All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Ke Sun <sunke@kylinos.cn>, Tamir Duberstein <tamird@gmail.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] rust: fmt: fix {:p} formatting for raw pointers
Date: Thu, 18 Dec 2025 08:04:45 +0000	[thread overview]
Message-ID: <aUO1nRdaAISMjMTG@google.com> (raw)
In-Reply-To: <20251218032709.2184890-1-sunke@kylinos.cn>

On Thu, Dec 18, 2025 at 11:27:09AM +0800, Ke Sun wrote:
> The fmt! macro wraps arguments as Adapter(&arg), causing raw pointers
> to be wrapped as Adapter(&*mut T). The generic Pointer implementation
> then formats the reference address (stack address of the variable)
> instead of the pointer value.
> 
> Add specialized Pointer implementations for Adapter<&*mut T> and
> Adapter<&*const T> that dereference before formatting.
> 
> Example:
>     let ptr: *mut SomeStruct = 0x12345678 as *mut _;
>     dev_info!(dev, "ptr: {:p}", ptr);
> 
> Before (wrong): prints stack address of `ptr` variable, e.g. 0xffffc90001234560
> After (correct): prints pointer value, e.g. 0x12345678
> 
> Signed-off-by: Ke Sun <sunke@kylinos.cn>

Ahh ... the goal here is that trying to print a raw pointer should not
compile at all. It's unfortunate if that's not what actually happens.

Alice

      reply	other threads:[~2025-12-18  8:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18  3:27 [PATCH] rust: fmt: fix {:p} formatting for raw pointers Ke Sun
2025-12-18  8:04 ` Alice Ryhl [this message]

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=aUO1nRdaAISMjMTG@google.com \
    --to=aliceryhl@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sunke@kylinos.cn \
    --cc=tamird@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.