Skip to content

Commit f6be7af

Browse files
charmitroojeda
authored andcommitted
rust: rbtree: fix comments referring to Box instead of KBox
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: 8373147 ("rust: treewide: switch to our kernel `Box` type") Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net> Reviewed-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20250315-rbtree-comment-fixes-v1-1-51f72c420ff0@posteo.net Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 5928642 commit f6be7af

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

rust/kernel/rbtree.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,12 +1168,12 @@ impl<'a, K, V> RawVacantEntry<'a, K, V> {
11681168
fn insert(self, node: RBTreeNode<K, V>) -> &'a mut V {
11691169
let node = KBox::into_raw(node.node);
11701170

1171-
// SAFETY: `node` is valid at least until we call `Box::from_raw`, which only happens when
1171+
// SAFETY: `node` is valid at least until we call `KBox::from_raw`, which only happens when
11721172
// the node is removed or replaced.
11731173
let node_links = unsafe { addr_of_mut!((*node).links) };
11741174

11751175
// INVARIANT: We are linking in a new node, which is valid. It remains valid because we
1176-
// "forgot" it with `Box::into_raw`.
1176+
// "forgot" it with `KBox::into_raw`.
11771177
// SAFETY: The type invariants of `RawVacantEntry` are exactly the safety requirements of `rb_link_node`.
11781178
unsafe { bindings::rb_link_node(node_links, self.parent, self.child_field_of_parent) };
11791179

@@ -1259,7 +1259,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
12591259
fn replace(self, node: RBTreeNode<K, V>) -> RBTreeNode<K, V> {
12601260
let node = KBox::into_raw(node.node);
12611261

1262-
// SAFETY: `node` is valid at least until we call `Box::from_raw`, which only happens when
1262+
// SAFETY: `node` is valid at least until we call `KBox::from_raw`, which only happens when
12631263
// the node is removed or replaced.
12641264
let new_node_links = unsafe { addr_of_mut!((*node).links) };
12651265

0 commit comments

Comments
 (0)