From aeef0f8a3af2e3003c1c4019cf8fcb5f4b14f17f Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 13 Oct 2026 12:37:54 +0000 Subject: [PATCH] rust: error: implement ZeroableOption for Error Rust Binder wants to store an Option in TransactionInfo, which derives Zeroable. Implement ZeroableOption for Error so that Option implements Zeroable. Acked-by: Miguel Ojeda Signed-off-by: Alice Ryhl Link: https://patch.msgid.link/20261013-binder-consolidate-txn-prints-v2-1-cf78927dab23@google.com Signed-off-by: Greg Kroah-Hartman --- rust/kernel/error.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index e52793f77196..9003a1b86da8 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -199,8 +199,13 @@ macro_rules! declare_err { /// /// The value is a valid `errno` (i.e. `>= -MAX_ERRNO && < 0`). #[derive(Clone, Copy, PartialEq, Eq)] +#[repr(transparent)] pub struct Error(NonZeroI32); +// SAFETY: `Error` is `repr(transparent)` over `NonZeroI32`, which is part of the option layout +// optimization guarantee, so all zeroes is a valid representation for `None`. +unsafe impl pin_init::ZeroableOption for Error {} + impl Error { /// Creates an [`Error`] from a kernel error code. ///