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: <ddf0d76649c44fa29f0fb5c5514987cd@AcuMS.aculab.com>
Date: Sun, 28 Jul 2024 20:13:04 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Linus Torvalds' <torvalds@...uxfoundation.org>
CC: "'linux-kernel@...r.kernel.org'" <linux-kernel@...r.kernel.org>, "'Jens
 Axboe'" <axboe@...nel.dk>, "'Matthew Wilcox (Oracle)'" <willy@...radead.org>,
	'Christoph Hellwig' <hch@...radead.org>, 'Andrew Morton'
	<akpm@...ux-foundation.org>, 'Andy Shevchenko'
	<andriy.shevchenko@...ux.intel.com>, 'Dan Carpenter'
	<dan.carpenter@...aro.org>, 'Arnd Bergmann' <arnd@...nel.org>,
	"'Jason@...c4.com'" <Jason@...c4.com>, "'pedro.falcato@...il.com'"
	<pedro.falcato@...il.com>, 'Mateusz Guzik' <mjguzik@...il.com>,
	"'linux-mm@...ck.org'" <linux-mm@...ck.org>, 'Lorenzo Stoakes'
	<lorenzo.stoakes@...cle.com>
Subject: RE: [PATCH v2 4/8] minmax: Simplify signedness check

From: David Laight
> Sent: 28 July 2024 19:15
> 
> From: Linus Torvalds
> > Sent: 28 July 2024 17:57
> >
> > On Sun, 28 Jul 2024 at 07:21, David Laight <David.Laight@...lab.com> wrote:
> > >
> > > +/* Allow if both x and y are valid for either signed or unsigned compares. */
> > > +#define __types_ok(x, y)                               \
> > > +       ((__is_ok_signed(x) && __is_ok_signed(y)) ||    \
> > > +        (__is_ok_unsigned(x) && __is_ok_unsigned(y)))
> >
> > This seems horrendous, exactly because it expands both x and y twice.
> > And the "expand multiple times" was really the fundamental problem.
> 
> This version is better than the previous one ;-)
> 
> > Why not just change the model to say it's a bitmask of "signedness
> > bits", the bits are "signed ok" and "unsigned ok", and turn it into
> >
> >   /* Signedness matches? */
> >   #define __types_ok(x, y) \
> >      (__signedness_bits(x) & __signedness_bits(y))
> 
> Something like that might work, but it would take some effort to get right.

Actually it doesn't work.
The checks are is_signed((x) + 0) and is_unsigned((x)) so that 'unsigned char'
can be compared against both 'int' and 'unsigned int'.

But the signedness tests can use _unique_x which is trivially short.
That needs a pre-change to pass __COUNTER__ through (as in min3()).

	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