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: <7f835fe8-e641-4b84-a080-13f4841fb64a@proton.me>
Date: Sat, 17 Aug 2024 21:34:13 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Andrew Lunn <andrew@...n.ch>, FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: netdev@...r.kernel.org, rust-for-linux@...r.kernel.org, tmgross@...ch.edu, miguel.ojeda.sandonis@...il.com, aliceryhl@...gle.com
Subject: Re: [PATCH net-next v4 6/6] net: phy: add Applied Micro QT2025 PHY driver

On 17.08.24 20:51, Andrew Lunn wrote:
>> +    fn read_status(dev: &mut phy::Device) -> Result<u16> {
>> +        dev.genphy_read_status::<C45>()
>> +    }
> 
> Probably a dumb Rust question. Shouldn't this have a ? at the end? It
> can return a negative error code.

`read_status` returns a `Result<u16>` and `Device::genphy_read_status`
also returns a `Result<u16>`. In the function body we just delegate to
the latter, so no `?` is needed. We just return the entire result.

Here is the equivalent pseudo-C code:

    int genphy_read_status(struct phy_device *dev);
    
    int read_status(struct phy_device *dev)
    {
        return genphy_read_status(dev);
    }

There you also don't need an if for the negative error code, since it's
just propagated.

Hope this helps!

---
Cheers,
Benno


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ