Skip to content

Commit

Permalink
rust: rbtree: fix SAFETY comments that should be # Safety sections
Browse files Browse the repository at this point in the history
The tag `SAFETY` is used for safety comments, i.e. `// SAFETY`, while a
`Safety` section is used for safety preconditions in code documentation,
i.e. `/// # Safety`.

Fix the three instances recently added in `rbtree` that Clippy would
have normally caught in a public item, so that we can enable checking
of private items in the next commit.

Fixes: 98c14e4 ("rust: rbtree: add cursor")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
  • Loading branch information
ojeda committed Sep 4, 2024
1 parent cbdd221 commit b4cd291
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rust/kernel/rbtree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,8 @@ impl<'a, K, V> Cursor<'a, K, V> {
NonNull::new(neighbor)
}

/// SAFETY:
/// # Safety
///
/// - `node` must be a valid pointer to a node in an [`RBTree`].
/// - The caller has immutable access to `node` for the duration of 'b.
unsafe fn to_key_value<'b>(node: NonNull<bindings::rb_node>) -> (&'b K, &'b V) {
Expand All @@ -894,7 +895,8 @@ impl<'a, K, V> Cursor<'a, K, V> {
(k, unsafe { &*v })
}

/// SAFETY:
/// # Safety
///
/// - `node` must be a valid pointer to a node in an [`RBTree`].
/// - The caller has mutable access to `node` for the duration of 'b.
unsafe fn to_key_value_mut<'b>(node: NonNull<bindings::rb_node>) -> (&'b K, &'b mut V) {
Expand All @@ -904,7 +906,8 @@ impl<'a, K, V> Cursor<'a, K, V> {
(k, unsafe { &mut *v })
}

/// SAFETY:
/// # Safety
///
/// - `node` must be a valid pointer to a node in an [`RBTree`].
/// - The caller has immutable access to the key for the duration of 'b.
unsafe fn to_key_value_raw<'b>(node: NonNull<bindings::rb_node>) -> (&'b K, *mut V) {
Expand Down

0 comments on commit b4cd291

Please sign in to comment.