mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
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>
This commit is contained in:
parent
ba9d2c7ea7
commit
aeef0f8a3a
|
|
@ -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.
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user