[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251201062516.45495-1-yu.whisper.personal@gmail.com>
Date: Mon, 1 Dec 2025 14:25:16 +0800
From: Hsiu Che Yu <yu.whisper.personal@...il.com>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Hsiu Che Yu <yu.whisper.personal@...il.com>,
Miguel Ojeda <ojeda@...nel.org>,
Yury Norov <yury.norov@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] rust: num: bounded: add safety comment for Bounded::__new
The `__new` constructor only performs a bounds check and stores the
value in the wrapper type. It does not perform any unsafe memory
operations, so it does not need to be marked as `unsafe`.
Reported-by: Miguel Ojeda <ojeda@...nel.org>
Closes: https://github.com/Rust-for-Linux/linux/issues/1211
Signed-off-by: Hsiu Che Yu <yu.whisper.personal@...il.com>
---
rust/kernel/num/bounded.rs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/rust/kernel/num/bounded.rs b/rust/kernel/num/bounded.rs
index f870080af8ac..cde1b8ba6880 100644
--- a/rust/kernel/num/bounded.rs
+++ b/rust/kernel/num/bounded.rs
@@ -284,6 +284,9 @@ impl<T, const N: u32> Bounded<T, N>
///
/// The caller remains responsible for checking, either statically or dynamically, that `value`
/// can be represented as a `T` using at most `N` bits.
+ ///
+ /// **Note**: This function is not marked as `unsafe` because it performs no memory-unsafe
+ /// operations itself.
const fn __new(value: T) -> Self {
// Enforce the type invariants.
const {
--
2.43.0
Powered by blists - more mailing lists