The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] rust: resolve safety comment TODO in `as_str_unchecked`
@ 2025-09-11  8:54 Onur Özkan
  2026-01-18 22:57 ` Miguel Ojeda
  0 siblings, 1 reply; 2+ messages in thread
From: Onur Özkan @ 2025-09-11  8:54 UTC (permalink / raw)
  To: rust-for-linux
  Cc: ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin,
	a.hindborg, aliceryhl, tmgross, dakr, tamird, daniel,
	linux-kernel, Onur Özkan

Resolved the TODO comment with a proper safety explanation.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
 rust/kernel/str.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
index 6c892550c0ba..11c30c765828 100644
--- a/rust/kernel/str.rs
+++ b/rust/kernel/str.rs
@@ -380,7 +380,8 @@ pub fn to_str(&self) -> Result<&str, core::str::Utf8Error> {
     /// ```
     #[inline]
     pub unsafe fn as_str_unchecked(&self) -> &str {
-        // SAFETY: TODO.
+        // SAFETY: The safety precondition guarantees that the contents
+        // of this `CStr` are valid UTF-8.
         unsafe { core::str::from_utf8_unchecked(self.as_bytes()) }
     }

--
2.50.0


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

* Re: [PATCH] rust: resolve safety comment TODO in `as_str_unchecked`
  2025-09-11  8:54 [PATCH] rust: resolve safety comment TODO in `as_str_unchecked` Onur Özkan
@ 2026-01-18 22:57 ` Miguel Ojeda
  0 siblings, 0 replies; 2+ messages in thread
From: Miguel Ojeda @ 2026-01-18 22:57 UTC (permalink / raw)
  To: Onur Özkan
  Cc: rust-for-linux, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, dakr, tamird, daniel,
	linux-kernel

On Fri, Sep 12, 2025 at 6:53 AM Onur Özkan <work@onurozkan.dev> wrote:
>
> Resolved the TODO comment with a proper safety explanation.
>
> Signed-off-by: Onur Özkan <work@onurozkan.dev>

I saw this patch without replies -- for future reference, commit
3b83f5d5e78a ("rust: replace `CStr` with `core::ffi::CStr`") made this
one not needed.

Thanks!

Cheers,
Miguel

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

end of thread, other threads:[~2026-01-18 22:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11  8:54 [PATCH] rust: resolve safety comment TODO in `as_str_unchecked` Onur Özkan
2026-01-18 22:57 ` Miguel Ojeda

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