[PATCH] rust: error: allow `useless_conversion` for 32-bit builds

Miguel Ojeda miguel.ojeda.sandonis at gmail.com
Sun Aug 18 14:32:26 PDT 2024


On Tue, Jul 30, 2024 at 5:57 PM Miguel Ojeda <ojeda at kernel.org> wrote:
>
> For the new Rust support for 32-bit arm [1], Clippy warns:
>
>     error: useless conversion to the same type: `i32`
>        --> rust/kernel/error.rs:139:36
>         |
>     139 |         unsafe { bindings::ERR_PTR(self.0.into()) as *mut _ }
>         |                                    ^^^^^^^^^^^^^ help: consider removing `.into()`: `self.0`
>         |
>         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
>         = note: `-D clippy::useless-conversion` implied by `-D warnings`
>         = help: to override `-D warnings` add `#[allow(clippy::useless_conversion)]`
>
> The `self.0.into()` converts an `c_int` into `ERR_PTR`'s parameter
> which is a `c_long`. Thus, both types are `i32` in 32-bit. Therefore,
> allow it for those architectures.
>
> Link: https://lore.kernel.org/rust-for-linux/2dbd1491-149d-443c-9802-75786a6a3b73@gmail.com/ [1]
> Signed-off-by: Miguel Ojeda <ojeda at kernel.org>

Applied to `rust-next` -- thanks everyone!

    [ Fixed typo in tag. - Miguel ]

We can also change the formatting later on top of the series that will
enable that lint.

Cheers,
Miguel



More information about the linux-arm-kernel mailing list