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: <CANiq72=Ga7usdPgACL6znOJ_=SQXy8ESbft4x0XewGL-Xf-M-g@mail.gmail.com>
Date: Mon, 19 Aug 2024 02:22:07 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: Benno Lossin <benno.lossin@...ton.me>, FUJITA Tomonori <fujita.tomonori@...il.com>, 
	netdev@...r.kernel.org, rust-for-linux@...r.kernel.org, tmgross@...ch.edu, 
	aliceryhl@...gle.com
Subject: Re: [PATCH net-next v4 6/6] net: phy: add Applied Micro QT2025 PHY driver

On Sun, Aug 18, 2024 at 7:39 PM Andrew Lunn <andrew@...n.ch> wrote:
>
> O.K, so the compiler tells you, which is great. The C compiler would
> not, which is why i tend to think of these things.

For the unused result, there is `__must_check` of course, though it
does not seem to apply to types in GCC like it is applied to `Result`
in Rust (Clang is OK with it).

C23 brings `[[nodiscard]]`, which can be. GCC >= 11 and Clang >= 17
support it, so one can do things like:

    typedef struct [[nodiscard]] Result {
        ...
    } Result;

    Result g(void);

    Result f(void)
    {
        g(); // will warn.
        return g();
    }

https://godbolt.org/z/PqK36rjWY

And have a `Result`-like type (or, rather, like our alias in the
kernel, given the generics).

So if one is happy using new types, that is great.

It would be nice to be able to do something like:

    #define Result __must_check int

...but that faces trouble when using it for e.g. local variables.

Cheers,
Miguel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ