[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DA0X867CPP0V.22GHRMZOW4DHB@buenzli.dev>
Date: Tue, 20 May 2025 12:37:51 +0200
From: "Remo Senekowitsch" <remo@...nzli.dev>
To: "Benno Lossin" <lossin@...nel.org>, "Danilo Krummrich" <dakr@...nel.org>
Cc: "Rob Herring" <robh@...nel.org>, "Saravana Kannan"
<saravanak@...gle.com>, "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>, "Greg
Kroah-Hartman" <gregkh@...uxfoundation.org>, "Rafael J. Wysocki"
<rafael@...nel.org>, "Dirk Behme" <dirk.behme@...bosch.com>,
<linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
<rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH v4 6/9] rust: device: Add bindings for reading device
properties
On Tue May 20, 2025 at 9:40 AM CEST, Benno Lossin wrote:
> On Tue May 20, 2025 at 9:21 AM CEST, Benno Lossin wrote:
>> On Mon May 19, 2025 at 9:51 PM CEST, Remo Senekowitsch wrote:
>>> On Mon May 19, 2025 at 6:55 PM CEST, Danilo Krummrich wrote:
>>>> Also, the PropertyInt trait itself has to be unsafe, given that it contains
>>>> unsafe functions.
>>>
>>> I don't think a trait necessarily has to be marked unsafe just because
>>> it has unsafe methods. Marking a trait as unsafe means that implementors
>>> of the trait must uphold some invariants. This is not the case here
>>> IIUC. Here's a good explanation of my understanding: [1]
>>
>> Yes this is correct, I don't think that the trait itself should be
>> unsafe.
>
> Ahh, I understood now why Danilo suggested this: if the trait should
> guarantee that `fwnode_property_read_*_array` is called, then the trait
> would have to be `unsafe`.
Oh yeah, that's true. Callers rely on the fact that if the function
returns zero, the requested number of elements have been initialized.
That's definitely a safety invariant implementors must uphold...
So I guess marking the trait unsafe is correct.
> But I don't think that's necessary, we don't have any other unsafe code
> that needs to rely on that.
Powered by blists - more mailing lists