a5bd9f6
From 8c3fd8eea724a1490d29937b1d23cde259bf63cb Mon Sep 17 00:00:00 2001
a5bd9f6
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
a5bd9f6
Date: Mon, 7 Jan 2013 11:27:18 +0100
a5bd9f6
Subject: [PATCH 088/364] 	* grub-core/fs/minix.c (grub_minix_read_file):
a5bd9f6
 Simplify arithmetics.
a5bd9f6
a5bd9f6
---
a5bd9f6
 ChangeLog            | 4 ++++
a5bd9f6
 grub-core/fs/minix.c | 8 ++++----
a5bd9f6
 2 files changed, 8 insertions(+), 4 deletions(-)
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index af29161..cdb3f3d 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,3 +1,7 @@
a5bd9f6
+2013-01-07  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
+
a5bd9f6
+	* grub-core/fs/minix.c (grub_minix_read_file): Simplify arithmetics.
a5bd9f6
+
a5bd9f6
 2013-01-05  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
 
a5bd9f6
 	* grub-core/fs/ext2.c (grub_ext2_read_block): Use shifts rather than
a5bd9f6
diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c
a5bd9f6
index 1e1c13b..a622533 100644
a5bd9f6
--- a/grub-core/fs/minix.c
a5bd9f6
+++ b/grub-core/fs/minix.c
a5bd9f6
@@ -261,12 +261,12 @@ grub_minix_read_file (struct grub_minix_data *data,
a5bd9f6
   /* Adjust len so it we can't read past the end of the file.  */
a5bd9f6
   if (len + pos > GRUB_MINIX_INODE_SIZE (data))
a5bd9f6
     len = GRUB_MINIX_INODE_SIZE (data) - pos;
a5bd9f6
+  if (len == 0)
a5bd9f6
+    return 0;
a5bd9f6
 
a5bd9f6
   /* Files are at most 2G/4G - 1 bytes on minixfs. Avoid 64-bit division.  */
a5bd9f6
-  blockcnt = ((grub_uint32_t) ((len + pos
a5bd9f6
-				+ (data->block_size << GRUB_DISK_SECTOR_BITS)
a5bd9f6
-				- 1)
a5bd9f6
-	       >> GRUB_DISK_SECTOR_BITS)) / data->block_size;
a5bd9f6
+  blockcnt = ((grub_uint32_t) ((len + pos - 1)
a5bd9f6
+	       >> GRUB_DISK_SECTOR_BITS)) / data->block_size + 1;
a5bd9f6
   posblock = (((grub_uint32_t) pos)
a5bd9f6
 	      / (data->block_size << GRUB_DISK_SECTOR_BITS));
a5bd9f6
   blockoff = (((grub_uint32_t) pos)
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6