From: Konstantin Andrikopoulos <kernel@mandragore.io>
To: rust-for-linux@vger.kernel.org
Cc: Konstantin Andrikopoulos <kernel@mandragore.io>
Subject: [PATCH] rust: add safety comment in rust_fmt_argument
Date: Fri, 15 Nov 2024 21:49:50 +0000 [thread overview]
Message-ID: <20241115214907.191454-1-kernel@mandragore.io> (raw)
-----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-----
next reply other threads:[~2024-11-15 21:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 21:49 Konstantin Andrikopoulos [this message]
2024-11-16 19:39 ` [PATCH] rust: add safety comment in rust_fmt_argument Miguel Ojeda
2024-11-17 14:22 ` Konstantin Andrikopoulos
2024-11-17 14:45 ` Miguel Ojeda
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=20241115214907.191454-1-kernel@mandragore.io \
--to=kernel@mandragore.io \
--cc=rust-for-linux@vger.kernel.org \
/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