All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rust_binder: use pin_init::zeroed for file_operations initialization
@ 2026-06-26 21:44 Nicolás Antinori
  2026-06-27  8:25 ` Alexandre Courbot
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolás Antinori @ 2026-06-26 21:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Christian Brauner, Carlos Llamas, Alice Ryhl
  Cc: Nicolás Antinori, Alexandre Courbot, Miguel Ojeda,
	Andreas Hindborg, Benno Lossin, Björn Roy Baron, Boqun Feng,
	Daniel Almeida, Danilo Krummrich, Gary Guo, Onur Özkan,
	Shuah Khan, Tamir Duberstein, Trevor Gross, linux-kernel,
	rust-for-linux, linux-kernel-mentees

All types in `bindings` implement `Zeroable` if they can. This enables
using `pin_init::zeroed()` for `file_operations` initialization instead
of relying on `unsafe { core::mem::MaybeUninit::zeroed().assume_init() }`.

This change improves readability and removes an unnecessary unsafe
block.

Link: https://github.com/Rust-for-Linux/linux/issues/1189
Suggested-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
---
 drivers/android/binder/rust_binder_main.rs | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/binder/rust_binder_main.rs
index dc1941cd2407..7f07fb5e171b 100644
--- a/drivers/android/binder/rust_binder_main.rs
+++ b/drivers/android/binder/rust_binder_main.rs
@@ -314,8 +314,7 @@ unsafe impl<T> Sync for AssertSync<T> {}
 #[no_mangle]
 #[used]
 pub static rust_binder_fops: AssertSync<kernel::bindings::file_operations> = {
-    // SAFETY: All zeroes is safe for the `file_operations` type.
-    let zeroed_ops = unsafe { core::mem::MaybeUninit::zeroed().assume_init() };
+    let zeroed_ops = pin_init::zeroed();

     let ops = kernel::bindings::file_operations {
         owner: THIS_MODULE.as_ptr(),
--
2.47.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rust_binder: use pin_init::zeroed for file_operations initialization
  2026-06-26 21:44 [PATCH] rust_binder: use pin_init::zeroed for file_operations initialization Nicolás Antinori
@ 2026-06-27  8:25 ` Alexandre Courbot
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Courbot @ 2026-06-27  8:25 UTC (permalink / raw)
  To: Nicolás Antinori
  Cc: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Christian Brauner, Carlos Llamas, Alice Ryhl, Miguel Ojeda,
	Andreas Hindborg, Benno Lossin, Björn Roy Baron, Boqun Feng,
	Daniel Almeida, Danilo Krummrich, Gary Guo, Onur Özkan,
	Shuah Khan, Tamir Duberstein, Trevor Gross, linux-kernel,
	rust-for-linux, linux-kernel-mentees

On Sat Jun 27, 2026 at 6:44 AM JST, Nicolás Antinori wrote:
> All types in `bindings` implement `Zeroable` if they can. This enables
> using `pin_init::zeroed()` for `file_operations` initialization instead
> of relying on `unsafe { core::mem::MaybeUninit::zeroed().assume_init() }`.
>
> This change improves readability and removes an unnecessary unsafe
> block.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1189
> Suggested-by: Benno Lossin <lossin@kernel.org>
> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-27  8:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-26 21:44 [PATCH] rust_binder: use pin_init::zeroed for file_operations initialization Nicolás Antinori
2026-06-27  8:25 ` Alexandre Courbot

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.