[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DAOMZ3J7CQXP.YBHQOBY1H020@nvidia.com>
Date: Tue, 17 Jun 2025 16:39:48 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Christian" <christiansantoslima21@...il.com>
Cc: "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
<alex.gaynor@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
<gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <benno.lossin@...ton.me>,
"Andreas Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl"
<aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>, "Danilo
Krummrich" <dakr@...nel.org>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <~lkcamp/patches@...ts.sr.ht>,
<richard120310@...il.com>
Subject: Re: [PATCH v7] rust: transmute: Add methods for FromBytes trait
On Tue Jun 17, 2025 at 10:55 AM JST, Christian wrote:
>> Or if that is still unclear, consider the following doctest in `dma.rs`
>> that fails with this patch:
>>
>> struct MyStruct { field: u32, }
>>
>> // SAFETY: All bit patterns are acceptable values for `MyStruct`.
>> unsafe impl kernel::transmute::FromBytes for MyStruct{};
>> // SAFETY: Instances of `MyStruct` have no uninitialized portions.
>> unsafe impl kernel::transmute::AsBytes for MyStruct{};
>>
>> It fails because the `FromBytes` implementation for `MyStruct` does not provide
>> a definition for `from_bytes` and `from_mut_bytes`. Fixing this is just a
>> matter of changing the `impl FromBytes` into `impl FromBytesSized`. But without
>> the latter, how do you make this example build without providing a definition
>> of `from_bytes` and `from_bytes_mut`?
>
> Well, that's fine with me. I'll send the next patch with this fix. Can
> I put it as `suggested-by`?
If you think it is appropriate, sure!
Powered by blists - more mailing lists