Re: [PATCH libcrypto 1/2] array_size: introduce min_array_size() function decoration
From: Herbert Xu
Date: Fri Nov 21 2025 - 21:37:39 EST
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> I wouldn't call that "asked for".
>
> It was more a musing on how random that "static" syntax is and it's
> likely incomprehensible to a lot of people - but also pointing out
> that we already do have users of it, and saying that maybe it won't be
> incomprehensible once we have a lot of users.
>
> So I'm definitely not pushing for it.
>
> But I do suspect it makes people understand what the code does more...
Actually there is one reason for using a macro instead of static
directly, sparse still seems to choke on a non-static value for
static:
int foo(int n, int a[static n])
{
return a[0]++;
}
This compiles correctly with gcc and clang, but sparse chokes on it:
a.c:1:29: error: undefined identifier 'n'
a.c:1:29: error: bad constant expression type
I was trying to use it in crypto/ecc.c where the arrays are
defined as ECC_MAX_DIGITS, but only the first ndigits are valid.
Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt