Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1460412 > unrolled thread
| Started by | Johannes Berg <johannes@sipsolutions.net> |
|---|---|
| First post | 2016-08-11 13:20 +0200 |
| Last post | 2016-08-11 14:00 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] byteswap: don't use __builtin_bswap*() with sparse Johannes Berg <johannes@sipsolutions.net> - 2016-08-11 13:20 +0200
Re: [PATCH] byteswap: don't use __builtin_bswap*() with sparse Arnd Bergmann <arnd@arndb.de> - 2016-08-11 14:00 +0200
| From | Johannes Berg <johannes@sipsolutions.net> |
|---|---|
| Date | 2016-08-11 13:20 +0200 |
| Subject | [PATCH] byteswap: don't use __builtin_bswap*() with sparse |
| Message-ID | <s4WbL-34E-21@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-08-11 14:00 +0200 |
| Message-ID | <s4WOu-3kP-41@gated-at.bofh.it> |
| In reply to | #1460412 |
On Thursday, August 11, 2016 1:15:02 PM CEST Johannes Berg wrote:
> 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>
Looks good, thanks for addressing this!
Acked-by: Arnd Bergmann <arnd@arndb.de>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web