projects/linux·commit ef91bb19

kernel.h: Silence sparse warning in lower_32_bits

ef91bb19 · Herbert Xu <[email protected]> · 2020-08-28 17:11:25 +10:00

I keep getting sparse warnings in crypto such as:

  CHECK   drivers/crypto/ccree/cc_hash.c
   drivers/crypto/ccree/cc_hash.c:49:9: warning: cast truncates bits from constant value (47b5481dbefa4fa4 becomes befa4fa4)
   drivers/crypto/ccree/cc_hash.c:49:26: warning: cast truncates bits from constant value (db0c2e0d64f98fa7 becomes 64f98fa7)
   [.. many more ..]

This patch removes the warning by adding a mask to keep sparse
happy.

Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
ef91bb196b0db1013ef8705367bc2d7944ef696b
Parents
e3094285

Changes

1 files changed · +1 −1

FileStatusAddDelContent
include/linux/kernel.hmodified+1−1View file

include/linux/kernel.h

View file
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 500def6..c25b8e4 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -186,7 +186,7 @@
* lower_32_bits - return bits 0-31 of a number
* @n: the number we're accessing
*/
-#define lower_32_bits(n) ((u32)(n))
+#define lower_32_bits(n) ((u32)((n) & 0xffffffff))
struct completion;
struct pt_regs;