From: Ritvik Gupta <ritvikfoss@gmail.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: tglx@kernel.org, peterz@infradead.org, ojeda@kernel.org,
boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com,
lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com,
tmgross@umich.edu, dakr@kernel.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org, skhan@linuxfoundation.org
Subject: Re: [PATCH] rust: cpu: use `unsafe_precondition_assert!`
Date: Tue, 19 May 2026 00:23:03 +0530 [thread overview]
Message-ID: <agtgD3wqjTvcldGx@fedora> (raw)
In-Reply-To: <CANiq72=5PUubJDYD57yhEC117tzNo9h6d=7f8OiengaExmGnyQ@mail.gmail.com>
On Mon, May 18, 2026 at 07:51:28PM +0200, Miguel Ojeda wrote:
> On Mon, May 18, 2026 at 7:40 PM Ritvik Gupta <ritvikfoss@gmail.com> wrote:
> >
> > Replace `debug_assert!` invocations with
> > `unsafe_precondition_assert!` in `from_i32_unchecked`
> > and `from_u32_unchecked` unsafe functions.
>
> Thanks for the patch!
>
> This should mention that we are adding messages too. That could
> actually be a second patch in the series to make it even clearer, but
> it is not a big a deal either way (and perhaps `rustfmt` makes that
> first patch not that clean due to the line wrapping anyway).
>
> Suggested-by: Miguel Ojeda <ojeda@kernel.org>
> Link: https://github.com/Rust-for-Linux/linux/issues/1232
>
> > -use crate::{bindings, device::Device, error::Result, prelude::ENODEV};
> > +use crate::{bindings, device::Device, error::Result, prelude::ENODEV, unsafe_precondition_assert};
>
> We should probably put it in the prelude along the others -- the
> easier it is to type, the better, to encourage its use.
>
> Do you want to add a first patch in the series doing that?
>
Sure! In v2 series, I'll add the first patch that adds `unsafe_precondition_assert!` to the prelude and
second patch that uses it.
> > + "CpuId::from_i32_unchecked requires a valid 'id' (i.e., `0 <= id < nr_cpu_ids()`)"
>
> This seems to mix Markdown backquotes with single quotes, and then
> doesn't use backquotes in the first part. Could we make it consistent
> if we are adding the messages? e.g.
>
> "`CpuId::from_i32_unchecked` requires a valid `id` (i.e., `0 <= id
> < nr_cpu_ids()`)"
>
Sure, will fix :)
> Sashiko has also spotted a copy-paste error in the one below.
>
> Cheers,
> Miguel
prev parent reply other threads:[~2026-05-18 18:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 17:44 [PATCH] rust: cpu: use `unsafe_precondition_assert!` Ritvik Gupta
2026-05-18 17:51 ` Miguel Ojeda
2026-05-18 18:53 ` Ritvik Gupta [this message]
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=agtgD3wqjTvcldGx@fedora \
--to=ritvikfoss@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tglx@kernel.org \
--cc=tmgross@umich.edu \
/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