rust: auxiliary: use `pin_init::zeroed()` for ACPI device ID
Subsystems (2)
PATCH 1/1 rust: auxiliary: use `pin_init::zeroed()` for ACPI device ID
Replace the previous unsafe { core::mem::zeroed() } initialization for bindings::acpi_device_id with pin_init::zeroed(). This removes the explicit unsafe block and uses the safer pinned zero-initialization helper.
Signed-off-by Atharv Dubey <[email protected]>
--- rust/kernel/auxiliary.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
rust/kernel/auxiliary.rs +1 -5
@@ -108,11 +108,7 @@ pub const fn new(modname: &'static CStr, name: &'static CStr) -> Self {let name = name.to_bytes_with_nul ();let modname = modname.to_bytes_with_nul (); -// TODO: Replace with `bindings::auxiliary_device_id::default()` once stabilized for -// `const`. -// -// SAFETY: FFI type is valid to be zero-initialized. -let mut id: bindings::auxiliary_device_id =unsafe { core::mem::zeroed () }; +let mut id: bindings::auxiliary_device_id = pin_init::zeroed ();let mut i =0 ;while i < modname.len () {
Signature · 1 line
2.43.0
Alexandre Courbot
reviewerQuoted 15 lines · Atharv Dubey
Replace the previous
unsafe { core::mem::zeroed() }initialization forbindings::acpi_device_idwithpin_init::zeroed(). This removes the explicit unsafe block and uses the safer pinned zero-initialization helper.Signed-off-by Atharv Dubey <[email protected]>--- rust/kernel/auxiliary.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)rust/kernel/auxiliary.rs +0
-0
rust/kernel/auxiliary.rs pub const fn new(modname: &'static CStr, name: &'static CStr) -> Self { · line 112
Quoted 5 lines
rust/kernel/auxiliary.rs +0
-2@@ -108,11 +108,7 @@ pub const fn new(modname: &'static CStr, name: &'static CStr) -> Self {let name = name.to_bytes_with_nul ();let modname = modname.to_bytes_with_nul (); -// TODO: Replace with `bindings::auxiliary_device_id::default()` once stabilized for -// `const`.
Same as the other patch, I don't think this change obsoletes this TODO.