From: Navaneeth K <knavaneeth786@gmail.com>
To: ojeda@kernel.org, alex.gaynor@gmail.com
Cc: wedsonaf@gmail.com, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org,
Navaneeth K <knavaneeth786@gmail.com>
Subject: [PATCH 1/2] rust: kernel: document safety for rust_fmt_argument
Date: Sat, 22 Nov 2025 19:09:07 +0000 [thread overview]
Message-ID: <20251122190908.259929-2-knavaneeth786@gmail.com> (raw)
In-Reply-To: <20251122190908.259929-1-knavaneeth786@gmail.com>
Add a proper // SAFETY: comment for the unsafe pointer dereference in
rust_fmt_argument. The comment explains that the caller guarantees
the pointer validity, satisfying the Rust-for-Linux safety documentation
requirements.
Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
---
rust/kernel/print.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/print.rs b/rust/kernel/print.rs
index 2d743d78d220..49fa87dfbce8 100644
--- a/rust/kernel/print.rs
+++ b/rust/kernel/print.rs
@@ -24,7 +24,7 @@
use fmt::Write;
// SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`.
let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) };
- // SAFETY: TODO.
+ // SAFETY: The caller guarantees that `ptr` points to a valid `fmt::Arguments`.
let _ = w.write_fmt(unsafe { *ptr.cast::<fmt::Arguments<'_>>() });
w.pos().cast()
}
--
2.43.0
next prev parent reply other threads:[~2025-11-22 19:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-22 19:09 [PATCH 0/2] rust: kernel: add missing safety documentation Navaneeth K
2025-11-22 19:09 ` Navaneeth K [this message]
2025-11-22 19:09 ` [PATCH 2/2] rust: kernel: document safety for as_str_unchecked Navaneeth K
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251122190908.259929-2-knavaneeth786@gmail.com \
--to=knavaneeth786@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).