rust: of: use safe zero initialization for struct of_device_id
Subsystems (2)
PATCH 1/1 rust: of: use safe zero initialization for struct of_device_id
Since bindings::of_device_id implements Zeroable, use pin_init::zeroed() instead of core::mem::zeroed().
Signed-off-by Thorsten Blum <[email protected]>
--- rust/kernel/of.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
rust/kernel/of.rs +1 -3
@@ -31,9 +31,7 @@ impl DeviceId {/// Create a new device id from an OF 'compatible' string. pub const fn new (compatible: &'staticCStr ) ->Self {let src = compatible.to_bytes_with_nul (); -// Replace with `bindings::of_device_id::default()` once stabilized for `const`. -// SAFETY: FFI type is valid to be zero-initialized. -let mut of: bindings::of_device_id =unsafe { core::mem::zeroed () }; +let mut of: bindings::of_device_id = pin_init::zeroed ();// TODO: Use `copy_from_slice` once stabilized for `const`. let mut i =0 ;
Quoted 5 lines · Thorsten Blum
Since
bindings::of_device_idimplements Zeroable, usepin_init::zeroed()instead ofcore::mem::zeroed().Signed-off-by Thorsten Blum <[email protected]>
This is:
https://lore.kernel.org/rust-for-linux/[email protected]/
Cc'ing Nils.
Cheers,
Miguel