summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorAlice Ryhl <aliceryhl@google.com>2026-10-13 12:37:54 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-10-13 15:59:46 +0200
commitaeef0f8a3af2e3003c1c4019cf8fcb5f4b14f17f (patch)
tree3281d4a0a9201f8c27eb09d83268bd32e1c99c25 /rust
parentba9d2c7ea7f8fd02726241e9b93a2a31d30c77ea (diff)
rust: error: implement ZeroableOption for Error
Rust Binder wants to store an Option<Error> in TransactionInfo, which derives Zeroable. Implement ZeroableOption for Error so that Option<Error> implements Zeroable. Acked-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20261013-binder-consolidate-txn-prints-v2-1-cf78927dab23@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'rust')
-rw-r--r--rust/kernel/error.rs5
1 files changed, 5 insertions, 0 deletions
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 @@ pub mod code {
///
/// 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.
///