summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorQian-Yu Lin <tiffany019230@gmail.com>2026-05-02 10:55:34 +0300
committerSteven Rostedt <rostedt@goodmis.org>2026-05-22 01:03:06 +0300
commit04fcbcf2dfe6a3fadc50b0f925c0b757386b82f8 (patch)
treecf41715dff04d960c2cb130ac845bcf137a0ce63 /include/linux
parent9764e731ef6abacdfc00d914061d4d900e302670 (diff)
downloadlinux-04fcbcf2dfe6a3fadc50b0f925c0b757386b82f8.tar.xz
tracing: Remove local variable for argument detection from trace_printk()
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>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/trace_printk.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/include/linux/trace_printk.h b/include/linux/trace_printk.h
index 2670ec7f4262..3d54f440dccf 100644
--- a/include/linux/trace_printk.h
+++ b/include/linux/trace_printk.h
@@ -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); \