Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH] rust: add safety comment in rust_fmt_argument
@ 2024-11-15 21:49 Konstantin Andrikopoulos
  2024-11-16 19:39 ` Miguel Ojeda
  0 siblings, 1 reply; 4+ messages in thread
From: Konstantin Andrikopoulos @ 2024-11-15 21:49 UTC (permalink / raw)
  To: rust-for-linux; +Cc: Konstantin Andrikopoulos

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

The function rust_fmt_argument derefernces a c_void pointer, and thus it
needs an unsafe block. The safety comment for that block was missing.

Part of Rust-for-Linux#351.

Signed-off-by: Konstantin Andrikopoulos <kernel@mandragore.io>
---
 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 a28077a7cb30..3545dd08fde0 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 Rust contract guarantees that `ptr` is a valid pointer to a `fmt::Arguments` struct.
     let _ = w.write_fmt(unsafe { *(ptr as *const fmt::Arguments<'_>) });
     w.pos().cast()
 }
-- 
2.47.0


-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wnUEARYIACcFAmc3wf4JEP6FRRdCoj7tFiEEZVtNSmVGsZsFReCA/oVFF0Ki
Pu0AAPvrAQCD8WeORM8+Nqsp4WQBmItlZz0S0fP5C9aUZpXjcUSmtgEAnMAV
CwlhJFanwZteGT8wM2Xodx2V8dWCmJxqiucOLwg=
=wJMv
-----END PGP SIGNATURE-----


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

end of thread, other threads:[~2024-11-17 14:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 21:49 [PATCH] rust: add safety comment in rust_fmt_argument Konstantin Andrikopoulos
2024-11-16 19:39 ` Miguel Ojeda
2024-11-17 14:22   ` Konstantin Andrikopoulos
2024-11-17 14:45     ` Miguel Ojeda

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