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] [thread-next>] [day] [month] [year] [list]
Message-ID: <fea4cc244f2f4f1a8cde7c49548e74eb@AcuMS.aculab.com>
Date: Mon, 18 Nov 2024 09:27:17 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Vincent Mailhol' <mailhol.vincent@...adoo.fr>, Linus Torvalds
	<torvalds@...ux-foundation.org>
CC: Yury Norov <yury.norov@...il.com>, Rasmus Villemoes
	<linux@...musvillemoes.dk>, Luc Van Oostenryck <luc.vanoostenryck@...il.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-sparse@...r.kernel.org" <linux-sparse@...r.kernel.org>, "Rikard
 Falkeborn" <rikard.falkeborn@...il.com>
Subject: RE: [PATCH v4 1/2] compiler.h: add const_true()

From: Vincent Mailhol
> Sent: 18 November 2024 03:22
> 
> On Mon. 18 nov. 2024 à 07:58, Linus Torvalds
> <torvalds@...ux-foundation.org> wrote:
> > The "0*!(x)" is admittedly kind of ugly, and might be prettier as
> > "0&&(x)". Same number of characters, but technically one op less and
> > not mixing booleans and integer ops.
> 
> I did a tree wide replacement of __is_constexpr() with is_const() and
> did an allyesconfig build test. It yields a -Wint-in-bool-context
> warning in GCC for both the "0*!(x)" and the "0&&(x)" each time the
> expression contains non-boolean operators, for example: * or <<.
> 
> I reproduced it in godbolt here:
> 
>   https://godbolt.org/z/5Wcbvanq3

Applies to pretty much all the variants.
Needs to be (x) == 0 (or (x) != 0) rather than !(x)

Fortunately comparison operators (and ?:) are all valid in
constant integer expressions.

Oh, one advantage of statically_const() is that you can give
it a 'local' variable that contains the value.
So this works:
#define check_lo_ho(lo, hi) do { \
	__auto_type _lo = lo; \
	__auto_type _hi = hi; \
	BUILD_BUG_ON_MSG(_lo > _hi, "inverted bounds"); \
} while (0)

I'm trying to finalise a patch for min() and max().

	David

	

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ