* [PATCH v3 1/3] rust: block: simplify Result<()> in validate_block_size return
2024-11-18 14:36 [PATCH v3 0/3] rust: simplify Result<()> uses Manas via B4 Relay
@ 2024-11-18 14:36 ` Manas via B4 Relay
2024-11-18 16:05 ` Miguel Ojeda
2024-11-18 14:36 ` [PATCH v3 2/3] rust: uaccess: simplify Result<()> in bytes_add_one return Manas via B4 Relay
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Manas via B4 Relay @ 2024-11-18 14:36 UTC (permalink / raw)
To: FUJITA Tomonori, Trevor Gross, Andrew Lunn, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Hindborg, Boqun Feng, Miguel Ojeda,
Alex Gaynor, Gary Guo, Björn Roy Baron, Benno Lossin,
Alice Ryhl
Cc: Shuah Khan, Anup Sharma, netdev, rust-for-linux, linux-kernel,
linux-block, Manas
From: Manas <manas18244@iiitd.ac.in>
`Result` is used in place of `Result<()>` because the default type
parameters are unit `()` and `Error` types, which are automatically
inferred. Thus keep the usage 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/block/mq/gen_disk.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index 708125dce96a934f32caab44d5e6cff14c4321a9..798c4ae0bdedd58221b5851a630c0e1052e0face 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -45,7 +45,7 @@ pub fn rotational(mut self, rotational: bool) -> Self {
/// Validate block size by verifying that it is between 512 and `PAGE_SIZE`,
/// and that it is a power of two.
- fn validate_block_size(size: u32) -> Result<()> {
+ fn validate_block_size(size: u32) -> Result {
if !(512..=bindings::PAGE_SIZE as u32).contains(&size) || !size.is_power_of_two() {
Err(error::code::EINVAL)
} else {
--
2.47.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v3 1/3] rust: block: simplify Result<()> in validate_block_size return
2024-11-18 14:36 ` [PATCH v3 1/3] rust: block: simplify Result<()> in validate_block_size return Manas via B4 Relay
@ 2024-11-18 16:05 ` Miguel Ojeda
2024-11-18 16:10 ` Jens Axboe
2024-11-18 16:19 ` Manas
0 siblings, 2 replies; 10+ messages in thread
From: Miguel Ojeda @ 2024-11-18 16:05 UTC (permalink / raw)
To: manas18244
Cc: FUJITA Tomonori, Trevor Gross, Andrew Lunn, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Hindborg, Boqun Feng, Miguel Ojeda,
Alex Gaynor, Gary Guo, Björn Roy Baron, Benno Lossin,
Alice Ryhl, Shuah Khan, Anup Sharma, netdev, rust-for-linux,
linux-kernel, linux-block
On Mon, Nov 18, 2024 at 3:37 PM Manas via B4 Relay
<devnull+manas18244.iiitd.ac.in@kernel.org> wrote:
>
> From: Manas <manas18244@iiitd.ac.in>
>
> `Result` is used in place of `Result<()>` because the default type
> parameters are unit `()` and `Error` types, which are automatically
> inferred. Thus keep the usage 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>
If block wants to pick this one up independently:
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
(Note: normally you would carry the review/tested tags you were given
in a previous version, unless you made significant changes)
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/3] rust: block: simplify Result<()> in validate_block_size return
2024-11-18 16:05 ` Miguel Ojeda
@ 2024-11-18 16:10 ` Jens Axboe
2024-11-18 16:19 ` Manas
1 sibling, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2024-11-18 16:10 UTC (permalink / raw)
To: Miguel Ojeda, manas18244
Cc: FUJITA Tomonori, Trevor Gross, Andrew Lunn, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Hindborg, Boqun Feng, Miguel Ojeda,
Alex Gaynor, Gary Guo, Björn Roy Baron, Benno Lossin,
Alice Ryhl, Shuah Khan, Anup Sharma, netdev, rust-for-linux,
linux-kernel, linux-block
On 11/18/24 9:05 AM, Miguel Ojeda wrote:
> On Mon, Nov 18, 2024 at 3:37?PM Manas via B4 Relay
> <devnull+manas18244.iiitd.ac.in@kernel.org> wrote:
>>
>> From: Manas <manas18244@iiitd.ac.in>
>>
>> `Result` is used in place of `Result<()>` because the default type
>> parameters are unit `()` and `Error` types, which are automatically
>> inferred. Thus keep the usage 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>
>
> If block wants to pick this one up independently:
>
> Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
I can grab it.
--
Jens Axboe
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/3] rust: block: simplify Result<()> in validate_block_size return
2024-11-18 16:05 ` Miguel Ojeda
2024-11-18 16:10 ` Jens Axboe
@ 2024-11-18 16:19 ` Manas
1 sibling, 0 replies; 10+ messages in thread
From: Manas @ 2024-11-18 16:19 UTC (permalink / raw)
To: Miguel Ojeda
Cc: FUJITA Tomonori, Trevor Gross, Andrew Lunn, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Hindborg, Boqun Feng, Miguel Ojeda,
Alex Gaynor, Gary Guo, Björn Roy Baron, Benno Lossin,
Alice Ryhl, Shuah Khan, Anup Sharma, netdev, rust-for-linux,
linux-kernel, linux-block
On 18.11.2024 17:05, Miguel Ojeda wrote:
>On Mon, Nov 18, 2024 at 3:37 PM Manas via B4 Relay
><devnull+manas18244.iiitd.ac.in@kernel.org> wrote:
>>
>> From: Manas <manas18244@iiitd.ac.in>
>>
>> `Result` is used in place of `Result<()>` because the default type
>> parameters are unit `()` and `Error` types, which are automatically
>> inferred. Thus keep the usage 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>
>
>If block wants to pick this one up independently:
>
>Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
>
>(Note: normally you would carry the review/tested tags you were given
>in a previous version, unless you made significant changes)
Thanks. I will keep that in mind.
--
Manas
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 2/3] rust: uaccess: simplify Result<()> in bytes_add_one return
2024-11-18 14:36 [PATCH v3 0/3] rust: simplify Result<()> uses Manas via B4 Relay
2024-11-18 14:36 ` [PATCH v3 1/3] rust: block: simplify Result<()> in validate_block_size return Manas via B4 Relay
@ 2024-11-18 14:36 ` Manas via B4 Relay
2024-11-18 20:10 ` Boqun Feng
2024-11-18 14:37 ` [PATCH v3 3/3] rust: macros: simplify Result<()> in function returns Manas via B4 Relay
2024-11-18 16:11 ` (subset) [PATCH v3 0/3] rust: simplify Result<()> uses Jens Axboe
3 siblings, 1 reply; 10+ messages in thread
From: Manas via B4 Relay @ 2024-11-18 14:36 UTC (permalink / raw)
To: FUJITA Tomonori, Trevor Gross, Andrew Lunn, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Hindborg, Boqun Feng, Miguel Ojeda,
Alex Gaynor, Gary Guo, Björn Roy Baron, Benno Lossin,
Alice Ryhl
Cc: Shuah Khan, Anup Sharma, netdev, rust-for-linux, linux-kernel,
linux-block, Manas
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(-)
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
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v3 2/3] rust: uaccess: simplify Result<()> in bytes_add_one return
2024-11-18 14:36 ` [PATCH v3 2/3] rust: uaccess: simplify Result<()> in bytes_add_one return Manas via B4 Relay
@ 2024-11-18 20:10 ` Boqun Feng
0 siblings, 0 replies; 10+ messages in thread
From: Boqun Feng @ 2024-11-18 20:10 UTC (permalink / raw)
To: manas18244
Cc: FUJITA Tomonori, Trevor Gross, Andrew Lunn, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Hindborg, Miguel Ojeda, Alex Gaynor,
Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
Shuah Khan, Anup Sharma, netdev, rust-for-linux, linux-kernel,
linux-block
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
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 3/3] rust: macros: simplify Result<()> in function returns
2024-11-18 14:36 [PATCH v3 0/3] rust: simplify Result<()> uses Manas via B4 Relay
2024-11-18 14:36 ` [PATCH v3 1/3] rust: block: simplify Result<()> in validate_block_size return Manas via B4 Relay
2024-11-18 14:36 ` [PATCH v3 2/3] rust: uaccess: simplify Result<()> in bytes_add_one return Manas via B4 Relay
@ 2024-11-18 14:37 ` Manas via B4 Relay
2024-11-18 20:28 ` Boqun Feng
2024-11-18 16:11 ` (subset) [PATCH v3 0/3] rust: simplify Result<()> uses Jens Axboe
3 siblings, 1 reply; 10+ messages in thread
From: Manas via B4 Relay @ 2024-11-18 14:37 UTC (permalink / raw)
To: FUJITA Tomonori, Trevor Gross, Andrew Lunn, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Hindborg, Boqun Feng, Miguel Ojeda,
Alex Gaynor, Gary Guo, Björn Roy Baron, Benno Lossin,
Alice Ryhl
Cc: Shuah Khan, Anup Sharma, netdev, rust-for-linux, linux-kernel,
linux-block, Manas
From: Manas <manas18244@iiitd.ac.in>
Functions foo and bar in doctests return `Result<()>` type. This type
can be simply written as `Result` as default type parameters are unit
`()` and `Error` types. Thus keep the usage of `Result` consistent.
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/macros/lib.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/rust/macros/lib.rs b/rust/macros/lib.rs
index 4ab94e44adfe3206faad159e81417ea41a35815b..463920353ca9c408f5d69e2626c13a173bae98d7 100644
--- a/rust/macros/lib.rs
+++ b/rust/macros/lib.rs
@@ -144,11 +144,11 @@ pub fn module(ts: TokenStream) -> TokenStream {
/// // Declares a `#[vtable]` trait
/// #[vtable]
/// pub trait Operations: Send + Sync + Sized {
-/// fn foo(&self) -> Result<()> {
+/// fn foo(&self) -> Result {
/// kernel::build_error(VTABLE_DEFAULT_ERROR)
/// }
///
-/// fn bar(&self) -> Result<()> {
+/// fn bar(&self) -> Result {
/// kernel::build_error(VTABLE_DEFAULT_ERROR)
/// }
/// }
@@ -158,7 +158,7 @@ pub fn module(ts: TokenStream) -> TokenStream {
/// // Implements the `#[vtable]` trait
/// #[vtable]
/// impl Operations for Foo {
-/// fn foo(&self) -> Result<()> {
+/// fn foo(&self) -> Result {
/// # Err(EINVAL)
/// // ...
/// }
--
2.47.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v3 3/3] rust: macros: simplify Result<()> in function returns
2024-11-18 14:37 ` [PATCH v3 3/3] rust: macros: simplify Result<()> in function returns Manas via B4 Relay
@ 2024-11-18 20:28 ` Boqun Feng
0 siblings, 0 replies; 10+ messages in thread
From: Boqun Feng @ 2024-11-18 20:28 UTC (permalink / raw)
To: manas18244
Cc: FUJITA Tomonori, Trevor Gross, Andrew Lunn, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Hindborg, Miguel Ojeda, Alex Gaynor,
Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
Shuah Khan, Anup Sharma, netdev, rust-for-linux, linux-kernel,
linux-block
On Mon, Nov 18, 2024 at 08:07:00PM +0530, Manas via B4 Relay wrote:
> From: Manas <manas18244@iiitd.ac.in>
>
> Functions foo and bar in doctests return `Result<()>` type. This type
Same nits here.
> can be simply written as `Result` as default type parameters are unit
> `()` and `Error` types. Thus keep the usage of `Result` consistent.
>
> 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/macros/lib.rs | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/rust/macros/lib.rs b/rust/macros/lib.rs
> index 4ab94e44adfe3206faad159e81417ea41a35815b..463920353ca9c408f5d69e2626c13a173bae98d7 100644
> --- a/rust/macros/lib.rs
> +++ b/rust/macros/lib.rs
> @@ -144,11 +144,11 @@ pub fn module(ts: TokenStream) -> TokenStream {
> /// // Declares a `#[vtable]` trait
> /// #[vtable]
> /// pub trait Operations: Send + Sync + Sized {
> -/// fn foo(&self) -> Result<()> {
> +/// fn foo(&self) -> Result {
> /// kernel::build_error(VTABLE_DEFAULT_ERROR)
> /// }
> ///
> -/// fn bar(&self) -> Result<()> {
> +/// fn bar(&self) -> Result {
> /// kernel::build_error(VTABLE_DEFAULT_ERROR)
> /// }
> /// }
> @@ -158,7 +158,7 @@ pub fn module(ts: TokenStream) -> TokenStream {
> /// // Implements the `#[vtable]` trait
> /// #[vtable]
> /// impl Operations for Foo {
> -/// fn foo(&self) -> Result<()> {
> +/// fn foo(&self) -> Result {
> /// # Err(EINVAL)
> /// // ...
> /// }
>
> --
> 2.47.0
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (subset) [PATCH v3 0/3] rust: simplify Result<()> uses
2024-11-18 14:36 [PATCH v3 0/3] rust: simplify Result<()> uses Manas via B4 Relay
` (2 preceding siblings ...)
2024-11-18 14:37 ` [PATCH v3 3/3] rust: macros: simplify Result<()> in function returns Manas via B4 Relay
@ 2024-11-18 16:11 ` Jens Axboe
3 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2024-11-18 16:11 UTC (permalink / raw)
To: FUJITA Tomonori, Trevor Gross, Andrew Lunn, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Hindborg, Boqun Feng, Miguel Ojeda,
Alex Gaynor, Gary Guo, Björn Roy Baron, Benno Lossin,
Alice Ryhl, Manas
Cc: Shuah Khan, Anup Sharma, netdev, rust-for-linux, linux-kernel,
linux-block
On Mon, 18 Nov 2024 20:06:57 +0530, Manas wrote:
>
Applied, thanks!
[1/3] rust: block: simplify Result<()> in validate_block_size return
commit: a3f143c461444c0b56360bbf468615fa814a8372
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 10+ messages in thread