[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f5692429eb4b43738f562e5fc402ead2@AcuMS.aculab.com>
Date: Sun, 17 Nov 2024 19:45:56 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Vincent Mailhol' <mailhol.vincent@...adoo.fr>, 'Linus Torvalds'
<torvalds@...ux-foundation.org>, 'Yury Norov' <yury.norov@...il.com>,
"'Rasmus Villemoes'" <linux@...musvillemoes.dk>, 'Luc Van Oostenryck'
<luc.vanoostenryck@...il.com>
CC: "'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 2/2] linux/bits.h: simplify GENMASK_INPUT_CHECK()
From: David Laight
> Sent: 17 November 2024 17:25
>
> From: Vincent Mailhol
> > Sent: 13 November 2024 17:19
> >
> > In GENMASK_INPUT_CHECK(),
> >
> > __builtin_choose_expr(__is_constexpr((l) > (h)), (l) > (h), 0)
> >
> > is the exact expansion of:
> >
> > const_true((l) > (h))
> >
> > Apply const_true() to simplify GENMASK_INPUT_CHECK().
>
> Wouldn't statically_true() give better coverage ?
> I wouldn't have though that GENMASK() got used anywhere where a constant
> integer expression was needed.
If it is, maybe add a GENMASK_CONST() that uses BUILD_BUG_ON_ZERO_MSG()
(recently proposed) and so validates that the values are constants.
And then use statically_true() in the normal case to pick up more errors.
(Or just remove the check because coders really aren't that stupid!)
The interesting cases are the ones using variables.
And they'd need run-time checks of some form.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists