* grub-core/fs/zfs/zfs.c (grub_zfs_read): Remove useless alloc and

handle NULL appropriately.
	Remove MIN.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-01-14 11:23:51 +01:00
parent 30c7d3ce34
commit 74a1dce71d
2 changed files with 14 additions and 10 deletions

View file

@ -1,3 +1,9 @@
2012-01-14 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/zfs/zfs.c (grub_zfs_read): Remove useless alloc and
handle NULL appropriately.
Remove MIN.
2012-01-13 Vladimir Serbinenko <phcoder@gmail.com> 2012-01-13 Vladimir Serbinenko <phcoder@gmail.com>
Fix efiemu. Fix efiemu.

View file

@ -3509,14 +3509,6 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
grub_size_t read; grub_size_t read;
grub_err_t err; grub_err_t err;
if (data->file_buf == NULL)
{
data->file_buf = grub_malloc (SPA_MAXBLOCKSIZE);
if (!data->file_buf)
return -1;
data->file_start = data->file_end = 0;
}
/* /*
* If offset is in memory, move it into the buffer provided and return. * If offset is in memory, move it into the buffer provided and return.
*/ */
@ -3553,12 +3545,18 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
0, data); 0, data);
data->file_buf = t; data->file_buf = t;
if (err) if (err)
{
data->file_buf = NULL;
data->file_start = data->file_end = 0;
return -1; return -1;
}
data->file_start = blkid * blksz; data->file_start = blkid * blksz;
data->file_end = data->file_start + blksz; data->file_end = data->file_start + blksz;
movesize = MIN (length, data->file_end - file->offset - read); movesize = data->file_end - file->offset - read;
if (movesize > length)
movesize = length;
grub_memmove (buf, data->file_buf + file->offset + read grub_memmove (buf, data->file_buf + file->offset + read
- data->file_start, movesize); - data->file_start, movesize);