All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: "Oliver Mangold" <oliver.mangold@pm.me>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Asahi Lina" <lina@asahilina.net>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v10 3/5] rust: Add missing SAFETY documentation for ARef example
Date: Fri, 02 May 2025 14:01:22 +0200	[thread overview]
Message-ID: <877c2zz0fh.fsf@kernel.org> (raw)
In-Reply-To: <aBSofsTTbt4pgsDU@mango> (Oliver Mangold's message of "Fri, 02 May 2025 11:12:05 +0000")

"Oliver Mangold" <oliver.mangold@pm.me> writes:

> On 250502 1241, Andreas Hindborg wrote:
>> >
>> > diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs
>> > index d7fa8934c545f46a646ca900ab8957a04b0ad34d..33d2b4e4a87b991c6d934f4e8d2c6c71a15b1bcb 100644
>> > --- a/rust/kernel/types.rs
>> > +++ b/rust/kernel/types.rs
>> > @@ -498,7 +498,9 @@ pub unsafe fn from_raw(ptr: NonNull<T>) -> Self {
>> >      ///
>> >      /// struct Empty {}
>> >      ///
>> > -    /// # // SAFETY: TODO.
>> > +    /// // SAFETY: The `RefCounted` implementation for `Empty` does not count references
>> > +    /// // and never frees the underlying object. Thus we can act as having a
>> > +    /// // refcount on the object that we pass to the newly created `ARef`.
>> >      /// unsafe impl RefCounted for Empty {
>> >      ///     fn inc_ref(&self) {}
>> >      ///     unsafe fn dec_ref(_obj: NonNull<Self>) {}
>> > @@ -506,7 +508,7 @@ pub unsafe fn from_raw(ptr: NonNull<T>) -> Self {
>> >      ///
>> >      /// let mut data = Empty {};
>> >      /// let ptr = NonNull::<Empty>::new(&mut data).unwrap();
>> > -    /// # // SAFETY: TODO.
>> > +    /// // SAFETY: We keep `data` around longer than the `ARef`.
>>
>> I still think this applies:
>>
>> >> How about:
>> >>
>> >>   The `RefCounted` implementation for `Empty` does not count references
>> >>   and never frees the underlying object. Thus we can act as having a
>> >>   refcount on the object that we pass to the newly created `ARef`.
>> >>
>
> Hi Andreas,
>
> I agree. Sorry, I just messed up the fix. Your wording landed in the
> previous to-be-fixed unsafe comment, as you can see.
>
> Happens when you are too much in a hurry and didn't touch the patch for
> too long :/
>
> I will fix it in the next version.

Cool! Also check my response to v9: https://lore.kernel.org/all/87cycrz1pa.fsf@kernel.org


Best regards,
Andreas Hindborg




  reply	other threads:[~2025-05-02 12:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02  9:02 [PATCH v10 0/5] New trait OwnableRefCounted for ARef<->Owned conversion Oliver Mangold
2025-05-02  9:02 ` [PATCH v10 1/5] rust: types: Add Ownable/Owned types Oliver Mangold
2025-05-02  9:57   ` Andreas Hindborg
2025-06-16 11:43     ` Oliver Mangold
2025-06-17 11:42       ` Andreas Hindborg
2025-05-02 11:29   ` Alice Ryhl
2025-05-06 11:20     ` Andreas Hindborg
2025-05-07  6:20       ` Alice Ryhl
2025-05-08 12:24   ` Andreas Hindborg
2025-05-14  9:32   ` Benno Lossin
2025-06-17  9:58     ` Oliver Mangold
2025-06-18 21:22       ` Benno Lossin
2025-06-20  7:01         ` Oliver Mangold
2025-06-20  8:09           ` Benno Lossin
2025-06-18  9:34     ` Oliver Mangold
2025-06-18 21:19       ` Benno Lossin
2025-06-19  9:33         ` Andreas Hindborg
2025-06-19 12:18           ` Benno Lossin
2025-05-02  9:02 ` [PATCH v10 2/5] rust: Rename AlwaysRefCounted to RefCounted Oliver Mangold
2025-05-02 10:10   ` Andreas Hindborg
2025-05-02 11:32   ` Alice Ryhl
2025-06-16 11:56     ` Oliver Mangold
2025-06-16 12:13       ` Alice Ryhl
2025-05-02  9:02 ` [PATCH v10 3/5] rust: Add missing SAFETY documentation for ARef example Oliver Mangold
2025-05-02 10:41   ` Andreas Hindborg
2025-05-02 11:12     ` Oliver Mangold
2025-05-02 12:01       ` Andreas Hindborg [this message]
2025-05-02  9:02 ` [PATCH v10 4/5] rust: kbuild: provide `RUSTC_HAS_DO_NOT_RECOMMEND` symbol Oliver Mangold
2025-05-02  9:03 ` [PATCH v10 5/5] rust: Add OwnableRefCounted and SimpleOwnableRefCounted Oliver Mangold
2025-05-02 11:43   ` Alice Ryhl
2025-05-06 11:42     ` Oliver Mangold
2025-05-07  6:19       ` Alice Ryhl
2025-06-13 13:10 ` [PATCH v10 0/5] New trait OwnableRefCounted for ARef<->Owned conversion Andreas Hindborg
2025-06-13 13:27   ` Oliver Mangold

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=877c2zz0fh.fsf@kernel.org \
    --to=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=lina@asahilina.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=oliver.mangold@pm.me \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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.