Skip to contentSkip to conversation

linux/compiler.h: don't use bool

PATCH In review Rasmus Villemoes 3 participants 3 messages Aug 17, 2018 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/compiler.h: don't use bool

Appararently, it's possible to have a non-trivial TU include a few headers, including linux/build_bug.h, without ending up with linux/types.h. So the 0day bot sent me

config: um-x86_64_defconfig (attached as .config)

Quoted 1 line
Quoted 1 line

include/linux/compiler.h:316:3: error: unknown type name 'bool'; did you mean '_Bool'?

      bool __cond = !(condition);    \

for something I'm working on.

Rather than contributing to the #include madness and including linux/types.h from compiler.h, just use int.

---
 include/linux/compiler.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/compiler.h +1 -1
index 42506e4d1f53..c8eab637a2a7 100644
@@ -313,7 +313,7 @@ unsigned long read_word_at_a_time(const void *addr)
 #ifdef __OPTIMIZE__
 # define __compiletime_assert(condition, msg, prefix, suffix)		\
 	do {								\
-		bool __cond = !(condition);				\
+		int __cond = !(condition);				\
 		extern void prefix ## suffix(void) __compiletime_error(msg); \
 		if (__cond)						\
 			prefix ## suffix();				\
Signature · 1 line
2.16.4
#1 lore raw
Quoted 3 lines · On Fri, 17 Aug 2018 12:10:35 +0200 Rasmus Villemoes <[email protected]>…

Appararently, it's possible to have a non-trivial TU include a few headers, including linux/build_bug.h, without ending up with linux/types.h. So the 0day bot sent me

What's a "TU"?

Quoted 10 lines

config: um-x86_64_defconfig (attached as .config)

Quoted 1 line
Quoted 1 line

include/linux/compiler.h:316:3: error: unknown type name 'bool'; did you mean '_Bool'?

      bool __cond = !(condition);    \

for something I'm working on.

Rather than contributing to the #include madness and including linux/types.h from compiler.h, just use int.

#2 lore raw
Quoted 9 lines · Andrew Morton
Quoted 1 line · On Fri, 17 Aug 2018 12:10:35 +0200 Rasmus Villemoes <[email protected]>…

Appararently, it's possible to have a non-trivial TU include a few

headers,

Quoted 2 lines

including linux/build_bug.h, without ending up with linux/types.h. So the 0day bot sent me

What's a "TU"?

Probably "translation unit".