[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D8OTXLDQCOKI.34R1U5R0JSB8H@proton.me>
Date: Mon, 24 Mar 2025 21:55:08 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Tamir Duberstein <tamird@...il.com>
Cc: Masahiro Yamada <masahiroy@...nel.org>, Nathan Chancellor <nathan@...nel.org>, Nicolas Schier <nicolas@...sle.eu>, Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>, Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, "Rafael J. Wysocki" <rafael@...nel.org>, Brendan Higgins <brendan.higgins@...ux.dev>, David Gow <davidgow@...gle.com>, Rae Moar <rmoar@...gle.com>, Bjorn Helgaas <bhelgaas@...gle.com>, Luis Chamberlain <mcgrof@...nel.org>, Russ Weight <russ.weight@...ux.dev>, Rob Herring <robh@...nel.org>, Saravana Kannan <saravanak@...gle.com>, linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org, linux-kselftest@...r.kernel.org, kunit-dev@...glegroups.com,
linux-pci@...r.kernel.org, linux-block@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v5 0/6] rust: reduce pointer casts, enable related lints
On Mon Mar 24, 2025 at 9:55 PM CET, Tamir Duberstein wrote:
> On Mon, Mar 24, 2025 at 4:16 PM Benno Lossin <benno.lossin@...ton.me> wrote:
>> * `shared_ref as *const _` (for example in rust/kernel/uaccess.rs:247,
>> rust/kernel/str.rs:32 and rust/kernel/fs/file.rs:367), these we can
>> replace with `let ptr: *const ... = shared_ref;`. Don't know if there
>> is a clippy lint for this.
>
> I think there's not a focused one. There's a nuclear option:
> https://rust-lang.github.io/rust-clippy/master/index.html?levels=allow#as_conversions
Yeah I saw that one, I don't think it's a good idea, since there will be
false positives.
>> * some pointer casts in rust/kernel/list/impl_list_item_mod.rs:{253,254}
>> not sure if they can be converted though (maybe they are unsizing the
>> pointer?)
>
> I have a local series that gets rid of these by doing similar things
> to https://lore.kernel.org/all/20250307-no-offset-v1-0-0c728f63b69c@gmail.com/.
> I can send it later this week but it probably can't land until Alice
> is back from vacation; she was the author of this code.
No worries, as I wrote below, I think it's fine to do that in a new
series.
>> Another pointer cast in rust/kernel/driver.rs:81 (I'm pretty sure this
>> one can be replaced by a `.cast()`)
>>
>> Some clippy lints that we could also enable that share the spirit of
>> this series:
>>
>> * `char_lit_as_u8` (maybe that also covers the `'|' as u32` case from
>> above?)
>
> It's already enabled, it's warn-by-default.
Ah I see, didn't look :)
>> * `cast_lossless` (maybe this catches some of the `num as int_type`
>> conversions I mentioned above)
>
> Yeah, suggested the same above. I had hoped this would deal with the
> char as u32 pattern but it did not.
Aw that's a shame. Maybe we should create a clippy issue for that,
thoughts?
>> I'll leave it up to you what you want to do with this: add it to this
>> series, make a new one, or let someone else handle it. If you don't want
>> to handle it, let me know, then I'll create a good-first-issue :)
>
> I'll add a patch for `cast_lossless` -- the rest should probably go
> into an issue.
Do you mind filing the issue? Then you can decide yourself what you want
to do yourself vs what you want to leave for others. Feel free to copy
from my mail summary.
Also I wouldn't mark it as a good-first-issue yet, since it's pretty
complicated and needs to be delayed/based on this series.
---
Cheers,
Benno
Powered by blists - more mailing lists