Skip to content

Commit 4e6b5b8

Browse files
BennoLossinojeda
authored andcommitted
rust: sync: fix safety comment for static_lock_class
The safety comment mentions lockdep -- which from a Rust perspective isn't important -- and doesn't mention the real reason for why it's sound to create `LockClassKey` as uninitialized memory. Signed-off-by: Benno Lossin <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 2875321 commit 4e6b5b8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

rust/kernel/sync.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ impl PinnedDrop for LockClassKey {
9595
macro_rules! static_lock_class {
9696
() => {{
9797
static CLASS: $crate::sync::LockClassKey =
98-
// SAFETY: lockdep expects uninitialized memory when it's handed a statically allocated
99-
// lock_class_key
98+
// Lockdep expects uninitialized memory when it's handed a statically allocated `struct
99+
// lock_class_key`.
100+
//
101+
// SAFETY: `LockClassKey` transparently wraps `Opaque` which permits uninitialized
102+
// memory.
100103
unsafe { ::core::mem::MaybeUninit::uninit().assume_init() };
101104
$crate::prelude::Pin::static_ref(&CLASS)
102105
}};

0 commit comments

Comments
 (0)