[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250911085447.17463-1-work@onurozkan.dev>
Date: Thu, 11 Sep 2025 11:54:47 +0300
From: Onur Özkan <work@...rozkan.dev>
To: rust-for-linux@...r.kernel.org
Cc: ojeda@...nel.org,
alex.gaynor@...il.com,
boqun.feng@...il.com,
gary@...yguo.net,
bjorn3_gh@...tonmail.com,
lossin@...nel.org,
a.hindborg@...nel.org,
aliceryhl@...gle.com,
tmgross@...ch.edu,
dakr@...nel.org,
tamird@...il.com,
daniel@...lak.dev,
linux-kernel@...r.kernel.org,
Onur Özkan <work@...rozkan.dev>
Subject: [PATCH] rust: resolve safety comment TODO in `as_str_unchecked`
Resolved the TODO comment with a proper safety explanation.
Signed-off-by: Onur Özkan <work@...rozkan.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
Powered by blists - more mailing lists