erofs-utils: fix bitops fls_long()
authorHongzhen Luo <hongzhen@linux.alibaba.com>
Tue, 9 Jul 2024 07:38:19 +0000 (15:38 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 9 Jul 2024 11:08:33 +0000 (19:08 +0800)
`__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 <hongzhen@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240709073819.3061805-1-hongzhen@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
include/erofs/defs.h

index e0798c841ce08c53943a4286b1b71e90d775483b..310a6aba34c9aec62cbcb21aea0f743cc6e2e635 100644 (file)
@@ -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)