Blame SOURCES/0089-grub-core-fs-minix.c-grub_minix_read_file-Simplify-a.patch

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