From patchwork Mon Nov 18 14:36:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manas via B4 Relay X-Patchwork-Id: 13878679 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 607EC1B4F25; Mon, 18 Nov 2024 14:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731940620; cv=none; b=KLs1DqCZphnxTTttqsDHR0/nPo21PnVfeW9HEsv0tY3XcCcU5E7bx+Bx44zw9aYwlt3r6RFRPB4RQfF3d/JoJ9DPeHJk+LhpZDzg9ao9sc9OqVBRlkMT7V6DmFB8nk9AD/c6K3/cs/+lOeoI9tGovlKqpG6lOQllMWCW1O7wAxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731940620; c=relaxed/simple; bh=F3SnLMn8Ir7Upg1k1br1UqesekB98aJ+5NfcgwfnNzE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OQDmAiwtIkChyRVGUp86Ui6wV/31WAI1atdtbsKbyRlLIvTIsQAvzQJJzrqKTfk2mnwuJKZiR4/5Dwd8YnNMGvjwpIkKVpZksejK5UI293VqgpXgqVK0EuVyxJ3HW3PvVOjNfukTAOQnMU3+CiKKtAPzaJ9Pkz+ifxKfaEOtVLc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iNgUhIWi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iNgUhIWi" Received: by smtp.kernel.org (Postfix) with ESMTPS id F33D4C4CED7; Mon, 18 Nov 2024 14:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731940620; bh=F3SnLMn8Ir7Upg1k1br1UqesekB98aJ+5NfcgwfnNzE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=iNgUhIWiijrBt01dIKmRRbcCM3LXVfUa8kBYpMIhqtp3joXCotTdTVfE0B/er/YlN m+QpkrkFLQUpUAFQteGUZxlpmfGG23ff5ACRKstA9b8i+o8X8axH4FM5oVZXnWT2L2 a+/P9rGr/MIQqztPIkcWtXFpw0zklL9cIRGav3hjahTzoVBXSgyrYTLGdf5Lr1q+3a bLfuKayuwkyafU2ySj1rf/qVqKFf3TIn6GTBYj9ArWmVMbJwg14o9NNLpo8DT3/STr 4Tmu0en6oms1uA4J2vlU/IL58jPbQrKGCMqCzH8I33iCK2OfZp3za9q26DTx8HRKmp 0+uuYL7LPcMOA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E18BAD4921D; Mon, 18 Nov 2024 14:36:59 +0000 (UTC) From: Manas via B4 Relay Date: Mon, 18 Nov 2024 20:06:58 +0530 Subject: [PATCH v3 1/3] rust: block: simplify Result<()> in validate_block_size return Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241118-simplify-result-v3-1-6b1566a77eab@iiitd.ac.in> References: <20241118-simplify-result-v3-0-6b1566a77eab@iiitd.ac.in> In-Reply-To: <20241118-simplify-result-v3-0-6b1566a77eab@iiitd.ac.in> 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 , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl Cc: Shuah Khan , Anup Sharma , netdev@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Manas X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1731940618; l=1188; i=manas18244@iiitd.ac.in; s=20240813; h=from:subject:message-id; bh=SjEoEAw4QthSgW06VVqrPjPqp4OFSw3Gjp5nrbE0RAU=; b=A/Mb8qo7Qi7OcYvRPjGPtfsA0qTx3z8eiNe0JuAYfi+2Rbz/Gr8wY65BMN1YbqOcIy8K0CH5v +IhxvUu7D4BCvgatpit1szrB6fHrzoXC9w5hIyQ4Jx7vcN2djHlwat+ X-Developer-Key: i=manas18244@iiitd.ac.in; a=ed25519; pk=pXNEDKd3qTkQe9vsJtBGT9hrfOR7Dph1rfX5ig2AAoM= X-Endpoint-Received: by B4 Relay for manas18244@iiitd.ac.in/20240813 with auth_id=196 X-Original-From: Manas Reply-To: manas18244@iiitd.ac.in From: Manas `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 Link: https://github.com/Rust-for-Linux/linux/issues/1128 Signed-off-by: Manas Reviewed-by: Miguel Ojeda --- 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 { From patchwork Mon Nov 18 14:36:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manas via B4 Relay X-Patchwork-Id: 13878678 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 334111AA1F1; Mon, 18 Nov 2024 14:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731940620; cv=none; b=VppbnQZJN0f+QPipzL0vUDBpfwoZdEsM9S6+S3LQwZeufK1/4+UiuugNxtsGi+Emv+LvKiAWHYeYljghQfgUOnvbExCb8uv3iJc4Y3GRFxA4sh+sAQyvEDBkodwTnK4ASNgwvYg2z3KZ7ZAAEVQqe7RlGrHYJ+owt7NRml8IjnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731940620; c=relaxed/simple; bh=esoZCnFjx5WNXz3R+iKa+/Xsb1A2fzUIYjufmmrEiV4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VNNS5d8EoXMAR/VpIu2nMnUpAwawax368gJInh+B/RAJ0q94F2QZvuwzGga5lPQjM/Ie9h4fKJcynA2rlhi3wIP2cEnFglUbHR3T/k7GesF+UxlMfPKK0Ho+Vk49RAmJdkunPseNiCQh3D0sj0JS3HoixrKC/n7f1lWG0HUJBlE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qKDmux5y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qKDmux5y" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0FDE0C4CED8; Mon, 18 Nov 2024 14:37:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731940620; bh=esoZCnFjx5WNXz3R+iKa+/Xsb1A2fzUIYjufmmrEiV4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qKDmux5yljJdb+TlTh/76+1leOXabxj1Z9Fs2HGlwSQUJxpyhGTeKU3fUIoHgVdo5 65X9TOG2Cd9jsQ4gbjbsqikkgrEgt2jOMQvFEKCW7OVbYtYdeQuV3p/7DBKeBsyGsI Gi8ed5rO90cPAO5D/B4xtj7YFw4eKt9bNoosUdTNfCSTiaTkZVrYNnyW4nWde7cPxG KxXLBr6l54hQYJfGHE9ZxV5W3xz1xxnN0suJ269f5+a2qdDLDoZb0rkA5AYJMlqMLl 1+KArtFvKqv2VXnUiHuwaNSkh1kPTv3DDYKS8OZCQJCFS5+5nk8gyuIohjZozWu67z MvfpnBQJFznEw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02449D4922A; Mon, 18 Nov 2024 14:37:00 +0000 (UTC) From: Manas via B4 Relay Date: Mon, 18 Nov 2024 20:06:59 +0530 Subject: [PATCH v3 2/3] rust: uaccess: simplify Result<()> in bytes_add_one return Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241118-simplify-result-v3-2-6b1566a77eab@iiitd.ac.in> References: <20241118-simplify-result-v3-0-6b1566a77eab@iiitd.ac.in> In-Reply-To: <20241118-simplify-result-v3-0-6b1566a77eab@iiitd.ac.in> 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 , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl Cc: Shuah Khan , Anup Sharma , netdev@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Manas X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1731940618; l=1055; i=manas18244@iiitd.ac.in; s=20240813; h=from:subject:message-id; bh=fXvE4MWPDfjFqc2bAWbwVy1YZ0cGmhfaa/pikK8HjcQ=; b=dhrh/6LCfnO2UT0ozqsoiea4r/886wFuhiNyyVGrEQk7OM3yTE7VnC+d5S+BD0WyItpc+9Ym2 9oa/fIrsgD8BQ0JeiQ8iANowMjk3Z+XKsMHs9JDXmzRiKXAEEGXMGzz X-Developer-Key: i=manas18244@iiitd.ac.in; a=ed25519; pk=pXNEDKd3qTkQe9vsJtBGT9hrfOR7Dph1rfX5ig2AAoM= X-Endpoint-Received: by B4 Relay for manas18244@iiitd.ac.in/20240813 with auth_id=196 X-Original-From: Manas Reply-To: manas18244@iiitd.ac.in From: Manas 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 Link: https://github.com/Rust-for-Linux/linux/issues/1128 Signed-off-by: Manas Reviewed-by: Boqun Feng --- 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(); From patchwork Mon Nov 18 14:37:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manas via B4 Relay X-Patchwork-Id: 13878680 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CEB21B6CFC; Mon, 18 Nov 2024 14:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731940620; cv=none; b=Y9W0Qv7U//cd7c9cPFzpn5gBPh99b/I1NiFzcIujWPyfargG3OnxfYwGNcdXuwg3WHFkvxGk6DsWCZK8ub/hTHL/f+zLmE3kegUPcjPyvAd7L5ED/wZlMW4TqSUiDnS6UR0GkZB7RWCS5dplFrluJ7Gpg+o7IrLo5z2G8XJWZV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731940620; c=relaxed/simple; bh=1C5xQW7WAmLfa3yWt5eppmcy13VdQvDCpoa+yQ2xw68=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uYWxqpq3/mclCj6dn5dX9iafTBsRoKAeF4C4HC8cB4rnoB51RDJtMqgVZ/p0ZwP5c2QVHGk8n8Ob/EQbRCmgTsqL+CQ+qR2OGXcWYLVlpUhmwAjPr7Wbay4T06s5aVxcgV8raPG9eETOR7bwY5T+Dfq9Cl6qLOsjqqLWTNaDHEc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RTlrgu1h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RTlrgu1h" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2786CC4CEDE; Mon, 18 Nov 2024 14:37:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731940620; bh=1C5xQW7WAmLfa3yWt5eppmcy13VdQvDCpoa+yQ2xw68=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RTlrgu1hpr0/ND4l7SsMNABskDLfpGcS364kqlO/5OBKd1RcpIZ48p3OZNiuigYtt U5yy5Wz3Q1lhjHM0GlU9GyDEZU0ft6hswf51WqE0O50u+U4m0d16D+EZaTDJXTfRLG 2TzMNfoU/KiCklIqDYEv5hHDQCYLCmD6aQk+XuLJbyNmjIBlNHJqJbZXQNs/u0O0R2 XbCZT8z5/haCskqctngH/STuOd9yOkepJn7dT0jaYv31oqkF1ZoUjXikhda+x+2vVP RYhgpJ6vlJApVR3YJ0t1l5QXZtPTAx70gD2unxtxptNdCnkdZyXpRICId9zttt+Oc/ 3Uvym7zbWBfJA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17EBFD4922D; Mon, 18 Nov 2024 14:37:00 +0000 (UTC) From: Manas via B4 Relay Date: Mon, 18 Nov 2024 20:07:00 +0530 Subject: [PATCH v3 3/3] rust: macros: simplify Result<()> in function returns Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241118-simplify-result-v3-3-6b1566a77eab@iiitd.ac.in> References: <20241118-simplify-result-v3-0-6b1566a77eab@iiitd.ac.in> In-Reply-To: <20241118-simplify-result-v3-0-6b1566a77eab@iiitd.ac.in> 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 , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl Cc: Shuah Khan , Anup Sharma , netdev@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Manas X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1731940618; l=1445; i=manas18244@iiitd.ac.in; s=20240813; h=from:subject:message-id; bh=NTTuXPWy5AUeqCEPojOUwO8gX5t/CAh+3ZZpchSjGSw=; b=TvZk+POq6esMzkJ39tL4CXbkwnxgKtAKjrW1VbhsNzlmzrcikgodE1xGSsj5SBJ+2ZWv8+42z ALzxsGbc1aoAJxPiSudyRmYmI22IvW9BpJV5IlEEHGn2VbgFrdfC6y+ X-Developer-Key: i=manas18244@iiitd.ac.in; a=ed25519; pk=pXNEDKd3qTkQe9vsJtBGT9hrfOR7Dph1rfX5ig2AAoM= X-Endpoint-Received: by B4 Relay for manas18244@iiitd.ac.in/20240813 with auth_id=196 X-Original-From: Manas Reply-To: manas18244@iiitd.ac.in From: Manas 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 Link: https://github.com/Rust-for-Linux/linux/issues/1128 Signed-off-by: Manas Reviewed-by: Boqun Feng --- 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) /// // ... /// }