* grub-core/fs/minix.c (grub_minix_read_file): Simplify arithmetics.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-01-07 11:27:18 +01:00
parent f797ec85a0
commit c6f1e92f0b
2 changed files with 8 additions and 4 deletions

View file

@ -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> 2013-01-05 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/ext2.c (grub_ext2_read_block): Use shifts rather than * grub-core/fs/ext2.c (grub_ext2_read_block): Use shifts rather than

View 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. */ /* Adjust len so it we can't read past the end of the file. */
if (len + pos > GRUB_MINIX_INODE_SIZE (data)) if (len + pos > GRUB_MINIX_INODE_SIZE (data))
len = GRUB_MINIX_INODE_SIZE (data) - pos; 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. */ /* Files are at most 2G/4G - 1 bytes on minixfs. Avoid 64-bit division. */
blockcnt = ((grub_uint32_t) ((len + pos blockcnt = ((grub_uint32_t) ((len + pos - 1)
+ (data->block_size << GRUB_DISK_SECTOR_BITS) >> GRUB_DISK_SECTOR_BITS)) / data->block_size + 1;
- 1)
>> GRUB_DISK_SECTOR_BITS)) / data->block_size;
posblock = (((grub_uint32_t) pos) posblock = (((grub_uint32_t) pos)
/ (data->block_size << GRUB_DISK_SECTOR_BITS)); / (data->block_size << GRUB_DISK_SECTOR_BITS));
blockoff = (((grub_uint32_t) pos) blockoff = (((grub_uint32_t) pos)