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]
Date:   Fri, 2 Dec 2022 18:32:47 +0000
From:   Wei Liu <wei.liu@...nel.org>
To:     ojeda@...nel.org
Cc:     Wedson Almeida Filho <wedsonaf@...il.com>,
        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>,
        rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
        patches@...ts.linux.dev, Wei Liu <wei.liu@...nel.org>
Subject: Re: [PATCH v2 26/28] rust: build_assert: add `build_{error,assert}!`
 macros

On Fri, Dec 02, 2022 at 05:14:57PM +0100, ojeda@...nel.org wrote:
> From: Gary Guo <gary@...yguo.net>
> 
> Add the `build_error!` and `build_assert!` macros which leverage
> the previously introduced `build_error` crate. Do so in a new
> module, called `build_assert`.
> 
> The former fails the build if the code path calling it can possibly
> be executed. The latter asserts that a boolean expression is `true`
> at compile time.
> 
> In particular, `build_assert!` can be used in some contexts where
> `static_assert!` cannot:
> 
>     fn f1<const N: usize>() {
>         static_assert!(N > 1);` // Error.
>         build_assert!(N > 1);   // Build-time check.
>         assert!(N > 1);         // Run-time check.
>     }
> 
>     #[inline]
>     fn f2(n: usize) {
>         static_assert!(n > 1);  // Error.
>         build_assert!(n > 1);   // Build-time check.
>         assert!(n > 1);         // Run-time check.
>     }
> 
> Signed-off-by: Gary Guo <gary@...yguo.net>
> [Reworded, adapted for upstream and applied latest changes]
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>

Reviewed-by: Wei Liu <wei.liu@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ