lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z78HZ5i9aMJq58E4@gmail.com>
Date: Wed, 26 Feb 2025 13:21:59 +0100
From: Ingo Molnar <mingo@...nel.org>
To: Jiri Slaby <jirislaby@...nel.org>
Cc: Uros Bizjak <ubizjak@...il.com>, x86@...nel.org,
	linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
	Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH 1/2] x86/bootflag: Change some static functions to bool


* Jiri Slaby <jirislaby@...nel.org> 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ