Re: [PATCH v4 2/2] linux/bits.h: simplify GENMASK_INPUT_CHECK()

From: Vincent Mailhol
Date: Sun Nov 17 2024 - 20:14:32 EST


On Mon. 18 Nov. 2024 at 02:24, David Laight <David.Laight@xxxxxxxxxx> wrote:
> 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.
>
> More interesting would be to get it to pass a W=1 build for
> any place where 'l' is 0u.

Are you referring to -Wtype-limits? If yes, this warning was moved to
W=2. I suggested in the past to add a cast to silence this warning,
but got rejected:

https://lore.kernel.org/lkml/CAHk-=whvGWbpsTa538CvQ9e=VF+m8WPQmES2y6-=0=-64uGkgg@xxxxxxxxxxxxxx/

Yours sincerely,
Vincent Mailhol