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: <D8H11HOL93UD.31F853PYJA9U2@proton.me>
Date: Sat, 15 Mar 2025 17:48:03 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Alexandre Courbot <acourbot@...dia.com>, 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 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.

---
Cheers,
Benno


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ