Skip to contentSkip to conversation

ftrace.h: TP_fast_assign - use do {} while (0);

PATCH In review Joe Perches 2 participants 2 messages Sep 9, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ftrace.h: TP_fast_assign - use do {} while (0);

Perhaps this is a more kernel style standard way to allow local variables in TP_fast_assign.

http://git.kernel.org/?p=linux/kernel/git/x86/linux-2.6-tip.git;a=commitdiff;h=a9c1c3abe1160a5632e48c929b02b740556bf423

include/trace/ftrace.h +1 -1
index f64fbaa..4c99bdc 100644
@@ -142,7 +142,7 @@
 #define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
 
 #undef TP_fast_assign
-#define TP_fast_assign(args...) args
+#define TP_fast_assign(args...) do { args } while (0);
 
 #undef TP_perf_assign
 #define TP_perf_assign(args...)
maintainer
#1 lore raw
Quoted 12 lines · Joe Perches

Perhaps this is a more kernel style standard way to allow local variables in TP_fast_assign.

http://git.kernel.org/?p=linux/kernel/git/x86/linux-2.6-tip.git;a=commitdiff;h=a9c1c3abe1160a5632e48c929b02b740556bf423

include/trace/ftrace.h +0 -0
index f64fbaa..4c99bdc 100644

include/trace/ftrace.h line 148

Quoted 8 lines
include/trace/ftrace.h +1 -1
@@ -142,7 +142,7 @@
 #define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
 
 #undef TP_fast_assign
-#define TP_fast_assign(args...) args
+#define TP_fast_assign(args...) do { args } while (0);
 
 #undef TP_perf_assign
 #define TP_perf_assign(args...)

This is not a normal macro that is used globally. I like the referenced commit better, because it shows where it is used what is happening. Note, TP_fast_assign is just a parameter into another macro, and using do { } while (0) is not really going to help change anything. This doesn't even remove a checkpatch warning.

-- Steve