rust: cpumask: Replace `MaybeUninit` with `Opaque::uninit`
Subsystems (2)
PATCH 1/1 rust: cpumask: Replace `MaybeUninit` with `Opaque::uninit`
Replace unsafe MaybeUninit::uninit().assume_init() initialization with Opaque::uninit(), which is an abstraction for handling opaque FFI types.
--- rust/kernel/cpumask.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
rust/kernel/cpumask.rs +1 -7
@@ -14,9 +14,6 @@#[cfg( CONFIG_CPUMASK_OFFSTACK )] use core::ptr::{self,NonNull }; -#[cfg(not( CONFIG_CPUMASK_OFFSTACK ))] -use core::mem::MaybeUninit ; -use core::ops::{Deref ,DerefMut };/// A CPU Mask.
@@ -266,10 +263,7 @@ pub unsafe fn new(_flags: Flags) -> Result<Self, AllocError> {NonNull ::new (ptr.cast ()).ok_or (AllocError )? },#[cfg(not( CONFIG_CPUMASK_OFFSTACK ))] -// SAFETY: Guaranteed by the safety requirements of the function. -// -// INVARIANT: The associated memory is freed when the `CpumaskVar` goes out of scope. - mask: unsafe { MaybeUninit::uninit().assume_init() }, + mask: Cpumask(Opaque::uninit()), }) }
base-commit: 2009a2d5696944d85c34d75e691a6f3884e787c0
Signature · 1 line
2.50.0
Quoted 8 lines · Ritvik Gupta
Replace unsafe
MaybeUninit::uninit().assume_init()initialization withOpaque::uninit(), which is an abstraction for handling opaque FFI types.Suggested-by Benno Lossin <[email protected]>Signed-off-by Ritvik Gupta <[email protected]>
I would make the same change to the mem::zeroed() call in CpumaskVar::new_zeroed().
Quoted 5 lines · Ritvik Gupta
Replace unsafe
MaybeUninit::uninit().assume_init()initialization withOpaque::uninit(), which is an abstraction for handling opaque FFI types.Suggested-by Benno Lossin <[email protected]>
@Viresh when you take this, please use <[email protected]> :)
(it also is in .mailmap, so maybe it will automatically be fixed?)
Quoted 2 lines
Thanks!
---
Cheers,
Benno
Quoted 3 lines
--- rust/kernel/cpumask.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)