Rust-for-Linux / linux

Adding support for the Rust language to the Linux kernel.

Home Page:https://rust-for-linux.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rust: error: Markdown style nit

ojeda opened this issue · comments

The following SAFETY: comment should have a trivial Markdown style nit fixed:

        // SAFETY: self.0 is a valid error due to its invariant.

This requires submitting a proper patch to the LKML and the Rust for Linux mailing list. Please recall to test your changes, to use a proper title for the commit, to sign your commit under the Developer's Certificate of Origin and so on. Please see https://docs.kernel.org/process/submitting-patches.html and https://rust-for-linux.com/contributing for details.

Please take this issue only if you are new to the kernel development process and you would like to use it as a test to submit your first patch to the kernel.

Can I take this issue?

Can I take this issue?

Yeah you can take it :)

Were some comments deleted?

Were some comments deleted?

Yeah @ojeda, I think @manmshuk deleted, I had it in my mailboxy

Yeah I'm sorry, I thought I asked some really stupid questions. I'm trying to work on the issue.

@vincenzopalazzo Thanks for confirming -- I see them in the audit log too.

@manmshuk No need to apologize :) The issue is in the error.rs file. Are you in another branch by chance?

Thanks. No I'm in the rust/default branch. I've found the file(thanx again). I'm going to generate the patch and let you know if I face any difficulty.

The issue is in the error.rs file

Another embarrassing admit: In the file error.rs , I can't seem to find this exact comment
// SAFETY: self.0 is a valid error due to its invariant. Though obviously there are multiple other lines with the same SAFETY: comment.

The issues here are intended (nowadays) for rust-next -- please see https://rust-for-linux.com/branches.

I'm going to generate the patch and let you know if I face any difficulty

https://bpa.st/WGFQ
Does it look OK? @ojeda

Could you please post the text inline here?

Could you please post the text inline here?

Sure

From 9cf8823fa22b08a8c50cdce5bc78ab73ab73ea3f Mon Sep 17 00:00:00 2001
From: Manmohan Shukla <manmshuk@gmail.com>
Date: Thu, 24 Aug 2023 00:29:15 +0530
Subject: [PATCH] fix trivial markdown style nit

---
 rust/kernel/error.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index 05fcab6abfe6..45bb70f63087 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -133,7 +133,7 @@ pub fn to_errno(self) -> core::ffi::c_int {
     /// Returns the error encoded as a pointer.
     #[allow(dead_code)]
     pub(crate) fn to_ptr<T>(self) -> *mut T {
-        // SAFETY: self.0 is a valid error due to its invariant.
+        // # SAFETY: self.0 is a valid error due to its invariant.
         unsafe { bindings::ERR_PTR(self.0.into()) as *mut _ }
     }
--
2.34.1
Signed-off-by: Manmohan Shukla <manmshuk@gmail.com>

The title should follow the usual conventions, please take a look at past submissions or the Git log.

Also, please use scripts/checkpatch.pl, it will likely report the missing commit message and the missing Signed-off-by (because it is not in the commit message). Please read https://docs.kernel.org/process/submitting-patches.html for other notes/tips.

Finally, w.r.t. the contents, that change is not what we were expecting. Please see other SAFETY comments throughout the code to see how they look, and how we typically use Markdown in them. Hint: there is something in the line that should look like code.

Apologies for responding late but in the meantime I was figuring out the basics like compiling the kernel, running it in QEMU and tried to use KGDB. I've rewritten the patch, please take a look.

From 876e893d51b234544aeca7f46702c20e28d630ec Mon Sep 17 00:00:00 2001
From: Manmohan Shukla <manmshuk@gmail.com>
Date: Sun, 3 Sep 2023 06:22:42 +0530
Subject: [PATCH] rust: error: Markdown style nit

This patch fixes a trivial markdown style nit in the `SAFETY` comment.
Signed-off-by: Manmohan Shukla <manmshuk@gmail.com>
---
 rust/kernel/error.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index 05fcab6abfe6..6233021daa8a 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -133,7 +133,7 @@ pub fn to_errno(self) -> core::ffi::c_int {
     /// Returns the error encoded as a pointer.
     #[allow(dead_code)]
     pub(crate) fn to_ptr<T>(self) -> *mut T {
-        // SAFETY: self.0 is a valid error due to its invariant.
+        // SAFETY: `self.0` is a valid error due to its invariant.
         unsafe { bindings::ERR_PTR(self.0.into()) as *mut _ }
     }
 
-- 
2.34.1

Yeah, that was the change! :)

The patch looks way better now, thanks. There is a missing newline before the Signed-off-by, and the title/content could be reworded to follow the conventions, but that can be improved later. Please feel free to send it to the list!

The patch was sent and the commit merged, see 2a7e0a5 ("rust: error: Markdown style nit"). Thanks!