* [PATCH v2 1/3] rust: block: simplify Result<()> in validate_block_size return
2024-11-18 13:12 [PATCH v2 0/3] rust: simplify Result<()> uses Manas via B4 Relay
@ 2024-11-18 13:12 ` Manas via B4 Relay
2024-11-18 14:08 ` Miguel Ojeda
2024-11-18 13:12 ` [PATCH v2 2/3] rust: uaccess: simplify Result<()> in bytes_add_one return Manas via B4 Relay
2024-11-18 13:12 ` [PATCH v2 3/3] rust: macros: simplify Result<()> in function returns Manas via B4 Relay
2 siblings, 1 reply; 8+ messages in thread
From: Manas via B4 Relay @ 2024-11-18 13:12 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. This patch keeps the usage consistent throughout codebase.
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] 8+ messages in thread* Re: [PATCH v2 1/3] rust: block: simplify Result<()> in validate_block_size return
2024-11-18 13:12 ` [PATCH v2 1/3] rust: block: simplify Result<()> in validate_block_size return Manas via B4 Relay
@ 2024-11-18 14:08 ` Miguel Ojeda
2024-11-18 14:22 ` Manas
0 siblings, 1 reply; 8+ messages in thread
From: Miguel Ojeda @ 2024-11-18 14:08 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 2:12 PM Manas via B4 Relay
<devnull+manas18244.iiitd.ac.in@kernel.org> wrote:
>
> `Result` is used in place of `Result<()>` because the default type
> parameters are unit `()` and `Error` types, which are automatically
> inferred. This patch keeps the usage consistent throughout codebase.
The tags you had in v1 (Link, Suggested-by) seem to have been removed.
Nit: the usual style is to use the imperative tense when describing
the change that the patch performs, although that is not a hard rule,
e.g. you could say "Thus keep the usage consistent throughout the
codebase." in the last sentence.
> Signed-off-by: Manas <manas18244@iiitd.ac.in>
Same comment as in v1 about the "known identity".
(The notes above apply to the other patches too).
The change itself looks fine to me of course, so with those fixed,
please feel free to add in your next version:
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] rust: block: simplify Result<()> in validate_block_size return
2024-11-18 14:08 ` Miguel Ojeda
@ 2024-11-18 14:22 ` Manas
2024-11-18 16:29 ` Miguel Ojeda
0 siblings, 1 reply; 8+ messages in thread
From: Manas @ 2024-11-18 14:22 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 15:08, Miguel Ojeda wrote:
>On Mon, Nov 18, 2024 at 2:12 PM Manas via B4 Relay
><devnull+manas18244.iiitd.ac.in@kernel.org> wrote:
>>
>> `Result` is used in place of `Result<()>` because the default type
>> parameters are unit `()` and `Error` types, which are automatically
>> inferred. This patch keeps the usage consistent throughout codebase.
>
>The tags you had in v1 (Link, Suggested-by) seem to have been removed.
>
>Nit: the usual style is to use the imperative tense when describing
>the change that the patch performs, although that is not a hard rule,
>e.g. you could say "Thus keep the usage consistent throughout the
>codebase." in the last sentence.
>
Will do.
>> Signed-off-by: Manas <manas18244@iiitd.ac.in>
>
>Same comment as in v1 about the "known identity".
>
Actually, "Manas" is my __official__ name.
>(The notes above apply to the other patches too).
>
>The change itself looks fine to me of course, so with those fixed,
>please feel free to add in your next version:
>
>Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
>
Adding tags in v3.
--
Manas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] rust: block: simplify Result<()> in validate_block_size return
2024-11-18 14:22 ` Manas
@ 2024-11-18 16:29 ` Miguel Ojeda
2024-11-18 16:51 ` Manas
0 siblings, 1 reply; 8+ messages in thread
From: Miguel Ojeda @ 2024-11-18 16:29 UTC (permalink / raw)
To: Manas
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:22 PM Manas <manas18244@iiitd.ac.in> wrote:
>
> Actually, "Manas" is my __official__ name.
I didn't say otherwise (nor I meant to offend, I apologize if that is the case).
I worded my comment that way because a "known identity" does not need
to be an official/legal/birth name, e.g. some contributors prefer to
use a nickname, and that is perfectly fine too.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] rust: block: simplify Result<()> in validate_block_size return
2024-11-18 16:29 ` Miguel Ojeda
@ 2024-11-18 16:51 ` Manas
0 siblings, 0 replies; 8+ messages in thread
From: Manas @ 2024-11-18 16:51 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:29, Miguel Ojeda wrote:
>On Mon, Nov 18, 2024 at 3:22 PM Manas <manas18244@iiitd.ac.in> wrote:
>>
>> Actually, "Manas" is my __official__ name.
>
>I didn't say otherwise (nor I meant to offend, I apologize if that is the case).
>
I didn't take an offense at all. :) No worries.
>I worded my comment that way because a "known identity" does not need
>to be an official/legal/birth name, e.g. some contributors prefer to
>use a nickname, and that is perfectly fine too.
>
I am in private talks with Andrew about this. I will CC you.
--
Manas
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] rust: uaccess: simplify Result<()> in bytes_add_one return
2024-11-18 13:12 [PATCH v2 0/3] rust: simplify Result<()> uses Manas via B4 Relay
2024-11-18 13:12 ` [PATCH v2 1/3] rust: block: simplify Result<()> in validate_block_size return Manas via B4 Relay
@ 2024-11-18 13:12 ` Manas via B4 Relay
2024-11-18 13:12 ` [PATCH v2 3/3] rust: macros: simplify Result<()> in function returns Manas via B4 Relay
2 siblings, 0 replies; 8+ messages in thread
From: Manas via B4 Relay @ 2024-11-18 13:12 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. This also keeps the usage of `Result` consistent
throughout codebase.
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] 8+ messages in thread* [PATCH v2 3/3] rust: macros: simplify Result<()> in function returns
2024-11-18 13:12 [PATCH v2 0/3] rust: simplify Result<()> uses Manas via B4 Relay
2024-11-18 13:12 ` [PATCH v2 1/3] rust: block: simplify Result<()> in validate_block_size return Manas via B4 Relay
2024-11-18 13:12 ` [PATCH v2 2/3] rust: uaccess: simplify Result<()> in bytes_add_one return Manas via B4 Relay
@ 2024-11-18 13:12 ` Manas via B4 Relay
2 siblings, 0 replies; 8+ messages in thread
From: Manas via B4 Relay @ 2024-11-18 13:12 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. This also keeps the usage of `Result`
consistent.
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] 8+ messages in thread