rust: drm: use `pin_init::zeroed()` for file operations initialization
Subsystems (3)
PATCH v2 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
--- rust/kernel/drm/gem/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
rust/kernel/drm/gem/mod.rs +1 -3
@@ -298,9 +298,7 @@ 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
Daniel Almeida
reviewerHi Atharv,
Quoted 30 lines · Atharv Dubey
Replace the manual
unsafe { core::mem::zeroed() }initialization ofbindings::file_operationswithpin_init::zeroed(). This removes the explicit unsafeSigned-off-by Atharv Dubey <[email protected]>---
rust/kernel/drm/gem/mod.rs| 4 +---1 file changed, 1 insertion(+), 3 deletions(-)rust/kernel/drm/gem/mod.rs +1
-3@@ -298,9 +298,7 @@ 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
I wonder if this should be part of a larger series that implements this change throughout the tree?
— Daniel
Quoted 3 lines · Daniel Almeida
I wonder if this should be part of a larger series that implements this change throughout the tree?
They are independent, so it is easier to land them as such (and may be clearer that is the case by sending them separately), but having them in a series (even if landed separately) is also OK.
Cheers,
Miguel
Alice Ryhl
maintainerQuoted 5 lines · Atharv Dubey
Replace the manual
unsafe { core::mem::zeroed() }initialization ofbindings::file_operationswithpin_init::zeroed(). This removes the explicit unsafeSigned-off-by Atharv Dubey <[email protected]>
Thanks, I'll pick this up for drm-rust-next once the branch reopens in two weeks.
Alice