tracepoints: Add check trace callback type
Mathieu Desnoyers [Fri, 30 Apr 2010 16:59:59 +0000 (12:59 -0400)]
This check is meant to be used by tracepoint users which do a direct cast of
callbacks to (void *) for direct registration, thus bypassing the
register_trace_##name and unregister_trace_##name checks.

This permits to ensure that the callback type matches the function type at the
call site, but without generating any code.

Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
LKML-Reference: <20100430165959.GA25605@Krystal>
CC: Ingo Molnar <mingo@elte.hu>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Arnaldo Carvalho de Melo <acme@redhat.com>
CC: Lai Jiangshan <laijs@cn.fujitsu.com>
CC: Li Zefan <lizf@cn.fujitsu.com>
CC: Christoph Hellwig <hch@lst.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

include/linux/tracepoint.h

index 1d85f9a..8d5e4f6 100644 (file)
@@ -137,9 +137,11 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
        static inline int unregister_trace_##name(void (*probe)(proto)) \
        {                                                               \
                return tracepoint_probe_unregister(#name, (void *)probe);\
+       }                                                               \
+       static inline void check_trace_callback_type_##name(void (*cb)(proto)) \
+       {                                                               \
        }
 
-
 #define DEFINE_TRACE_FN(name, reg, unreg)                              \
        static const char __tpstrtab_##name[]                           \
        __attribute__((section("__tracepoints_strings"))) = #name;      \
@@ -168,6 +170,9 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
        static inline int unregister_trace_##name(void (*probe)(proto)) \
        {                                                               \
                return -ENOSYS;                                         \
+       }                                                               \
+       static inline void check_trace_callback_type_##name(void (*cb)(proto)) \
+       {                                                               \
        }
 
 #define DEFINE_TRACE_FN(name, reg, unreg)