Skip to content

Commit 1a93371

Browse files
nbdd0121ojeda
authored andcommitted
rust: task: use as_char_ptr instead of as_ptr().cast()
`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@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202601221157.89t3Sqbl-lkp@intel.com/ Signed-off-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260203130745.868762-1-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent f4040a7 commit 1a93371

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

rust/kernel/task.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
77
use crate::{
88
bindings,
9-
ffi::{c_int, c_long, c_uint},
109
mm::MmWithUser,
1110
pid_namespace::PidNamespace,
11+
prelude::*,
1212
sync::aref::ARef,
1313
types::{NotThreadSafe, Opaque},
1414
};
1515
use core::{
16-
cmp::{Eq, PartialEq},
1716
ops::Deref,
18-
ptr,
17+
ptr, //
1918
};
2019

2120
/// A sentinel value used for infinite timeouts.
@@ -419,7 +418,7 @@ pub fn might_sleep() {
419418
let file = kernel::file_from_location(loc);
420419

421420
// SAFETY: `file.as_ptr()` is valid for reading and guaranteed to be nul-terminated.
422-
unsafe { crate::bindings::__might_sleep(file.as_ptr().cast(), loc.line() as i32) }
421+
unsafe { crate::bindings::__might_sleep(file.as_char_ptr(), loc.line() as i32) }
423422
}
424423

425424
// SAFETY: Always safe to call.

0 commit comments

Comments
 (0)