Re: [PATCH 1/2] x86/bootflag: Change some static functions to bool

From: Ingo Molnar
Date: Wed Feb 26 2025 - 07:23:59 EST



* Jiri Slaby <jirislaby@xxxxxxxxxx> wrote:

> On 24. 02. 25, 19:58, Ingo Molnar wrote:
> > So this CodingStyle entry is a red herring, and the !! is absolutely
> > used in the kernel
>
> Sure, for intended conversion to either 0 or 1.
>
> > as an explicit marker of intentional type conversion
> > to bool.
>
> With this in mind, you would have to write "if (!!x)" everywhere.

No, why would I? In a conditional statement any type conversion is for
that evaluation alone and any mistakes are limited to that statement.

On a return statement the value continues to live on in the call
context and has a far longer lifetime. Marking that the type conversion
from int to bool was intentional is prudent, and the use of '!!' is
common practice within the kernel:

starship:~/tip> git grep '!!' -- '*.[ch]' | wc -l
10739

Thanks,

Ingo