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

From: Sergey Senozhatsky
Date: Tue Mar 22 2022 - 00:17:08 EST


On (22/03/18 17:04), Petr Mladek wrote:
> On Fri 2022-03-18 16:07:31, Andy Shevchenko wrote:
> > On Thu, Mar 17, 2022 at 07:10:00PM +0100, Miguel Ojeda wrote:
> > > From: Gary Guo <gary@xxxxxxxxxxx>
> > > + 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).
>
> Good question!
>
> The advantage of WARN_ONCE() is that it shows the stack so that it is
> easier to locate the caller.
>
> On the other hand, WARN_ONCE() is a bit misused here. It should be
> used only in situations that might be potentially fatal. It might
> even cause panic() with "panic_on_warn" kernel parameter.

Stack trace is certainly helpful here. So maybe dump_stack() instead
of WARN_ONCE()? I guess I don't mind WARN_ONCE().