]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/fs/zfs/zfs.c (grub_zfs_read): Remove useless alloc and
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 14 Jan 2012 10:23:51 +0000 (11:23 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 14 Jan 2012 10:23:51 +0000 (11:23 +0100)
handle NULL appropriately.
Remove MIN.

ChangeLog
grub-core/fs/zfs/zfs.c

index 45db5ffb35f73dd7a8f4dfeb8361c636ae7d92db..3e34a478c6f55b6915e47abe1138847ec7b2bd17 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        Fix efiemu.
index 534b7d224b3a09d502095a12c919686ee318b118..782563384de57ce58364b357bad3159df6054bbd 100644 (file)
@@ -3509,14 +3509,6 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
   grub_size_t read;
   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.
    */
@@ -3553,12 +3545,18 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
                      0, data);
       data->file_buf = t;
       if (err)
-       return -1;
+       {
+         data->file_buf = NULL;
+         data->file_start = data->file_end = 0;
+         return -1;
+       }
 
       data->file_start = blkid * 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
                    - data->file_start, movesize);