[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251122190908.259929-2-knavaneeth786@gmail.com>
Date: Sat, 22 Nov 2025 19:09:07 +0000
From: Navaneeth K <knavaneeth786@...il.com>
To: ojeda@...nel.org,
alex.gaynor@...il.com
Cc: wedsonaf@...il.com,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org,
Navaneeth K <knavaneeth786@...il.com>
Subject: [PATCH 1/2] rust: kernel: document safety for rust_fmt_argument
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@...il.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
Powered by blists - more mailing lists