From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
torvalds@linux-foundation.org, ebiggers@kernel.org,
kees@kernel.org, linux-crypto@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH libcrypto v2 2/3] compiler: introduce at_least parameter decoration pseudo keyword
Date: Sat, 22 Nov 2025 13:02:04 +0100 [thread overview]
Message-ID: <aSGmPAmCXJiv73wI@zx2c4.com> (raw)
In-Reply-To: <CAMj1kXG0adfCkuM4f92csxF0bxxBo6sNe_iJ_szKNEcEfgFwqg@mail.gmail.com>
On Sat, Nov 22, 2025 at 12:53:58PM +0100, Ard Biesheuvel wrote:
> On Sat, 22 Nov 2025 at 04:08, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> >
> > On Sat, Nov 22, 2025 at 03:46:38AM +0100, Jason A. Donenfeld wrote:
> > >
> > > Saw your reply to v1 and was thinking about that. Will do. Thanks for
> > > pointing this out.
> >
> > It seems that we need to bring the brackets back, because sparse
> > won't take this either:
> >
> > int foo(int n, int a[n])
> > {
> > return a[0]++;
> > }
> >
> > But this seems to work:
> >
> > #ifdef __CHECKER__
> > #define at_least(x)
> > #else
> > #define at_least(x) static x
> > #endif
> >
> > int foo(int n, int a[at_least(n)])
> > {
> > return a[0]++;
> > }
> >
>
> This is a different idiom: n is a function argument, not a compile
> time constant.
>
> Clang and GCC both appear to permit it, but only GCC [11 or newer]
> emits a diagnostic when 'n' exceeds the size of a[]. There is also
> work ongoing to support the counted_by variable attribute for formal
> function parameters in both compilers.
>
> So for the moment, I think we should limit this to compile time
> constants only, in which case sparse is happy too, right?
Sparse seems happy with my v3 for constants:
https://lore.kernel.org/all/20251122025510.1625066-4-Jason@zx2c4.com/
For this new idiom -- function arguments -- I think I'll look into just
fixing sparse. This seems like something useful down the line.
So I think we ought to merge v3 as-is, and then take the longer but
better road for this additional feature Herbert has brought up, by
extending sparse.
Jason
next prev parent reply other threads:[~2025-11-22 12:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 1:10 [PATCH libcrypto v2 1/3] wifi: iwlwifi: trans: rename at_least variable to min_mode Jason A. Donenfeld
2025-11-20 1:10 ` [PATCH libcrypto v2 2/3] compiler: introduce at_least parameter decoration pseudo keyword Jason A. Donenfeld
2025-11-21 11:03 ` Ard Biesheuvel
2025-11-22 2:45 ` Herbert Xu
2025-11-22 2:46 ` Jason A. Donenfeld
2025-11-22 3:08 ` Herbert Xu
2025-11-22 11:53 ` Ard Biesheuvel
2025-11-22 12:02 ` Jason A. Donenfeld [this message]
2025-11-22 19:19 ` Eric Biggers
2025-11-22 19:33 ` Eric Biggers
2025-11-23 13:21 ` Jason A. Donenfeld
2025-11-20 1:10 ` [PATCH libcrypto v2 3/3] crypto: chacha20poly1305: statically check fixed array lengths Jason A. Donenfeld
2025-11-21 11:04 ` Ard Biesheuvel
2025-11-21 11:03 ` [PATCH libcrypto v2 1/3] wifi: iwlwifi: trans: rename at_least variable to min_mode Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aSGmPAmCXJiv73wI@zx2c4.com \
--to=jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=kees@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox