From: Mathieu Desnoyers Date: Tue, 19 Jun 2012 17:45:05 +0000 (-0400) Subject: Fix C99 strict compatibility: don't use void * for function pointers X-Git-Tag: v2.1.0-rc1~55 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fbdeb5ecb8ff9b7d73a72de9fc66d07f7797d93f;p=lttng-ust.git Fix C99 strict compatibility: don't use void * for function pointers compiling public headers with --std=x99 -pedantic shows: warning: ISO C forbids conversion of object pointer to function pointer type Use "void (*func)(void)" to represent a generic function pointer rather than "void *". Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/tracepoint-types.h b/include/lttng/tracepoint-types.h index ee1cd78d..0c0c7237 100644 --- a/include/lttng/tracepoint-types.h +++ b/include/lttng/tracepoint-types.h @@ -16,7 +16,7 @@ */ struct tracepoint_probe { - void *func; + void (*func)(void); void *data; }; diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h index 3d54864f..5bab476b 100644 --- a/include/lttng/tracepoint.h +++ b/include/lttng/tracepoint.h @@ -148,7 +148,7 @@ static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_A if (caa_unlikely(!__tp_probe)) \ goto end; \ do { \ - void *__tp_cb = __tp_probe->func; \ + void (*__tp_cb)(void) = __tp_probe->func; \ void *__tp_data = __tp_probe->data; \ \ URCU_FORCE_CAST(void (*)(_TP_ARGS_DATA_PROTO(__VA_ARGS__)), __tp_cb) \ @@ -158,20 +158,21 @@ end: \ tp_rcu_read_unlock_bp(); \ } \ static inline void __tracepoint_register_##_provider##___##_name(char *name, \ - void *func, void *data) \ + void (*func)(void), void *data) \ { \ __tracepoint_probe_register(name, func, data, \ __tracepoint_##_provider##___##_name.signature); \ } \ static inline void __tracepoint_unregister_##_provider##___##_name(char *name, \ - void *func, void *data) \ + void (*func)(void), void *data) \ { \ __tracepoint_probe_unregister(name, func, data); \ } -extern int __tracepoint_probe_register(const char *name, void *func, void *data, - const char *signature); -extern int __tracepoint_probe_unregister(const char *name, void *func, void *data); +extern int __tracepoint_probe_register(const char *name, void (*func)(void), + void *data, const char *signature); +extern int __tracepoint_probe_unregister(const char *name, void (*func)(void), + void *data); /* * tracepoint dynamic linkage handling (callbacks). Hidden visibility: diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index da7a2299..5edfbb99 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -212,7 +212,7 @@ struct lttng_ctx { #define LTTNG_UST_EVENT_DESC_PADDING 40 struct lttng_event_desc { const char *name; - void *probe_callback; + void (*probe_callback)(void); const struct lttng_event_ctx *ctx; /* context */ const struct lttng_event_field *fields; /* event payload */ unsigned int nr_fields; @@ -282,6 +282,7 @@ struct lttng_ust_field_list { }; struct ust_pending_probe; +struct ltt_event; /* * ltt_event structure is referred to by the tracing fast path. It must be @@ -292,7 +293,7 @@ struct ltt_event { struct ltt_channel *chan; int enabled; const struct lttng_event_desc *desc; - void *filter; + void (*filter)(struct ltt_event *event); struct lttng_ctx *ctx; enum lttng_ust_instrumentation instrumentation; union { @@ -412,7 +413,7 @@ struct ltt_channel *ltt_global_channel_create(struct ltt_session *session, int ltt_event_create(struct ltt_channel *chan, struct lttng_ust_event *event_param, - void *filter, + void (*filter)(struct ltt_event *event), struct ltt_event **event); int ltt_channel_enable(struct ltt_channel *channel); diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 28ac8d80..78d85af2 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -496,7 +496,7 @@ static const int * \ const struct lttng_event_desc __event_desc___##_provider##_##_name = { \ .fields = __event_fields___##_provider##___##_template, \ .name = #_provider ":" #_name, \ - .probe_callback = (void *) &__event_probe__##_provider##___##_template,\ + .probe_callback = (void (*)(void)) &__event_probe__##_provider##___##_template,\ .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \ .loglevel = &__ref_loglevel___##_provider##___##_name, \ .signature = __tp_event_signature___##_provider##___##_template, \ diff --git a/liblttng-ust/ltt-events.c b/liblttng-ust/ltt-events.c index 226eca28..0fdfd2fd 100644 --- a/liblttng-ust/ltt-events.c +++ b/liblttng-ust/ltt-events.c @@ -500,7 +500,7 @@ void _ltt_channel_destroy(struct ltt_channel *chan) */ int ltt_event_create(struct ltt_channel *chan, struct lttng_ust_event *event_param, - void *filter, + void (*filter)(struct ltt_event *event), struct ltt_event **_event) { const struct lttng_event_desc *desc = NULL; /* silence gcc */ diff --git a/liblttng-ust/tracepoint-internal.h b/liblttng-ust/tracepoint-internal.h index 98688ace..72eafec1 100644 --- a/liblttng-ust/tracepoint-internal.h +++ b/liblttng-ust/tracepoint-internal.h @@ -32,10 +32,10 @@ struct tracepoint_lib { }; extern int tracepoint_probe_register_noupdate(const char *name, - void *callback, void *priv, + void (*callback)(void), void *priv, const char *signature); extern int tracepoint_probe_unregister_noupdate(const char *name, - void *callback, void *priv); + void (*callback)(void), void *priv); extern void tracepoint_probe_update_all(void); /* diff --git a/liblttng-ust/tracepoint.c b/liblttng-ust/tracepoint.c index a93f2863..85b14d2c 100644 --- a/liblttng-ust/tracepoint.c +++ b/liblttng-ust/tracepoint.c @@ -138,7 +138,7 @@ static void debug_print_probes(struct tracepoint_entry *entry) static void * tracepoint_entry_add_probe(struct tracepoint_entry *entry, - void *probe, void *data) + void (*probe)(void), void *data) { int nr_probes = 0; struct tracepoint_probe *old, *new; @@ -170,8 +170,8 @@ tracepoint_entry_add_probe(struct tracepoint_entry *entry, } static void * -tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe, - void *data) +tracepoint_entry_remove_probe(struct tracepoint_entry *entry, + void (*probe)(void), void *data) { int nr_probes = 0, nr_del = 0, i; struct tracepoint_probe *old, *new; @@ -391,7 +391,7 @@ static void tracepoint_update_probes(void) } static struct tracepoint_probe * -tracepoint_add_probe(const char *name, void *probe, void *data, +tracepoint_add_probe(const char *name, void (*probe)(void), void *data, const char *signature) { struct tracepoint_entry *entry; @@ -418,8 +418,8 @@ tracepoint_add_probe(const char *name, void *probe, void *data, * The probe address must at least be aligned on the architecture pointer size. * Called with the tracepoint mutex held. */ -int __tracepoint_probe_register(const char *name, void *probe, void *data, - const char *signature) +int __tracepoint_probe_register(const char *name, void (*probe)(void), + void *data, const char *signature) { void *old; int ret = 0; @@ -440,7 +440,8 @@ end: return ret; } -static void *tracepoint_remove_probe(const char *name, void *probe, void *data) +static void *tracepoint_remove_probe(const char *name, void (*probe)(void), + void *data) { struct tracepoint_entry *entry; void *old; @@ -462,7 +463,8 @@ static void *tracepoint_remove_probe(const char *name, void *probe, void *data) * @probe: probe function pointer * @probe: probe data pointer */ -int __tracepoint_probe_unregister(const char *name, void *probe, void *data) +int __tracepoint_probe_unregister(const char *name, void (*probe)(void), + void *data) { void *old; int ret = 0; @@ -499,7 +501,7 @@ static void tracepoint_add_old_probes(void *old) * * caller must call tracepoint_probe_update_all() */ -int tracepoint_probe_register_noupdate(const char *name, void *probe, +int tracepoint_probe_register_noupdate(const char *name, void (*probe)(void), void *data, const char *signature) { void *old; @@ -525,7 +527,7 @@ end: * caller must call tracepoint_probe_update_all() * Called with the tracepoint mutex held. */ -int tracepoint_probe_unregister_noupdate(const char *name, void *probe, +int tracepoint_probe_unregister_noupdate(const char *name, void (*probe)(void), void *data) { void *old;