public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Gary Guo" <gary@garyguo.net>, "Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Panagiotis Foliadis" <pfoliadis@posteo.net>,
	"Shankari Anand" <shankari.ak0208@gmail.com>,
	"FUJITA Tomonori" <fujita.tomonori@gmail.com>
Cc: "kernel test robot" <lkp@intel.com>,
	<rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] rust: task: use `as_char_ptr` instead of `as_ptr().cast()`
Date: Thu, 22 Jan 2026 14:48:49 +0000	[thread overview]
Message-ID: <DFV78VWVSJXY.2RW8FAP4JS8DM@garyguo.net> (raw)
In-Reply-To: <20260122144444.265412-1-gary@kernel.org>

On Thu Jan 22, 2026 at 2:44 PM GMT, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.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@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202601221157.89t3Sqbl-lkp@intel.com/
> Signed-off-by: Gary Guo <gary@garyguo.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


  parent reply	other threads:[~2026-01-22 14:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22 14:44 [PATCH v2 1/2] rust: task: use `as_char_ptr` instead of `as_ptr().cast()` Gary Guo
2026-01-22 14:44 ` [PATCH v2 2/2] rust: disallow use of `CStr::as_ptr` Gary Guo
2026-01-22 14:48 ` Gary Guo [this message]
2026-01-22 22:33   ` [PATCH v2 1/2] rust: task: use `as_char_ptr` instead of `as_ptr().cast()` Tamir Duberstein
2026-01-24 23:33 ` kernel test robot
2026-01-25 20:19   ` Tamir Duberstein
2026-01-26  9:22     ` Alice Ryhl
2026-01-26 12:25       ` Gary Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DFV78VWVSJXY.2RW8FAP4JS8DM@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=pfoliadis@posteo.net \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=shankari.ak0208@gmail.com \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox