diff mbox series

[v3,2/3] rust: uaccess: simplify Result<()> in bytes_add_one return

Message ID 20241118-simplify-result-v3-2-6b1566a77eab@iiitd.ac.in (mailing list archive)
State Not Applicable
Headers show
Series rust: simplify Result<()> uses | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Manas via B4 Relay Nov. 18, 2024, 2:36 p.m. UTC
From: Manas <manas18244@iiitd.ac.in>

bytes_add_one returns `Result<()>`, a result over unit type. This can be
simplified to `Result` as default type parameters are unit `()` and
`Error` types. Thus keep the usage of `Result` consistent throughout
codebase.

Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/Rust-for-Linux/linux/issues/1128
Signed-off-by: Manas <manas18244@iiitd.ac.in>
---
 rust/kernel/uaccess.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Boqun Feng Nov. 18, 2024, 8:10 p.m. UTC | #1
Hi Manas,

On Mon, Nov 18, 2024 at 08:06:59PM +0530, Manas via B4 Relay wrote:
> From: Manas <manas18244@iiitd.ac.in>
> 
> bytes_add_one returns `Result<()>`, a result over unit type. This can be

This is a bit nitpicking from my side, but usually when referring to the
name of a function, I would suggest adding the parentheses, i.e.
"bytes_add_one()". In this way, it's more clear that it's a function
(instead of a variable or something else).

> simplified to `Result` as default type parameters are unit `()` and
> `Error` types. Thus keep the usage of `Result` consistent throughout
> codebase.
> 
> Suggested-by: Miguel Ojeda <ojeda@kernel.org>
> Link: https://github.com/Rust-for-Linux/linux/issues/1128
> Signed-off-by: Manas <manas18244@iiitd.ac.in>

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

> ---
>  rust/kernel/uaccess.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/rust/kernel/uaccess.rs b/rust/kernel/uaccess.rs
> index 05b0b8d13b10da731af62be03e1c2c13ced3f706..7c21304344ccd943816e38119a5be2ccf8d8e154 100644
> --- a/rust/kernel/uaccess.rs
> +++ b/rust/kernel/uaccess.rs
> @@ -49,7 +49,7 @@
>  /// use kernel::error::Result;
>  /// use kernel::uaccess::{UserPtr, UserSlice};
>  ///
> -/// fn bytes_add_one(uptr: UserPtr, len: usize) -> Result<()> {
> +/// fn bytes_add_one(uptr: UserPtr, len: usize) -> Result {
>  ///     let (read, mut write) = UserSlice::new(uptr, len).reader_writer();
>  ///
>  ///     let mut buf = KVec::new();
> 
> -- 
> 2.47.0
> 
>
diff mbox series

Patch

diff --git a/rust/kernel/uaccess.rs b/rust/kernel/uaccess.rs
index 05b0b8d13b10da731af62be03e1c2c13ced3f706..7c21304344ccd943816e38119a5be2ccf8d8e154 100644
--- a/rust/kernel/uaccess.rs
+++ b/rust/kernel/uaccess.rs
@@ -49,7 +49,7 @@ 
 /// use kernel::error::Result;
 /// use kernel::uaccess::{UserPtr, UserSlice};
 ///
-/// fn bytes_add_one(uptr: UserPtr, len: usize) -> Result<()> {
+/// fn bytes_add_one(uptr: UserPtr, len: usize) -> Result {
 ///     let (read, mut write) = UserSlice::new(uptr, len).reader_writer();
 ///
 ///     let mut buf = KVec::new();