Skip to contentSkip to conversation

include/uapi: Fix invalid use of BITS_PER_LONG in __swab

PATCH In review Torsten Hilbrich 2 participants 2 messages Feb 12, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include/uapi: Fix invalid use of BITS_PER_LONG in __swab

This caused compile problems in user-space application using that header. Seen with systemd:

In file included from /build/client/devel/kernel/_/usr/include/linux/byteorder/little_endian.h:13,
from /build/client/devel/kernel/_/usr/include/asm/byteorder.h: ,
from /build/client/devel/kernel/_/usr/include/linux/icmpv6.h:6,
from ../src/network/networkd-route.c:3:
/build/client/devel/kernel/_/usr/include/linux/swab.h: In function ‘__swab’:
/build/client/devel/kernel/_/usr/include/linux/swab.h:138:5: error: "BITS_PER_LONG" is not defined, evaluates to 0 [-Werror=undef]

 #if BITS_PER_LONG == 64
     ^~~~~~~~~~~~~

cc1: some warnings being treated as errors
[181/1207] Generating sys with a custom command.
ninja: build stopped: subcommand failed.

---
 include/uapi/linux/swab.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/swab.h +2 -2
index fa7f97da5b76..7272f85d6d6a 100644
@@ -135,9 +135,9 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val)
 
 static __always_inline unsigned long __swab(const unsigned long y)
 {
-#if BITS_PER_LONG == 64
+#if __BITS_PER_LONG == 64
 	return __swab64(y);
-#else /* BITS_PER_LONG == 32 */
+#else /* __BITS_PER_LONG == 32 */
 	return __swab32(y);
 #endif
 }
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 38 lines · Torsten Hilbrich

This caused compile problems in user-space application using that header. Seen with systemd:

In file included from /build/client/devel/kernel/_/usr/include/linux/byteorder/little_endian.h:13,
from /build/client/devel/kernel/_/usr/include/asm/byteorder.h: ,
from /build/client/devel/kernel/_/usr/include/linux/icmpv6.h:6,
from ../src/network/networkd-route.c:3:
/build/client/devel/kernel/_/usr/include/linux/swab.h: In function ‘__swab’:
/build/client/devel/kernel/_/usr/include/linux/swab.h:138:5: error: "BITS_PER_LONG" is not defined, evaluates to 0 [-Werror=undef]

 #if BITS_PER_LONG == 64
     ^~~~~~~~~~~~~

cc1: some warnings being treated as errors
[181/1207] Generating sys with a custom command.
ninja: build stopped: subcommand failed.

---
 include/uapi/linux/swab.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/swab.h +2 -2
index fa7f97da5b76..7272f85d6d6a 100644
@@ -135,9 +135,9 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val)
 
 static __always_inline unsigned long __swab(const unsigned long y)
 {
-#if BITS_PER_LONG == 64
+#if __BITS_PER_LONG == 64
 	return __swab64(y);
-#else /* BITS_PER_LONG == 32 */
+#else /* __BITS_PER_LONG == 32 */
 	return __swab32(y);
 #endif
 }
Signature · 1 line
2.20.1