Re: [PATCH v5 0/6] rust: reduce pointer casts, enable related lints

Tamir Duberstein
2025-03-25T13:35:32Z

On Tue, Mar 25, 2025 at 7:05 AM Benno Lossin <benno.lossin@proton.me> wrote:
>
> On Mon Mar 24, 2025 at 10:59 PM CET, Tamir Duberstein wrote:
> > On Mon, Mar 24, 2025 at 5:55 PM Benno Lossin <benno.lossin@proton.me> wrote:
> >> 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@proton.me> wrote:
> >> >> * `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?
> >
> > Yeah, it's not clear to me why it isn't covered by `cast_lossless`.
> > Might just be a bug. Want to file it?
>
> Done: https://github.com/rust-lang/rust-clippy/issues/14469

Nice, looks like there's already a PR out:
https://github.com/rust-lang/rust-clippy/pull/14470.

> >> >> 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.
> >
> > Well, I don't really know what's left to do. We're pretty close at
> > this point to having enabled everything but the nukes. Then there's
> > the strict provenance thing, which I suppose we can write down.
>
> Yes, but there are also these from my original mail:
> * `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 don't think we should go fixing things for which we don't have a
clippy lint. That way lies madness, particularly as patches begin to
be carried by other trees.

>
> And the other points (haven't taken a look at the other series you
> submitted, so I don't know to what extend you fixed the other `as` casts
> I mentioned). So I figured you might know which ones we still have after
> applying all your patches :)
>
> ---
> Cheers,
> Benno
>