mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Benno Lossin <benno.lossin@proton.me>
To: "Charalampos Mitrodimas" <charmitro@posteo.net>,
	"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>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: rbtree: fix comments referring to Box instead of KBox
Date: Sun, 16 Mar 2025 09:20:08 +0000	[thread overview]
Message-ID: <D8HKV6149T8U.2HZ2WE1E8FCJ@proton.me> (raw)
In-Reply-To: <20250315-rbtree-comment-fixes-v1-1-51f72c420ff0@posteo.net>

On Sat Mar 15, 2025 at 10:48 PM CET, Charalampos Mitrodimas wrote:
> Several safety comments in the RBTree implementation still refer to
> "Box::from_raw" and "Box::into_raw", but the code actually uses KBox.
> These comments were not updated when the implementation transitioned
> from using Box to KBox.
>
> Fixes: 8373147ce496 ("rust: treewide: switch to our kernel `Box` type")
> Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>

Reviewed-by: Benno Lossin <benno.lossin@proton.me>

---
Cheers,
Benno

> ---
>  rust/kernel/rbtree.rs | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/rust/kernel/rbtree.rs b/rust/kernel/rbtree.rs
> index 0d1e75810664e18c0abe851ece2223d203721f79..a7ce512773563150fc2c290c544f20baad6509bf 100644
> --- a/rust/kernel/rbtree.rs
> +++ b/rust/kernel/rbtree.rs
> @@ -1168,12 +1168,12 @@ impl<'a, K, V> RawVacantEntry<'a, K, V> {
>      fn insert(self, node: RBTreeNode<K, V>) -> &'a mut V {
>          let node = KBox::into_raw(node.node);
>  
> -        // SAFETY: `node` is valid at least until we call `Box::from_raw`, which only happens when
> +        // SAFETY: `node` is valid at least until we call `KBox::from_raw`, which only happens when
>          // the node is removed or replaced.
>          let node_links = unsafe { addr_of_mut!((*node).links) };
>  
>          // INVARIANT: We are linking in a new node, which is valid. It remains valid because we
> -        // "forgot" it with `Box::into_raw`.
> +        // "forgot" it with `KBox::into_raw`.
>          // SAFETY: The type invariants of `RawVacantEntry` are exactly the safety requirements of `rb_link_node`.
>          unsafe { bindings::rb_link_node(node_links, self.parent, self.child_field_of_parent) };
>  
> @@ -1259,7 +1259,7 @@ pub fn remove(self) -> V {
>      fn replace(self, node: RBTreeNode<K, V>) -> RBTreeNode<K, V> {
>          let node = KBox::into_raw(node.node);
>  
> -        // SAFETY: `node` is valid at least until we call `Box::from_raw`, which only happens when
> +        // SAFETY: `node` is valid at least until we call `KBox::from_raw`, which only happens when
>          // the node is removed or replaced.
>          let new_node_links = unsafe { addr_of_mut!((*node).links) };
>  
>
> ---
> base-commit: eb88e6bfbc0a975e08a18c39d1138d3e6cdc00a5
> change-id: 20250315-rbtree-comment-fixes-99e567449195
>
> Best regards,



  reply	other threads:[~2025-03-16  9:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-15 21:48 Charalampos Mitrodimas
2025-03-16  9:20 ` Benno Lossin [this message]
2025-03-17 10:19 ` Alice Ryhl
2025-03-23 22:31 ` Miguel Ojeda

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=D8HKV6149T8U.2HZ2WE1E8FCJ@proton.me \
    --to=benno.lossin@proton.me \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=charmitro@posteo.net \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®