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] [day] [month] [year] [list]
Message-Id: <DCHBJ8PJ79FK.B4J91QH6FC7B@umich.edu>
Date: Mon, 01 Sep 2025 03:25:10 -0500
From: "Trevor Gross" <tmgross@...ch.edu>
To: Onur Özkan <work@...rozkan.dev>,
 <rust-for-linux@...r.kernel.org>
Cc: <fujita.tomonori@...il.com>, <tmgross@...ch.edu>, <ojeda@...nel.org>,
 <alex.gaynor@...il.com>, <boqun.feng@...il.com>, <gary@...yguo.net>,
 <bjorn3_gh@...tonmail.com>, <lossin@...nel.org>, <a.hindborg@...nel.org>,
 <aliceryhl@...gle.com>, <dakr@...nel.org>, <netdev@...r.kernel.org>,
 <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] rust: phy: use to_result for error handling

On Thu Aug 21, 2025 at 4:12 AM CDT, Onur Özkan wrote:
> Simplifies error handling by replacing the manual check
> of the return value with the `to_result` helper.
>
> Signed-off-by: Onur Özkan <work@...rozkan.dev>

Reviewed-by: Trevor Gross <tmgross@...ch.edu>

> ---
>  rust/kernel/net/phy.rs | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
> index 7de5cc7a0eee..c895582cd624 100644
> --- a/rust/kernel/net/phy.rs
> +++ b/rust/kernel/net/phy.rs
> @@ -196,11 +196,8 @@ pub fn read_paged(&mut self, page: u16, regnum: u16) -> Result<u16> {
>          // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`.
>          // So it's just an FFI call.
>          let ret = unsafe { bindings::phy_read_paged(phydev, page.into(), regnum.into()) };
> -        if ret < 0 {
> -            Err(Error::from_errno(ret))
> -        } else {
> -            Ok(ret as u16)
> -        }
> +
> +        to_result(ret).map(|()| ret as u16)
>      }
>
>      /// Resolves the advertisements into PHY settings.
> --
> 2.50.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ