All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benno Lossin" <lossin@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: "Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Jan Kara" <jack@suse.cz>, "Miguel Ojeda" <ojeda@kernel.org>,
	"Christian Brauner" <brauner@kernel.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] poll: rust: allow poll_table ptrs to be null
Date: Sun, 22 Jun 2025 09:50:15 +0200	[thread overview]
Message-ID: <DASWBTM3280H.KMIP372JNU2O@kernel.org> (raw)
In-Reply-To: <CAH5fLgh7n75Q4Txi29CxFG4nfkxzceqh=bMBDyYj01G_KC0vwg@mail.gmail.com>

On Fri Jun 20, 2025 at 3:19 PM CEST, Alice Ryhl wrote:
> On Fri, Jun 20, 2025 at 2:31 PM Benno Lossin <lossin@kernel.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.

Ah right...

An `PollTableInner` type that wraps the `bindings::poll_table` opaquely
sounds like too much work, so let's go with your approach.

---
Cheers,
Benno

  reply	other threads:[~2025-06-22  7:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20 11:49 [PATCH] poll: rust: allow poll_table ptrs to be null Alice Ryhl
2025-06-20 12:31 ` Benno Lossin
2025-06-20 13:19   ` Alice Ryhl
2025-06-22  7:50     ` Benno Lossin [this message]
2025-06-22  7:55 ` Benno Lossin
2025-06-23 11:56 ` Christian Brauner
2025-06-23 13:57   ` Benno Lossin
2025-06-23 13:58   ` Alice Ryhl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DASWBTM3280H.KMIP372JNU2O@kernel.org \
    --to=lossin@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=brauner@kernel.org \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.