]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tracing: Remove local variable for argument detection from trace_printk()
authorQian-Yu Lin <tiffany019230@gmail.com>
Sat, 2 May 2026 07:55:34 +0000 (15:55 +0800)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 21 May 2026 22:03:06 +0000 (18:03 -0400)
The trace_printk() macro uses a local variable _______STR to detect
whether variadic arguments are present. This name can shadow outer
variables.

Replace the local variable with sizeof applied directly to the
stringified arguments:

  if (sizeof __stringify((__VA_ARGS__)) > 3)

This eliminates the shadowing risk entirely without introducing
any additional includes or local variables.

Verified with objdump on samples/trace_printk that all four cases
branch correctly: __trace_bputs, __trace_puts, __trace_bprintk,
and __trace_printk.

Link: https://patch.msgid.link/20260502075535.34997-1-tiffany019230@gmail.com
Suggested-by: David Laight <david.laight.linux@gmail.com>
Signed-off-by: Qian-Yu Lin <tiffany019230@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/linux/trace_printk.h

index 2670ec7f426299489b17171c4f7125f417a98e02..3d54f440dccf7f6bdeb857bb67b6f5071ce416d1 100644 (file)
@@ -86,8 +86,7 @@ do {                                                                  \
 
 #define trace_printk(fmt, ...)                         \
 do {                                                   \
-       char _______STR[] = __stringify((__VA_ARGS__)); \
-       if (sizeof(_______STR) > 3)                     \
+       if (sizeof __stringify((__VA_ARGS__)) > 3)              \
                do_trace_printk(fmt, ##__VA_ARGS__);    \
        else                                            \
                trace_puts(fmt);                        \