From: Johannes Berg <johannes@sipsolutions.net>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Arnd Bergmann <arnd@arndb.de>,
linux-sparse@vger.kernel.org,
Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH] byteswap: don't use __builtin_bswap*() with sparse
Date: Thu, 11 Aug 2016 13:15:02 +0200
Message-ID: <1470914102-26389-1-git-send-email-johannes@sipsolutions.net> (raw)
From: Johannes Berg <johannes.berg@intel.com>
Although sparse declares __builtin_bswap*(), it can't actually
do constant folding inside them (yet). As such, things like
switch (protocol) {
case htons(ETH_P_IP):
break;
}
which we do all over the place cause sparse to warn that it
expects a constant instead of a function call.
Disable __HAVE_BUILTIN_BSWAP*__ if __CHECKER__ is defined to
avoid this.
Cc: Arnd Bergmann <arnd@arndb.de>
Fixes: 7322dd755e7d ("byteswap: try to avoid __builtin_constant_p gcc bug")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
include/linux/compiler-gcc.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index e2949397c19b..8dbc8929a6a0 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -242,7 +242,11 @@
*/
#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
-#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
+/*
+ * sparse (__CHECKER__) pretends to be gcc, but can't do constant
+ * folding in __builtin_bswap*() (yet), so don't set these for it.
+ */
+#if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP) && !defined(__CHECKER__)
#if GCC_VERSION >= 40400
#define __HAVE_BUILTIN_BSWAP32__
#define __HAVE_BUILTIN_BSWAP64__
@@ -250,7 +254,7 @@
#if GCC_VERSION >= 40800
#define __HAVE_BUILTIN_BSWAP16__
#endif
-#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */
#if GCC_VERSION >= 50000
#define KASAN_ABI_VERSION 4
--
2.8.1
next reply index
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-11 11:15 Johannes Berg [this message]
2016-08-11 11:55 ` Arnd Bergmann
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=1470914102-26389-1-git-send-email-johannes@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=johannes.berg@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.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
Linux-Sparse Archive on lore.kernel.org
Archives are clonable:
git clone --mirror https://lore.kernel.org/linux-sparse/0 linux-sparse/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 linux-sparse linux-sparse/ https://lore.kernel.org/linux-sparse \
linux-sparse@vger.kernel.org
public-inbox-index linux-sparse
Example config snippet for mirrors
Newsgroup available over NNTP:
nntp://nntp.lore.kernel.org/org.kernel.vger.linux-sparse
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git