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: <20221114143226.78512a35@GaryWorkstation>
Date:   Mon, 14 Nov 2022 14:32:26 +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
Subject: Re: [PATCH v1 11/28] rust: prelude: add `error::code::*` constant
 items

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

> From: Wedson Almeida Filho <wedsonaf@...il.com>
> 
> It is convenient to have all the `Error` constant items (such as
> `EINVAL`) available as-is everywhere (i.e. for code using the kernel
> prelude such as kernel modules).
> 
> Therefore, add all of them to the prelude.

Personally, I would prefer to have all error codes as associated
constants of the `kernel::Error` type so the code below would use
`Err(Error::EINVAL)` (more "Rusty" way of writing things). But IIRC
that we settled on the current approach because it's more similar to
existing C code.

> 
> For instance, this allows to write `Err(EINVAL)` to create
> a kernel `Result`:
> 
>     fn f() -> Result<...> {
>         ...
>         Err(EINVAL)
>     }
> 
> Signed-off-by: Wedson Almeida Filho <wedsonaf@...il.com>
> [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/prelude.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
> index 7c4c35bf3c66..1e08b08e9420 100644
> --- a/rust/kernel/prelude.rs
> +++ b/rust/kernel/prelude.rs
> @@ -19,6 +19,6 @@ pub use macros::{module, vtable};
>  
>  pub use super::{pr_alert, pr_crit, pr_debug, pr_emerg, pr_err, pr_info, pr_notice, pr_warn};
>  
> -pub use super::error::{Error, Result};
> +pub use super::error::{code::*, Error, Result};
>  
>  pub use super::ThisModule;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ