[PATCH] rust: drm: use `pin_init::zeroed()` for file operations initialization

Atharv Dubey posted 1 patch 2 days, 8 hours ago
rust/kernel/drm/gem/mod.rs | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
[PATCH] rust: drm: use `pin_init::zeroed()` for file operations initialization
Posted by Atharv Dubey 2 days, 8 hours ago
Replace the manual `unsafe { core::mem::zeroed() }` initialization of
`bindings::file_operations` with `pin_init::zeroed()`. This removes the
explicit unsafe

Signed-off-by: Atharv Dubey <atharvd440@gmail.com>
---
 rust/kernel/drm/gem/mod.rs | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index 30c853988b94..c220cf1966fd 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -298,9 +298,8 @@ impl<T: DriverObject> AllocImpl for Object<T> {
 }
 
 pub(super) const fn create_fops() -> bindings::file_operations {
-    // SAFETY: As by the type invariant, it is safe to initialize `bindings::file_operations`
-    // zeroed.
-    let mut fops: bindings::file_operations = unsafe { core::mem::zeroed() };
+
+    let mut fops: bindings::file_operations = pin_init::zeroed();
 
     fops.owner = core::ptr::null_mut();
     fops.open = Some(bindings::drm_open);
-- 
2.43.0
Re: [PATCH] rust: drm: use `pin_init::zeroed()` for file operations initialization
Posted by Miguel Ojeda 2 days, 7 hours ago
On Sat, Nov 29, 2025 at 2:48 PM Atharv Dubey <atharvd440@gmail.com> wrote:
>
> +

Spurious newline?

Cheers,
Miguel
Re: [PATCH] rust: drm: use `pin_init::zeroed()` for file operations initialization
Posted by Atharv Dubey 7 hours ago
On Sat, Nov 29, 2025 at 03:30:53PM +0100, Miguel Ojeda wrote:
> On Sat, Nov 29, 2025 at 2:48 PM Atharv Dubey <atharvd440@gmail.com> wrote:
> >
> > +
> 
> Spurious newline?
> > Sorry for this, I will send a V2 of the patch.
> Cheers,
> Miguel