Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH] rust: print: document safety of printing functions
@ 2026-09-08 20:38 Mohamed Osama
  2026-09-08 20:42 ` Miguel Ojeda
  0 siblings, 1 reply; 2+ messages in thread
From: Mohamed Osama @ 2026-09-08 20:38 UTC (permalink / raw)
  To: rust-for-linux; +Cc: linux-kernel, ojeda, Mohamed Osama

Signed-off-by: Mohamed Osama <mohamed.osama189110@gmail.com>
---
 rust/kernel/print.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/print.rs b/rust/kernel/print.rs
index 0d62beeedca5..def6ef5a1dec 100644
--- a/rust/kernel/print.rs
+++ b/rust/kernel/print.rs
@@ -29,7 +29,8 @@
     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: `ptr` is provided by the `%pA` formatting path and points to the
+    // `fmt::Arguments` passed to `_printk`.
     let _ = w.write_fmt(unsafe { *ptr.cast::<fmt::Arguments<'_>>() });
     w.pos().cast()
 }
@@ -109,7 +110,8 @@ pub unsafe fn call_printk(
 ) {
     // `_printk` does not seem to fail in any path.
     #[cfg(CONFIG_PRINTK)]
-    // SAFETY: TODO.
+    // SAFETY: `format_string` is one of the fixed format strings, `module_name` is
+    // null-terminated, and the `%pA` argument is a pointer to the valid `args`.
     unsafe {
         bindings::_printk(
             format_string.as_ptr(),
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rust: print: document safety of printing functions
  2026-09-08 20:38 [PATCH] rust: print: document safety of printing functions Mohamed Osama
@ 2026-09-08 20:42 ` Miguel Ojeda
  0 siblings, 0 replies; 2+ messages in thread
From: Miguel Ojeda @ 2026-09-08 20:42 UTC (permalink / raw)
  To: Mohamed Osama; +Cc: rust-for-linux, linux-kernel, ojeda

On Tue, Sep 8, 2026 at 10:38 PM Mohamed Osama
<mohamed.osama189110@gmail.com> wrote:
>
> Signed-off-by: Mohamed Osama <mohamed.osama189110@gmail.com>

Welcome and thanks for the patch!

The kernel requires a commit message.

In addition, please see (and maybe help review!) previous attempts:

  https://lore.kernel.org/rust-for-linux/20260729175305.723486-1-cianmcguire167@gmail.com/

Finally, the commit message should have the right tags, and Cc all the
maintainers and reviewers of the `RUST` subsystem from the
`MAINTAINERS` file.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-08 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 20:38 [PATCH] rust: print: document safety of printing functions Mohamed Osama
2026-09-08 20:42 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox