* [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
2026-06-28 10:16 ` Miguel Ojeda
0 siblings, 2 replies; 4+ 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] 4+ 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
2026-06-28 10:16 ` Miguel Ojeda
1 sibling, 0 replies; 4+ 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] 4+ 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
@ 2026-06-28 10:16 ` Miguel Ojeda
2026-06-30 15:43 ` Nicolás Antinori
1 sibling, 1 reply; 4+ messages in thread
From: Miguel Ojeda @ 2026-06-28 10:16 UTC (permalink / raw)
To: Nicolás Antinori
Cc: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Christian Brauner, Carlos Llamas, Alice Ryhl, 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
On Fri, Jun 26, 2026 at 11:44 PM Nicolás Antinori
<nico.antinori.7@gmail.com> wrote:
>
> - // 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();
I would just remove the variable and put `zeroed()` directly in the
fops initializer like we do in other cases, but it is fine of course.
I guess it will go through Binder, but if `rust-next` is preferred,
please let me know.
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust_binder: use pin_init::zeroed for file_operations initialization
2026-06-28 10:16 ` Miguel Ojeda
@ 2026-06-30 15:43 ` Nicolás Antinori
0 siblings, 0 replies; 4+ messages in thread
From: Nicolás Antinori @ 2026-06-30 15:43 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Christian Brauner, Carlos Llamas, Alice Ryhl, 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
On Sun Jun 28, 2026 at 7:16 AM -03, Miguel Ojeda wrote:
> On Fri, Jun 26, 2026 at 11:44 PM Nicolás Antinori
> <nico.antinori.7@gmail.com> wrote:
>>
>> - // 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();
>
> I would just remove the variable and put `zeroed()` directly in the
> fops initializer like we do in other cases, but it is fine of course.
I thought of that as well but I tried to touch as little as possible (I
assumed that was in a variable for a reason). I can send a v2 if that is
preferred!
Thank you,
Nicolás
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-30 15:43 UTC | newest]
Thread overview: 4+ 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
2026-06-28 10:16 ` Miguel Ojeda
2026-06-30 15:43 ` Nicolás Antinori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox