Commit 1cab0874 authored by Atharv Dubey's avatar Atharv Dubey Committed by Danilo Krummrich
Browse files

rust: auxiliary: use `pin_init::zeroed()` for device ID



Replace the previous `unsafe { core::mem::zeroed() }` initialization
for `bindings::auxillary_device_id` with `pin_init::zeroed()`. This removes
the explicit unsafe block and uses the safer pinned zero-initialization
helper.

Suggested-by: default avatarBenno Lossin <lossin@kernel.org>
Signed-off-by: default avatarAtharv Dubey <atharvd440@gmail.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1189
Link: https://patch.msgid.link/20251129124706.26263-1-atharvd440@gmail.com


Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent ae3bf761
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -121,12 +121,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() {
            id.name[i] = modname[i];