ftrace: add compile-time check on F_printk()
authorLi Zefan <lizf@cn.fujitsu.com>
Mon, 14 Sep 2009 07:54:52 +0000 (15:54 +0800)
committerSteven Rostedt <rostedt@goodmis.org>
Mon, 14 Sep 2009 15:42:10 +0000 (11:42 -0400)
Make sure F_printk() has corrent format and args, and make sure
changes in F_STRUCT() won't break F_printk().

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4AADF6CC.1060809@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_export.c

index 4cb29d84d73a3c33325f908865c09ad00fc94e1f..2435d55947e61f2034c9140c75fa73e034cceba6 100644 (file)
 #undef __field_struct
 #define __field_struct(type, item)
 
+#undef __field
+#define __field(type, item)                            type item;
+
+#undef __field_desc
+#define __field_desc(type, container, item)            type item;
+
+#undef __array
+#define __array(type, item, size)                      type item[size];
+
+#undef __array_desc
+#define __array_desc(type, container, item, size)      type item[size];
+
+#undef __dynamic_array
+#define __dynamic_array(type, item)                    type item[];
+
+#undef F_STRUCT
+#define F_STRUCT(args...)                              args
+
+#undef F_printk
+#define F_printk(fmt, args...) fmt, args
+
+#undef FTRACE_ENTRY
+#define FTRACE_ENTRY(name, struct_name, id, tstruct, print)    \
+struct ____ftrace_##name {                                     \
+       tstruct                                                 \
+};                                                             \
+static void __used ____ftrace_check_##name(void)               \
+{                                                              \
+       struct ____ftrace_##name *__entry = NULL;               \
+                                                               \
+       /* force cmpile-time check on F_printk() */             \
+       printk(print);                                          \
+}
+
+#undef FTRACE_ENTRY_DUP
+#define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print)        \
+       FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
+
+#include "trace_entries.h"
+
+
 #undef __field
 #define __field(type, item)                                            \
        ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"      \
@@ -88,10 +129,6 @@ ftrace_format_##name(struct ftrace_event_call *unused,                      \
        return ret;                                                     \
 }
 
-#undef FTRACE_ENTRY_DUP
-#define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print)        \
-       FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
-
 #include "trace_entries.h"