[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLgg_11gFtGG=0zjhyYhK1JvChFxdXvwxKkAEUGxOpC-Ljw@mail.gmail.com>
Date: Thu, 10 Jul 2025 15:24:29 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Daniel Almeida <daniel.almeida@...labora.com>
Cc: 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>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Bjorn Helgaas <bhelgaas@...gle.com>, Mika Westerberg <mika.westerberg@...ux.intel.com>,
Ying Huang <huang.ying.caritas@...il.com>, Benno Lossin <lossin@...nel.org>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
Fiona Behrens <me@...enk.dev>
Subject: Re: [PATCH v12 1/3] rust: io: add resource abstraction
On Thu, Jul 10, 2025 at 3:16 PM Daniel Almeida
<daniel.almeida@...labora.com> wrote:
>
> Hi Alice,
>
> > Is this name used for a lookup or stored? If just a lookup, then it
> > doesn't need to be 'static.
> >
> >> + flags: Flags,
> >> + ) -> Option<Region> {
> >> + // SAFETY: Safe as per the invariant of `Resource`.
> >> + let region = unsafe {
> >> + bindings::__request_region(
> >> + self.0.get(),
> >> + start,
> >> + size,
> >> + name.as_char_ptr(),
> >> + flags.0 as i32,
> >
>
> JFYI, this is stored:
>
> static int __request_region_locked(struct resource *res, struct resource *parent,
> resource_size_t start, resource_size_t n,
> const char *name, int flags)
> {
> DECLARE_WAITQUEUE(wait, current);
>
> res->name = name;
I think it would be useful for the safety comment to say something
along the lines of "it's okay that __request_region stashes a copy of
the string because it is static".
Alice
Powered by blists - more mailing lists