Thread (67 messages) 67 messages, 9 authors, 2025-04-04

Re: [PATCH v3 00/16] Introduce and use generic parity16/32/64 helper

From: Jiri Slaby <jirislaby@kernel.org>
Date: 2025-03-07 10:53:05
Also in: bpf, dri-devel, linux-input, linux-media, linux-serial, linux-wireless, lkml

On 07. 03. 25, 10:19, Kuan-Wei Chiu wrote:
I used to believe that casting a boolean variable to int would always
result in 0 or 1 until a few months ago when Waiman Long explicitly
pointed out during a review that C does not guarantee this.

So I revisited the C11 standard, which states that casting to _Bool
always results in 0 or 1 [1]. Another section specifies that bool,
true, and false are macros defined in <stdbool.h>, with true expanding
to 1 and false to 0. However, these macros can be #undef and redefined
to other values [2].
Note that we do not have/use user's stdbool.h in kernel at all. Instead, 
in linux/stddef.h, we define:
enum {
         false   = 0,
         true    = 1
};

So all is blue.

thanks,
-- 
js
suse labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help