On February 25, 2025 10:31:37 PM PST, 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.
I don't want such constructions in code I maintain. (Nor for return values.) But this is not code I maintain (obviously), so your call after all.
thanks,
Uh, no, that's not the point.
The point is that:
!!x
... is the same as
x ? true : false
... which if promoted to an integer, intentionally or not, becomes
x ? 1 : 0