Skip to contentSkip to conversation

swab: fix sparse warnings

PATCH New Stephen Hemminger 1 participant 1 message Jul 30, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 swab: fix sparse warnings

There are a lot of sparse warnings in networking code where a constant ends up being byte swapped caused because there is no explicit prototype for the __builtin_bswap functions. Simplest workaround is to just avoid them here, and use the normal swap routines when doing sparse checks.

include/uapi/linux/swab.h +3 -3
@@ -45,7 +45,7 @@
 
 static inline __attribute_const__ __u16 __fswab16(__u16 val)
 {
-#ifdef __HAVE_BUILTIN_BSWAP16__
+#if defined(__HAVE_BUILTIN_BSWAP16__) && !defined(__CHECKER__)
 	return __builtin_bswap16(val);
 #elif defined (__arch_swab16)
 	return __arch_swab16(val);
@@ -56,7 +56,7 @@ static inline __attribute_const__ __u16
 
 static inline __attribute_const__ __u32 __fswab32(__u32 val)
 {
-#ifdef __HAVE_BUILTIN_BSWAP32__
+#if defined(__HAVE_BUILTIN_BSWAP32__) && !defined(__CHECKER__)
 	return __builtin_bswap32(val);
 #elif defined(__arch_swab32)
 	return __arch_swab32(val);
@@ -67,7 +67,7 @@ static inline __attribute_const__ __u32
 
 static inline __attribute_const__ __u64 __fswab64(__u64 val)
 {
-#ifdef __HAVE_BUILTIN_BSWAP64__
+#if defined(__HAVE_BUILTIN_BSWAP64__) && !defined(__CHECKER__)
 	return __builtin_bswap64(val);
 #elif defined (__arch_swab64)
 	return __arch_swab64(val);