Re: [PATCH v2 2/2] rust: cpu: use `unsafe_precondition_assert!`

From: Miguel Ojeda

Date: Tue May 19 2026 - 01:42:38 EST


On Tue, May 19, 2026 at 12:57 AM Ritvik Gupta <ritvikfoss@xxxxxxxxx> wrote:
>
> Replace `debug_assert!` invocations with
> `unsafe_precondition_assert!` in `from_i32_unchecked`
> and `from_u32_unchecked` unsafe functions.

The commit message doesn't mention why the messages were added -- I
asked for it because I am not sure if it is worth providing a message
for each assertion, especially since the original code decided to
avoid it, i.e. the change to the new macro is good on its own,
regardless of the messages.

> -use crate::{bindings, device::Device, error::Result, prelude::ENODEV};
> +use crate::{bindings, device::Device, error::Result, prelude::*};

By the way, we could remove `error::Result` from the list since we
have the entire prelude now, and also take the chance to use the new
style:

https://docs.kernel.org/rust/coding-guidelines.html#imports

But maybe wait to see if the maintainers have other feedback before v3.

Thanks!

Cheers,
Miguel