[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DFV78VWVSJXY.2RW8FAP4JS8DM@garyguo.net>
Date: Thu, 22 Jan 2026 14:48:49 +0000
From: "Gary Guo" <gary@...yguo.net>
To: "Gary Guo" <gary@...yguo.net>, "Miguel Ojeda" <ojeda@...nel.org>, "Boqun
Feng" <boqun.feng@...il.com>, 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: Re: [PATCH v2 1/2] rust: task: use `as_char_ptr` instead of
`as_ptr().cast()`
On Thu Jan 22, 2026 at 2:44 PM GMT, Gary Guo wrote:
> 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.
>
> 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>
Oops, I am trying out new workflow of using "git notes" for changelog, but I
forget to put set format.notes to true...
Here's the change log:
v1 -> v2:
- fix one existing usage of `as_ptr()` (kernel test robot)
- styling of message (Tamir)
- Link to v1: https://lore.kernel.org/rust-for-linux/202601221157.89t3Sqbl-lkp@intel.com/T/#m8ca5da7e22ff7ac6caff83326f4b81e0e9e3536f
> ---
> rust/kernel/task.rs | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs
> index cc907fb531bc..7ccb20a8f813 100644
> --- a/rust/kernel/task.rs
> +++ b/rust/kernel/task.rs
> @@ -9,6 +9,7 @@
> ffi::{c_int, c_long, c_uint},
> mm::MmWithUser,
> pid_namespace::PidNamespace,
> + str::CStrExt,
> sync::aref::ARef,
> types::{NotThreadSafe, Opaque},
> };
> @@ -419,7 +420,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: 053966c344dbd346e71305f530e91ea77916189f
Powered by blists - more mailing lists