Re: [PATCH] bitfield.h: add FIELD_MAX_CONST

From: Jakub Kicinski
Date: Mon May 20 2024 - 18:26:47 EST


On Mon, 20 May 2024 12:29:54 -0700 Yury Norov wrote:
> > A simplified example of what I actually want to use in a driver:
> > #define DATA_SIZE_M GENMASK(3, 0)
> > #define MAX_DATA_SIZE FIELD_MAX_CONST(DATA_SIZE_M)
> > static void f(void) {
> > char buf[MAX_DATA_SIZE];

You need a "+ 1" somewhere here, right?

> > }
> >
> > In the implementation, reuse the existing compile-time checks from
> > FIELD_PREP_CONST.
> >
> > Signed-off-by: Michal Schmidt <mschmidt@xxxxxxxxxx>
>
> Hi Michal,
>
> So... FIELD_MAX() already requires the _mask to be a const value.
> Now you add a FIELD_MAX_CONST(), which makes it more confusing.

+1, I think this is doing too much in general.