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: <20221114142853.5200d36d@GaryWorkstation>
Date:   Mon, 14 Nov 2022 14:28:53 +0000
From:   Gary Guo <gary@...yguo.net>
To:     Miguel Ojeda <ojeda@...nel.org>
Cc:     Wedson Almeida Filho <wedsonaf@...il.com>,
        Alex Gaynor <alex.gaynor@...il.com>,
        Boqun Feng <boqun.feng@...il.com>,
        Björn Roy Baron <bjorn3_gh@...tonmail.com>,
        rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
        patches@...ts.linux.dev, Finn Behrens <me@...enk.dev>
Subject: Re: [PATCH v1 08/28] rust: error: declare errors using macro

On Thu, 10 Nov 2022 17:41:20 +0100
Miguel Ojeda <ojeda@...nel.org> wrote:

> From: Finn Behrens <me@...enk.dev>
> 
> Add a macro to declare errors, which simplifies the work needed to
> add each one, avoids repetition of the code and makes it easier to
> change the way they are declared.
> 
> Signed-off-by: Finn Behrens <me@...enk.dev>
> [Reworded, adapted for upstream and applied latest changes]
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>

Reviewed-by: Gary Guo <gary@...yguo.net>

> ---
>  rust/kernel/error.rs | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
> index 466b2a8fe569..b843f3445483 100644
> --- a/rust/kernel/error.rs
> +++ b/rust/kernel/error.rs
> @@ -8,8 +8,16 @@ use alloc::collections::TryReserveError;
>  
>  /// Contains the C-compatible error codes.
>  pub mod code {
> -    /// Out of memory.
> -    pub const ENOMEM: super::Error = super::Error(-(crate::bindings::ENOMEM as i32));
> +    macro_rules! declare_err {
> +        ($err:tt $(,)? $($doc:expr),+) => {
> +            $(
> +            #[doc = $doc]
> +            )*
> +            pub const $err: super::Error = super::Error(-(crate::bindings::$err as i32));
> +        };
> +    }
> +
> +    declare_err!(ENOMEM, "Out of memory.");
>  }
>  
>  /// Generic integer kernel error.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ