Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Gary Guo and committed by
Miguel Ojeda
1a933719 f4040a7c

+3 -4
+3 -4
rust/kernel/task.rs
··· 6 6 7 7 use crate::{ 8 8 bindings, 9 - ffi::{c_int, c_long, c_uint}, 10 9 mm::MmWithUser, 11 10 pid_namespace::PidNamespace, 11 + prelude::*, 12 12 sync::aref::ARef, 13 13 types::{NotThreadSafe, Opaque}, 14 14 }; 15 15 use core::{ 16 - cmp::{Eq, PartialEq}, 17 16 ops::Deref, 18 - ptr, 17 + ptr, // 19 18 }; 20 19 21 20 /// A sentinel value used for infinite timeouts. ··· 418 419 let file = kernel::file_from_location(loc); 419 420 420 421 // SAFETY: `file.as_ptr()` is valid for reading and guaranteed to be nul-terminated. 421 - unsafe { crate::bindings::__might_sleep(file.as_ptr().cast(), loc.line() as i32) } 422 + unsafe { crate::bindings::__might_sleep(file.as_char_ptr(), loc.line() as i32) } 422 423 } 423 424 424 425 // SAFETY: Always safe to call.