lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D8HOP09FU367.2MVDRQ5G0OPV@nvidia.com>
Date: Sun, 16 Mar 2025 21:20:03 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Benno Lossin" <benno.lossin@...ton.me>, "Danilo Krummrich"
 <dakr@...nel.org>
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>, "Andreas Hindborg" <a.hindborg@...nel.org>,
 "Alice Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>,
 <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] rust/revocable: add try_with() convenience method

On Sun Mar 16, 2025 at 2:48 AM JST, Benno Lossin wrote:
> On Sat Mar 15, 2025 at 3:26 PM CET, Alexandre Courbot wrote:
>> On Sat Mar 15, 2025 at 11:17 PM JST, Danilo Krummrich wrote:
>>> On Sat, Mar 15, 2025 at 11:07:44PM +0900, Alexandre Courbot wrote:
>>>> I suppose drivers could add their own macros to do that automatically
>>>> and reduce code verbosity, at the cost of less cohesion across drivers.
>>>> Guess I'll go with that if I cannot come with anything better.
>>>
>>> Maybe we could do something more specific but yet generic on top (for the
>>> use-case above), but we still can't assume the exact error code a driver wants
>>> to derive from failing try_access(). So, maybe a driver specific wrapper is
>>> indeed what you want on top of what this patch provides.
>>
>> So be it! It's not that bad and more flexible in the end.
>
> You could have the following signature:
>
>     fn try_access_with<R>(&self, on_vacant: Error, f: impl FnOnce(&T) -> Result<R>) -> Result<R>;
>
> That will use the `on_vacant` error instead of hard coding ENXIO. But
> maybe it's better to just have such a wrapper in drivers that actually
> need it (ie even with the concrete error specified and not a parameter).
> You'll know better through actually trying to write a driver.

Yeah, having the extra on_vacant parameter would require callers to
specify the error they need every time, where it is supposed to be
a per-driver constant. So I guess a per-driver macro or wrapper would be
more ergonomic in the end.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ