mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
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 <lossin@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20250520231714.323931-1-lossin@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
committed by
Miguel Ojeda
parent
28753212e0
commit
4e6b5b8ab3
+5
-2
@@ -95,8 +95,11 @@ impl PinnedDrop for LockClassKey {
|
||||
macro_rules! static_lock_class {
|
||||
() => {{
|
||||
static CLASS: $crate::sync::LockClassKey =
|
||||
// SAFETY: lockdep expects uninitialized memory when it's handed a statically allocated
|
||||
// lock_class_key
|
||||
// Lockdep expects uninitialized memory when it's handed a statically allocated `struct
|
||||
// lock_class_key`.
|
||||
//
|
||||
// SAFETY: `LockClassKey` transparently wraps `Opaque` which permits uninitialized
|
||||
// memory.
|
||||
unsafe { ::core::mem::MaybeUninit::uninit().assume_init() };
|
||||
$crate::prelude::Pin::static_ref(&CLASS)
|
||||
}};
|
||||
|
||||
Reference in New Issue
Block a user