* [PATCH] rust: cpumask: Replace `MaybeUninit` with `Opaque::uninit`
@ 2025-07-10 12:38 Ritvik Gupta
2025-07-10 12:41 ` Alice Ryhl
2025-07-10 15:01 ` Benno Lossin
0 siblings, 2 replies; 3+ messages in thread
From: Ritvik Gupta @ 2025-07-10 12:38 UTC (permalink / raw)
To: viresh.kumar, ojeda, alex.gaynor
Cc: yury.norov, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg,
aliceryhl, tmgross, dakr, rust-for-linux, skhan, Benno Lossin
Replace unsafe `MaybeUninit::uninit().assume_init()`
initialization with `Opaque::uninit()`, which is an
abstraction for handling opaque FFI types.
Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1178
Signed-off-by: Ritvik Gupta <ritvikfoss@gmail.com>
---
rust/kernel/cpumask.rs | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/rust/kernel/cpumask.rs b/rust/kernel/cpumask.rs
index 4bce230a73b68..5f84b8797c2a7 100644
--- a/rust/kernel/cpumask.rs
+++ b/rust/kernel/cpumask.rs
@@ -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
--
2.50.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] rust: cpumask: Replace `MaybeUninit` with `Opaque::uninit`
2025-07-10 12:38 [PATCH] rust: cpumask: Replace `MaybeUninit` with `Opaque::uninit` Ritvik Gupta
@ 2025-07-10 12:41 ` Alice Ryhl
2025-07-10 15:01 ` Benno Lossin
1 sibling, 0 replies; 3+ messages in thread
From: Alice Ryhl @ 2025-07-10 12:41 UTC (permalink / raw)
To: Ritvik Gupta
Cc: viresh.kumar, ojeda, alex.gaynor, yury.norov, boqun.feng, gary,
bjorn3_gh, lossin, a.hindborg, tmgross, dakr, rust-for-linux,
skhan, Benno Lossin
On Thu, Jul 10, 2025 at 2:37 PM Ritvik Gupta <ritvikfoss@gmail.com> wrote:
>
> Replace unsafe `MaybeUninit::uninit().assume_init()`
> initialization with `Opaque::uninit()`, which is an
> abstraction for handling opaque FFI types.
>
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
> Link: https://github.com/Rust-for-Linux/linux/issues/1178
> Signed-off-by: Ritvik Gupta <ritvikfoss@gmail.com>
I would make the same change to the mem::zeroed() call in
CpumaskVar::new_zeroed().
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rust: cpumask: Replace `MaybeUninit` with `Opaque::uninit`
2025-07-10 12:38 [PATCH] rust: cpumask: Replace `MaybeUninit` with `Opaque::uninit` Ritvik Gupta
2025-07-10 12:41 ` Alice Ryhl
@ 2025-07-10 15:01 ` Benno Lossin
1 sibling, 0 replies; 3+ messages in thread
From: Benno Lossin @ 2025-07-10 15:01 UTC (permalink / raw)
To: Ritvik Gupta, viresh.kumar, ojeda, alex.gaynor
Cc: yury.norov, boqun.feng, gary, bjorn3_gh, a.hindborg, aliceryhl,
tmgross, dakr, rust-for-linux, skhan, Benno Lossin
On Thu Jul 10, 2025 at 2:38 PM CEST, Ritvik Gupta wrote:
> Replace unsafe `MaybeUninit::uninit().assume_init()`
> initialization with `Opaque::uninit()`, which is an
> abstraction for handling opaque FFI types.
>
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
@Viresh when you take this, please use <lossin@kernel.org> :)
(it also is in .mailmap, so maybe it will automatically be fixed?)
> Link: https://github.com/Rust-for-Linux/linux/issues/1178
> Signed-off-by: Ritvik Gupta <ritvikfoss@gmail.com>
Thanks!
Reviewed-by: Benno Lossin <lossin@kernel.org>
---
Cheers,
Benno
> ---
> rust/kernel/cpumask.rs | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-10 15:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10 12:38 [PATCH] rust: cpumask: Replace `MaybeUninit` with `Opaque::uninit` Ritvik Gupta
2025-07-10 12:41 ` Alice Ryhl
2025-07-10 15:01 ` Benno Lossin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.