Patch "word-at-a-time: use the same return type for has_zero regardless of endianness" has been added to the 4.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    word-at-a-time: use the same return type for has_zero regardless of endianness

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     word-at-a-time-use-the-same-return-type-for-has_zero.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit fe4c279e12a028114123eb54abd7555d2e59a3b9
Author: ndesaulniers@xxxxxxxxxx <ndesaulniers@xxxxxxxxxx>
Date:   Tue Aug 1 15:22:17 2023 -0700

    word-at-a-time: use the same return type for has_zero regardless of endianness
    
    [ Upstream commit 79e8328e5acbe691bbde029a52c89d70dcbc22f3 ]
    
    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: https://github.com/ClangBuiltLinux/linux/issues/1832
    Link: https://lore.kernel.org/lkml/20230801-bitwise-v1-1-799bec468dc4@xxxxxxxxxx/
    Fixes: 36126f8f2ed8 ("word-at-a-time: make the interfaces truly generic")
    Debugged-by: Nathan Chancellor <nathan@xxxxxxxxxx>
    Signed-off-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
    Acked-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
    Cc: Arnd Bergmann <arnd@xxxxxxxx>
    Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/powerpc/include/asm/word-at-a-time.h b/arch/powerpc/include/asm/word-at-a-time.h
index f3f4710d4ff52..99129b0cd8b8a 100644
--- a/arch/powerpc/include/asm/word-at-a-time.h
+++ b/arch/powerpc/include/asm/word-at-a-time.h
@@ -34,7 +34,7 @@ static inline long find_zero(unsigned long mask)
 	return leading_zero_bits >> 3;
 }
 
-static inline bool has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c)
+static inline unsigned long has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c)
 {
 	unsigned long rhs = val | c->low_bits;
 	*data = rhs;
diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h
index 20c93f08c9933..95a1d214108a5 100644
--- a/include/asm-generic/word-at-a-time.h
+++ b/include/asm-generic/word-at-a-time.h
@@ -38,7 +38,7 @@ static inline long find_zero(unsigned long mask)
 	return (mask >> 8) ? byte : byte + 1;
 }
 
-static inline bool has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c)
+static inline unsigned long has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c)
 {
 	unsigned long rhs = val | c->low_bits;
 	*data = rhs;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux