From: Lorenzo Delgado <lnsdev@proton.me>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: "Lorenzo Delgado" <lnsdev@proton.me>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
"Thorsten Blum" <blum@kernel.org>,
"Francis Laniel" <laniel_francis@npnm.eu>
Subject: Re: [PATCH 2/2] rust: uaccess: use NonEmpty in strcpy_into_buf()
Date: Mon, 12 Oct 2026 18:24:32 +0000 [thread overview]
Message-ID: <20261012182426.4013900-1-lnsdev@proton.me> (raw)
In-Reply-To: <CANiq72niDTiewxWGC=PTCoG1xeb6hVmeKT+5N8DDHV2bQdQ0Ug@mail.gmail.com>
On Mon, Oct 12, 2026 at 2:22 PM Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:
>
> Hmm... I thought the idea was to request a `NonEmpty` in the signature.
>
> Is it not possible for some reason?
It's possible. I kept the signature as is to limit the change to the
inside of the function, but you're right: the point of the newtype is
to put the requirement in the signature. In v2 it will take
`&mut NonEmpty<[u8]>` and the `EINVAL` case goes away.
Since callers will usually pass a fixed-size array, v2 also adds a
constructor from `&mut [T; N]` that checks `N > 0` at compile time, so
they don't need a runtime check either.
Thanks,
Lorenzo
next prev parent reply other threads:[~2026-10-12 18:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 11:53 [PATCH 0/2] rust: add NonEmpty Lorenzo Delgado
2026-10-12 11:53 ` [PATCH 1/2] rust: non_empty: " Lorenzo Delgado
2026-10-12 11:53 ` [PATCH 2/2] rust: uaccess: use NonEmpty in strcpy_into_buf() Lorenzo Delgado
2026-10-12 12:22 ` Miguel Ojeda
2026-10-12 18:24 ` Lorenzo Delgado [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-12 11:46 [PATCH 0/2] rust: add NonEmpty Lorenzo Delgado
2026-10-12 11:46 ` [PATCH 2/2] rust: uaccess: use NonEmpty in strcpy_into_buf() Lorenzo Delgado
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=20261012182426.4013900-1-lnsdev@proton.me \
--to=lnsdev@proton.me \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=blum@kernel.org \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=laniel_francis@npnm.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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
all inboxes | Powered by JetHome®