From 5cfdceb4909d9ee6ac2502b83215fb71f5077e06 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 7 Aug 2022 19:47:25 -0400 Subject: Fix UBSAN if s_log_groups_per_flex is 31 It is logal (albeit rare) for the number of block groups per flex_bg to 2**31 (which effectively means to put all of the block groups into a single flex_bg). However, in that case "1 << 31" is undefined on architectures with a 32-bit integer. Fix this UBSAN complaint by using "1U << 31" instead. Signed-off-by: Theodore Ts'o --- misc/e4defrag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'misc') diff --git a/misc/e4defrag.c b/misc/e4defrag.c index 86e97ee3..9ec265f2 100644 --- a/misc/e4defrag.c +++ b/misc/e4defrag.c @@ -1021,7 +1021,7 @@ static int get_best_count(ext4_fsblk_t block_count) return 1; if (feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) { - flex_bg_num = 1 << log_groups_per_flex; + flex_bg_num = 1U << log_groups_per_flex; ret = ((block_count - 1) / ((ext4_fsblk_t)blocks_per_group * flex_bg_num)) + 1; -- cgit v1.2.1