[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAH5fLgh7n75Q4Txi29CxFG4nfkxzceqh=bMBDyYj01G_KC0vwg@mail.gmail.com>
Date: Fri, 20 Jun 2025 15:19:22 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Benno Lossin <lossin@...nel.org>
Cc: Alexander Viro <viro@...iv.linux.org.uk>, Jan Kara <jack@...e.cz>,
Miguel Ojeda <ojeda@...nel.org>, Christian Brauner <brauner@...nel.org>, 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>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org
Subject: Re: [PATCH] poll: rust: allow poll_table ptrs to be null
On Fri, Jun 20, 2025 at 2:31 PM Benno Lossin <lossin@...nel.org> wrote:
>
> On Fri Jun 20, 2025 at 1:49 PM CEST, Alice Ryhl wrote:
> > ///
> > /// # Safety
> > ///
> > - /// The caller must ensure that for the duration of `'a`, the pointer will point at a valid poll
> > - /// table (as defined in the type invariants).
> > - ///
> > - /// The caller must also ensure that the `poll_table` is only accessed via the returned
> > - /// reference for the duration of `'a`.
> > - pub unsafe fn from_ptr<'a>(ptr: *mut bindings::poll_table) -> &'a mut PollTable {
>
> Returning `Option<&'a mut PollTable>` is not an option? I'd like to
> avoid wrapping raw pointers...
You're going to make people handle the Option by early-returning if
you do that, but that's wrong. You're supposed to treat null and
non-null the same.
Alice
Powered by blists - more mailing lists