[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9253sEI_cRS3mtN@pollux>
Date: Fri, 21 Mar 2025 20:11:26 +0100
From: Danilo Krummrich <dakr@...nel.org>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: kernel test robot <lkp@...el.com>, bhelgaas@...gle.com,
gregkh@...uxfoundation.org, rafael@...nel.org, ojeda@...nel.org,
alex.gaynor@...il.com, boqun.feng@...il.com, gary@...yguo.net,
bjorn3_gh@...tonmail.com, benno.lossin@...ton.me,
a.hindborg@...nel.org, aliceryhl@...gle.com, tmgross@...ch.edu,
llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
linux-pci@...r.kernel.org, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/4] rust: pci: impl TryFrom<&Device> for &pci::Device
On Fri, Mar 21, 2025 at 07:59:08PM +0100, Miguel Ojeda wrote:
> On Fri, Mar 21, 2025 at 6:44 PM Danilo Krummrich <dakr@...nel.org> wrote:
> >
> > This requires an unsafe block for compilers < 1.82. For compilers >= 1.82 it
> > turns into a warning *if* using an unsafe block.
> >
> > *Not* requiring unsafe for this seems like the correct thing -- was this a
> > bugfix in the compiler?
> >
> > I guess to make it work for all compiler versions supported by the kernel we
> > have to use unsafe and suppress the warning?
>
> It was a feature, but it has been fairly annoying -- it affected
> several series, e.g. the latest KUnit one as well as:
>From the second link:
"Previously, the compiler's safety checks were not aware that the raw ref
operator did not actually affect the operand's place, treating it as a possible
read or write to a pointer. No unsafety is actually present, however, as it just
creates a pointer.
That sounds like it was a bug, or do I miss anything?
>
> https://lore.kernel.org/rust-for-linux/CANiq72kuebpOa4aPxmTXNMA0eo-SLL+Ht9u1SGHymXBF5_92eA@mail.gmail.com/
>
> Please see:
>
> https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#safely-addressing-unsafe-statics
>
> So, yeah, we use `allow(unused_unsafe)` (no `expect`, since it depends
> on the version).
>
> I hope that helps.
Yeah, thanks a lot. Especially for the second link, I couldn't find it even
after quite a while of searching.
I will respin right away, since otherwise the patches of v3 are reviewed.
Powered by blists - more mailing lists