Re: [PATCH v2 09/12] rust: init: implement Zeroable for Opaque<T>

From: Alice Ryhl
Date: Thu Jul 20 2023 - 09:35:26 EST


Benno Lossin <benno.lossin@xxxxxxxxx> writes:
> Since `Opaque<T>` contains a `MaybeUninit<T>`, all bytes zero is a valid
> bit pattern for that type.
>
> Signed-off-by: Benno Lossin <benno.lossin@xxxxxxxxx>
> ---
> ///
> /// This is meant to be used with FFI objects that are never interpreted by Rust code.
> #[repr(transparent)]
> +#[derive(Zeroable)]
> pub struct Opaque<T> {
> value: UnsafeCell<MaybeUninit<T>>,
> _pin: PhantomPinned,
> }

Does this actually work? I don't think we implement Zeroable for
UnsafeCell.

I suggest you instead add Opaque to the `impl_zeroable!` macro in
`rust/kernel/init.rs`.

Alice