Re: [PATCH v5 12/20] vsprintf: add new `%pA` format specifier

From: Andy Shevchenko
Date: Fri Mar 18 2022 - 10:08:21 EST


On Thu, Mar 17, 2022 at 07:10:00PM +0100, Miguel Ojeda wrote:
> From: Gary Guo <gary@xxxxxxxxxxx>
>
> This patch adds a format specifier `%pA` to `vsprintf` which formats
> a pointer as `core::fmt::Arguments`. Doing so allows us to directly
> format to the internal buffer of `printf`, so we do not have to use
> a temporary buffer on the stack to pre-assemble the message on
> the Rust side.
>
> This specifier is intended only to be used from Rust and not for C, so
> `checkpatch.pl` is intentionally unchanged to catch any misuse.

...

> + case 'A':
> + if (!IS_ENABLED(CONFIG_RUST)) {
> + WARN_ONCE(1, "Please remove %%pA from non-Rust code\n");
> + return error_string(buf, end, "(%pA?)", spec);
> + }

I'm wondering if the Big Scary Banner as trace_printk() does would be better
(in case we can tell that %pA is used in the code when RUST=n).

--
With Best Regards,
Andy Shevchenko