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

Jiri Slaby
2025-03-07T10:53:05Z

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