diff options
author | Johannes Berg <johannes.berg@intel.com> | 2016-08-25 18:16:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-26 20:39:34 -0400 |
commit | 101b29a204f87c99377faa53bd378f101ebb1824 (patch) | |
tree | c3cb59db61461cf85e05ed0daf6423148fb9ccb1 /include/linux/compiler-gcc.h | |
parent | 61c04572de404e52a655a36752e696bbcb483cf5 (diff) |
byteswap: don't use __builtin_bswap*() with sparse
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.
Fixes: 7322dd755e7d ("byteswap: try to avoid __builtin_constant_p gcc bug")
Link: http://lkml.kernel.org/r/1470914102-26389-1-git-send-email-johannes@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/compiler-gcc.h')
-rw-r--r-- | include/linux/compiler-gcc.h | 8 |
1 files 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 @@ | |||
242 | */ | 242 | */ |
243 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) | 243 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) |
244 | 244 | ||
245 | #ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP | 245 | /* |
246 | * sparse (__CHECKER__) pretends to be gcc, but can't do constant | ||
247 | * folding in __builtin_bswap*() (yet), so don't set these for it. | ||
248 | */ | ||
249 | #if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP) && !defined(__CHECKER__) | ||
246 | #if GCC_VERSION >= 40400 | 250 | #if GCC_VERSION >= 40400 |
247 | #define __HAVE_BUILTIN_BSWAP32__ | 251 | #define __HAVE_BUILTIN_BSWAP32__ |
248 | #define __HAVE_BUILTIN_BSWAP64__ | 252 | #define __HAVE_BUILTIN_BSWAP64__ |
@@ -250,7 +254,7 @@ | |||
250 | #if GCC_VERSION >= 40800 | 254 | #if GCC_VERSION >= 40800 |
251 | #define __HAVE_BUILTIN_BSWAP16__ | 255 | #define __HAVE_BUILTIN_BSWAP16__ |
252 | #endif | 256 | #endif |
253 | #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ | 257 | #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */ |
254 | 258 | ||
255 | #if GCC_VERSION >= 50000 | 259 | #if GCC_VERSION >= 50000 |
256 | #define KASAN_ABI_VERSION 4 | 260 | #define KASAN_ABI_VERSION 4 |