From: Hongzhen Luo Date: Tue, 9 Jul 2024 07:38:19 +0000 (+0800) Subject: erofs-utils: fix bitops fls_long() X-Git-Tag: v1.8~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5cce92be7c19e4171b148b2c4865ac20097256e6;p=platform%2Fupstream%2Ferofs-utils.git erofs-utils: fix bitops fls_long() `__builtin_clz` is for unsigned int, while it is now applied to unsigned long. This fixes it by using `__builtin_clzl`. `roundup_pow_of_two()` in `erofs_init_devices()` could give wrong results although the current compiler optimization level "-O2" covers it up. Signed-off-by: Hongzhen Luo Link: https://lore.kernel.org/r/20240709073819.3061805-1-hongzhen@linux.alibaba.com Signed-off-by: Gao Xiang --- diff --git a/include/erofs/defs.h b/include/erofs/defs.h index e0798c8..310a6ab 100644 --- a/include/erofs/defs.h +++ b/include/erofs/defs.h @@ -288,7 +288,7 @@ static inline u32 get_unaligned_le64(const void *p) static inline unsigned int fls_long(unsigned long x) { - return x ? sizeof(x) * 8 - __builtin_clz(x) : 0; + return x ? sizeof(x) * 8 - __builtin_clzl(x) : 0; } static inline unsigned long lowbit(unsigned long n)