Re: [PATCH libcrypto v2 2/3] compiler: introduce at_least parameter decoration pseudo keyword
From: Jason A. Donenfeld
Date: Fri Nov 21 2025 - 21:46:50 EST
On Sat, Nov 22, 2025 at 3:45 AM Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
>
> Jason A. Donenfeld <Jason@xxxxxxxxx> wrote:
> >
> > +/*
> > + * This designates the minimum number of elements a passed array parameter must
> > + * have. For example:
> > + *
> > + * void some_function(u8 param[at_least 7]);
> > + *
> > + * If a caller passes an array with fewer than 7 elements, the compiler will
> > + * emit a warning.
> > + */
> > +#define at_least static
>
> Please make this conditional on __CHECKER__ as sparse still chokes
> on the following which compiles fine with gcc and clang:
>
> int foo(int n, int a[static n])
> {
> return a[0]++;
> }
Saw your reply to v1 and was thinking about that. Will do. Thanks for
pointing this out.
Jason