Re: [PATCH] trace_printk: replace _______STR with __UNIQUE_ID(STR)

From: Steven Rostedt

Date: Fri May 01 2026 - 11:19:51 EST


On Fri, 1 May 2026 22:40:17 +0800
Qian-Yu Lin <tiffany019230@xxxxxxxxx> wrote:

> I propose using a compound literal in v2, which eliminates the local
> variable entirely and requires no extra include:
>
> #define trace_printk(fmt, ...) \
> do { \
> if (sizeof((char[]) \
> {__stringify((__VA_ARGS__))}) > 3) \
> do_trace_printk(fmt, ##__VA_ARGS__); \
> else \
> trace_puts(fmt); \
> } while (0)
>
> This fully eliminates the shadowing risk without any compile overhead.

Have you tested to make sure a string with no arguments still produces the
trace_puts() and one that has arguments calls do_trace_printk()?

I'm fine with that one if it still works.

-- Steve