Skip to content

Commit 79e8328

Browse files
nickdesaulnierstorvalds
authored andcommitted
word-at-a-time: use the same return type for has_zero regardless of endianness
Compiling big-endian targets with Clang produces the diagnostic: fs/namei.c:2173:13: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical] } while (!(has_zero(a, &adata, &constants) | has_zero(b, &bdata, &constants))); ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ || fs/namei.c:2173:13: note: cast one or both operands to int to silence this warning It appears that when has_zero was introduced, two definitions were produced with different signatures (in particular different return types). Looking at the usage in hash_name() in fs/namei.c, I suspect that has_zero() is meant to be invoked twice per while loop iteration; using logical-or would not update `bdata` when `a` did not have zeros. So I think it's preferred to always return an unsigned long rather than a bool than update the while loop in hash_name() to use a logical-or rather than bitwise-or. [ Also changed powerpc version to do the same - Linus ] Link: ClangBuiltLinux#1832 Link: https://lore.kernel.org/lkml/[email protected]/ Fixes: 36126f8 ("word-at-a-time: make the interfaces truly generic") Debugged-by: Nathan Chancellor <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Acked-by: Heiko Carstens <[email protected]> Cc: Arnd Bergmann <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 5d0c230 commit 79e8328

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

arch/powerpc/include/asm/word-at-a-time.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static inline long find_zero(unsigned long mask)
3434
return leading_zero_bits >> 3;
3535
}
3636

37-
static inline bool has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c)
37+
static inline unsigned long has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c)
3838
{
3939
unsigned long rhs = val | c->low_bits;
4040
*data = rhs;

include/asm-generic/word-at-a-time.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static inline long find_zero(unsigned long mask)
3838
return (mask >> 8) ? byte : byte + 1;
3939
}
4040

41-
static inline bool has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c)
41+
static inline unsigned long has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c)
4242
{
4343
unsigned long rhs = val | c->low_bits;
4444
*data = rhs;

0 commit comments

Comments
 (0)