linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Joerg Roedel <joerg.roedel@amd.com>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] kernel.h: Silence sparse warning in lower_32_bits
Date: Fri, 28 Aug 2020 17:11:25 +1000	[thread overview]
Message-ID: <20200828071125.GA18772@gondor.apana.org.au> (raw)

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)
../drivers/crypto/ccree/cc_hash.c:49:43: warning: cast truncates bits from constant value (8eb44a8768581511 becomes 68581511)
../drivers/crypto/ccree/cc_hash.c:49:60: warning: cast truncates bits from constant value (67332667ffc00b31 becomes ffc00b31)
../drivers/crypto/ccree/cc_hash.c:50:9: warning: cast truncates bits from constant value (152fecd8f70e5939 becomes f70e5939)
../drivers/crypto/ccree/cc_hash.c:50:26: warning: cast truncates bits from constant value (9159015a3070dd17 becomes 3070dd17)
../drivers/crypto/ccree/cc_hash.c:50:43: warning: cast truncates bits from constant value (629a292a367cd507 becomes 367cd507)
../drivers/crypto/ccree/cc_hash.c:50:60: warning: cast truncates bits from constant value (cbbb9d5dc1059ed8 becomes c1059ed8)
../drivers/crypto/ccree/cc_hash.c:52:9: warning: cast truncates bits from constant value (5be0cd19137e2179 becomes 137e2179)
../drivers/crypto/ccree/cc_hash.c:52:26: warning: cast truncates bits from constant value (1f83d9abfb41bd6b becomes fb41bd6b)
../drivers/crypto/ccree/cc_hash.c:52:43: warning: cast truncates bits from constant value (9b05688c2b3e6c1f becomes 2b3e6c1f)
../drivers/crypto/ccree/cc_hash.c:52:60: warning: cast truncates bits from constant value (510e527fade682d1 becomes ade682d1)
../drivers/crypto/ccree/cc_hash.c:53:9: warning: cast truncates bits from constant value (a54ff53a5f1d36f1 becomes 5f1d36f1)
../drivers/crypto/ccree/cc_hash.c:53:26: warning: cast truncates bits from constant value (3c6ef372fe94f82b becomes fe94f82b)
../drivers/crypto/ccree/cc_hash.c:53:43: warning: cast truncates bits from constant value (bb67ae8584caa73b becomes 84caa73b)
../drivers/crypto/ccree/cc_hash.c:53:60: warning: cast truncates bits from constant value (6a09e667f3bcc908 becomes f3bcc908)

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

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 500def620d8f..c25b8e41c0ea 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;
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

             reply	other threads:[~2020-08-28  7:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28  7:11 Herbert Xu [this message]
2020-08-29 10:51 ` [PATCH] kernel.h: Silence sparse warning in lower_32_bits Guenter Roeck
2020-08-29 12:45   ` [PATCH] dmaengine: fsldma: Do not pass pointers to lower_32_bits Herbert Xu
2020-08-29 15:08     ` Guenter Roeck
2020-08-29 12:45   ` [PATCH] fsldma: fsl_ioread64*() do not need lower_32_bits() Luc Van Oostenryck
2020-08-29 17:29     ` Linus Torvalds
2020-08-29 20:40       ` Guenter Roeck
2020-08-29 21:20         ` Linus Torvalds
2020-08-31  1:54           ` Michael Ellerman
2020-08-31  6:39           ` Vinod Koul
2020-08-31 14:25           ` Leo Li
2020-08-30 12:11       ` Luc Van Oostenryck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200828071125.GA18772@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=akpm@linux-foundation.org \
    --cc=joerg.roedel@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).