rust: drm: use `pin_init::zeroed()` for file operations initialization
Subsystems (3)
PATCH 1/1 rust: drm: use `pin_init::zeroed()` for file operations initialization
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 <[email protected]>
--- rust/kernel/drm/gem/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
rust/kernel/drm/gem/mod.rs +2 -3
@@ -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);
Signature · 1 line
2.43.0
Quoted 2 lines · Atharv Dubey
+
Spurious newline?
Cheers,
Miguel
Quoted 8 lines · Miguel Ojeda
Quoted 2 lines · Atharv Dubey
+
Spurious newline?
Quoted 1 line
Sorry for this, I will send a V2 of the patch.
Cheers,
Miguel