]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/fs/minix.c (grub_minix_read_file): Simplify arithmetics.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 7 Jan 2013 10:27:18 +0000 (11:27 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 7 Jan 2013 10:27:18 +0000 (11:27 +0100)
ChangeLog
grub-core/fs/minix.c

index af2916120b0408e6be3cda221526949d7c137c0f..cdb3f3d337730b6f5a85e9c0e3f7fc1b5c4c6ab2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-01-07  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/fs/minix.c (grub_minix_read_file): Simplify arithmetics.
+
 2013-01-05  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/ext2.c (grub_ext2_read_block): Use shifts rather than
index 1e1c13b561fa994342c6cb726d71c2e25a389394..a62253387bd25ced6b042c09cd5ae3b3c8bad2bc 100644 (file)
@@ -261,12 +261,12 @@ grub_minix_read_file (struct grub_minix_data *data,
   /* Adjust len so it we can't read past the end of the file.  */
   if (len + pos > GRUB_MINIX_INODE_SIZE (data))
     len = GRUB_MINIX_INODE_SIZE (data) - pos;
+  if (len == 0)
+    return 0;
 
   /* Files are at most 2G/4G - 1 bytes on minixfs. Avoid 64-bit division.  */
-  blockcnt = ((grub_uint32_t) ((len + pos
-                               + (data->block_size << GRUB_DISK_SECTOR_BITS)
-                               - 1)
-              >> GRUB_DISK_SECTOR_BITS)) / data->block_size;
+  blockcnt = ((grub_uint32_t) ((len + pos - 1)
+              >> GRUB_DISK_SECTOR_BITS)) / data->block_size + 1;
   posblock = (((grub_uint32_t) pos)
              / (data->block_size << GRUB_DISK_SECTOR_BITS));
   blockoff = (((grub_uint32_t) pos)