[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260203130745.868762-1-gary@kernel.org>
Date: Tue, 3 Feb 2026 13:06:26 +0000
From: Gary Guo <gary@...nel.org>
To: Miguel Ojeda <ojeda@...nel.org>,
Boqun Feng <boqun@...nel.org>,
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>,
Panagiotis Foliadis <pfoliadis@...teo.net>,
Shankari Anand <shankari.ak0208@...il.com>,
FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: kernel test robot <lkp@...el.com>,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v3 1/2] rust: task: use `as_char_ptr` instead of `as_ptr().cast()`
From: Gary Guo <gary@...yguo.net>
`as_char_ptr` would provide the correct (unsigned char) type without
needing to convert to an intermediate type and cast the pointer.
The `as_ptr()` function is going to be disallowed by clippy warning, so fix
this usage.
This is used only if CONFIG_DEBUG_ATOMIC_SLEEP=y. Instead of conditionally
importing `CStrExt`, import it via prelude instead, and remove other
imports that are already available via the prelude.
Reported-by: kernel test robot <lkp@...el.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202601221157.89t3Sqbl-lkp@intel.com/
Signed-off-by: Gary Guo <gary@...yguo.net>
---
Changes since v2:
- Use CStrExt from prelude, as the use of it is conditional on
CONFIG_DEBUG_ATOMIC_SLEEP
Link to v2: https://lore.kernel.org/rust-for-linux/20260122144444.265412-1-gary@kernel.org/#t
---
rust/kernel/task.rs | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs
index cc907fb531bc..049c8a4d45d8 100644
--- a/rust/kernel/task.rs
+++ b/rust/kernel/task.rs
@@ -6,16 +6,15 @@
use crate::{
bindings,
- ffi::{c_int, c_long, c_uint},
mm::MmWithUser,
pid_namespace::PidNamespace,
+ prelude::*,
sync::aref::ARef,
types::{NotThreadSafe, Opaque},
};
use core::{
- cmp::{Eq, PartialEq},
ops::Deref,
- ptr,
+ ptr, //
};
/// A sentinel value used for infinite timeouts.
@@ -419,7 +418,7 @@ pub fn might_sleep() {
let file = kernel::file_from_location(loc);
// SAFETY: `file.as_ptr()` is valid for reading and guaranteed to be nul-terminated.
- unsafe { crate::bindings::__might_sleep(file.as_ptr().cast(), loc.line() as i32) }
+ unsafe { crate::bindings::__might_sleep(file.as_char_ptr(), loc.line() as i32) }
}
// SAFETY: Always safe to call.
base-commit: 4c87cdd0328495759f6e9f9f4e1e53ef8032a76f
--
2.51.2
Powered by blists - more mailing lists