mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()`
@ 2025-10-25 12:42 Yizhe Sun
  2025-10-25 12:44 ` Miguel Ojeda
  0 siblings, 1 reply; 5+ messages in thread
From: Yizhe Sun @ 2025-10-25 12:42 UTC (permalink / raw)
  To: fujita.tomonori, ojeda, alex.gaynor
  Cc: tmgross, netdev, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg,
	aliceryhl, dakr, rust-for-linux, linux-kernel, Yizhe Sun

From: Benno Lossin <lossin@kernel.org>

All types in `bindings` implement `Zeroable` if they can, so use
`pin_init::zeroed` instead of relying on `unsafe` code.

If this ends up not compiling in the future, something in bindgen or on
the C side changed and is most likely incorrect.

Link: https://github.com/Rust-for-Linux/linux/issues/1189
Suggested-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Yizhe Sun <sunyizhe@fastmail.com>
---
 rust/kernel/net/phy.rs | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index bf6272d87a7b..46c693c5768a 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -553,9 +553,7 @@ pub const fn create_phy_driver<T: Driver>() -> DriverVTable {
         } else {
             None
         },
-        // SAFETY: The rest is zeroed out to initialize `struct phy_driver`,
-        // sets `Option<&F>` to be `None`.
-        ..unsafe { core::mem::MaybeUninit::<bindings::phy_driver>::zeroed().assume_init() }
+        ..pin_init::zeroed()
     }))
 }
 
-- 
2.51.1


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

* Re: [PATCH] rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()`
  2025-10-25 12:42 [PATCH] rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()` Yizhe Sun
@ 2025-10-25 12:44 ` Miguel Ojeda
  2025-10-25 12:49   ` Yizhe Sun
  0 siblings, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2025-10-25 12:44 UTC (permalink / raw)
  To: Yizhe Sun
  Cc: fujita.tomonori, ojeda, alex.gaynor, tmgross, netdev, boqun.feng,
	gary, bjorn3_gh, lossin, a.hindborg, aliceryhl, dakr,
	rust-for-linux, linux-kernel

On Sat, Oct 25, 2025 at 2:43 PM Yizhe Sun <sunyizhe@fastmail.com> wrote:
>
> From: Benno Lossin <lossin@kernel.org>

This looks wrong -- is the Git commit under his authorship?

Thanks!

Cheers,
Miguel

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

* Re: [PATCH] rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()`
  2025-10-25 12:44 ` Miguel Ojeda
@ 2025-10-25 12:49   ` Yizhe Sun
  2025-10-25 13:00     ` Miguel Ojeda
  0 siblings, 1 reply; 5+ messages in thread
From: Yizhe Sun @ 2025-10-25 12:49 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: fujita.tomonori, ojeda, alex.gaynor, tmgross, netdev, boqun.feng,
	gary, bjorn3_gh, lossin, a.hindborg, aliceryhl, dakr,
	rust-for-linux, linux-kernel

> This looks wrong -- is the Git commit under his authorship?

It is. He requested to have his patches re-sent because he didn't have time. This is my first time participating in kernel development, so please tell me if I did something wrong.

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

* Re: [PATCH] rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()`
  2025-10-25 12:49   ` Yizhe Sun
@ 2025-10-25 13:00     ` Miguel Ojeda
  2025-10-25 13:47       ` Yizhe Sun
  0 siblings, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2025-10-25 13:00 UTC (permalink / raw)
  To: Yizhe Sun
  Cc: fujita.tomonori, ojeda, alex.gaynor, tmgross, netdev, boqun.feng,
	gary, bjorn3_gh, lossin, a.hindborg, aliceryhl, dakr,
	rust-for-linux, linux-kernel

On Sat, Oct 25, 2025 at 2:50 PM Yizhe Sun <sunyizhe@fastmail.com> wrote:
>
> It is. He requested to have his patches re-sent because he didn't have time. This is my first time participating in kernel development, so please tell me if I did something wrong.

I see, thanks!

So it is this one:

    https://lore.kernel.org/rust-for-linux/20250814093046.2071971-5-lossin@kernel.org/

When submitting a patch on behalf of someone else, their Signed-off-by
tag must be kept (and then add yours too), since they are the author.
You can read about the procedure at the end of this section:

    https://docs.kernel.org/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin

Also, what I would normally suggest is to indicate that it is a resend
in the part outside the commit message (written right below the first
`---` line), ideally including a link to the original patch (i.e. the
first link I added here).

By the way, ideally patches also have a base commit with e.g. `git
format-patch --base`.

And no worries, it is all good, getting these details right the first
time is not trivial -- welcome! :)

If you could please resubmit it with the SoB fixed, that would be great.

Thanks!

Cheers,
Miguel

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

* Re: [PATCH] rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()`
  2025-10-25 13:00     ` Miguel Ojeda
@ 2025-10-25 13:47       ` Yizhe Sun
  0 siblings, 0 replies; 5+ messages in thread
From: Yizhe Sun @ 2025-10-25 13:47 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: fujita.tomonori, ojeda, alex.gaynor, tmgross, netdev, boqun.feng,
	gary, bjorn3_gh, lossin, a.hindborg, aliceryhl, dakr,
	rust-for-linux, linux-kernel

Thanks for the advice. I've fixed the issues and resubmitted the patch.

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

end of thread, other threads:[~2025-10-25 13:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-25 12:42 [PATCH] rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()` Yizhe Sun
2025-10-25 12:44 ` Miguel Ojeda
2025-10-25 12:49   ` Yizhe Sun
2025-10-25 13:00     ` Miguel Ojeda
2025-10-25 13:47       ` Yizhe Sun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®