Fix C99 strict compatibility: don't use void * for function pointers
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 19 Jun 2012 17:45:05 +0000 (13:45 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 19 Jun 2012 17:45:05 +0000 (13:45 -0400)
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 <mathieu.desnoyers@efficios.com>
include/lttng/tracepoint-types.h
include/lttng/tracepoint.h
include/lttng/ust-events.h
include/lttng/ust-tracepoint-event.h
liblttng-ust/ltt-events.c
liblttng-ust/tracepoint-internal.h
liblttng-ust/tracepoint.c

index ee1cd78daba67274c1d82bb5d321240ed454bb95..0c0c723729363a6cfd5a69813d37f76e7dca099a 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 struct tracepoint_probe {
-       void *func;
+       void (*func)(void);
        void *data;
 };
 
index 3d54864fcf578ebc9fd50bfa69f2537334ef5dad..5bab476b86485a112c98a5ab433fa13ec88cca7d 100644 (file)
@@ -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:
index da7a2299f055ec45ae7cd88c909b581536c65f15..5edfbb99f88019565669adaf735cefa2e6cc3b12 100644 (file)
@@ -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);
index 28ac8d8075dc71a7518a43148d0bc746a5bd3715..78d85af2a85babac8ea938e62e5eec4f61fc4781 100644 (file)
@@ -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,       \
index 226eca287df44c9f62392242d9c6342a01a49b06..0fdfd2fd5bcdb115ace5ea1b4d70663c50b0a8eb 100644 (file)
@@ -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 */
index 98688ace8bd80c0a31aaefa7eb152fa9238565a7..72eafec1ab57c81acc3cb6e12c545a9a4992d7bc 100644 (file)
@@ -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);
 
 /*
index a93f286364550e1cf29a3388fa2f5b4a09d5adbf..85b14d2c176af0cbccaf9ad517cb0afc42ab6056 100644 (file)
@@ -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;
This page took 0.037319 seconds and 4 git commands to generate.