summaryrefslogtreecommitdiff
path: root/ext2fs
diff options
context:
space:
mode:
authorEtienne Brateau <etienne.brateau@gmail.com>2022-01-18 22:11:40 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-01-18 22:34:40 +0100
commit0ba67e20da488e1b715b5c33e3d08daeec3b8aba (patch)
tree8bacbdad4f07db45bfa1d5301af6b8c991e5d7ba /ext2fs
parentb874989276a33411f188f277e74b612612af6fac (diff)
ext2fs: fix invalid check
log2_dev_block_per_fs_block is unsigned so it won’t never be less than 0 and the check is then always false. Instead check the two values directly before doing the substraction. Message-Id: <20220118211140.8837-1-etienne.brateau@gmail.com>
Diffstat (limited to 'ext2fs')
-rw-r--r--ext2fs/hyper.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext2fs/hyper.c b/ext2fs/hyper.c
index 6ef2b8c3..e77c0266 100644
--- a/ext2fs/hyper.c
+++ b/ext2fs/hyper.c
@@ -84,11 +84,11 @@ get_hypermetadata (void)
ext2_panic ("block size %d is too big (max is %d bytes)",
block_size, EXT2_MAX_BLOCK_SIZE);
- log2_dev_blocks_per_fs_block = log2_block_size - store->log2_block_size;
- if (log2_dev_blocks_per_fs_block < 0)
+ if (log2_block_size < store->log2_block_size)
ext2_panic ("block size %d isn't a power-of-two multiple of the device"
" block size (%zd)!",
block_size, store->block_size);
+ log2_dev_blocks_per_fs_block = log2_block_size - store->log2_block_size;
log2_stat_blocks_per_fs_block = 0;
while ((512 << log2_stat_blocks_per_fs_block) < block_size)