Fix: don't define variables in headers
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 8 Jun 2012 17:17:05 +0000 (13:17 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 8 Jun 2012 17:17:05 +0000 (13:17 -0400)
From Hollis Blanchard <hollis_blanchard@mentor.com>:
> Hi, I was adding an LTTng UST 2.0 tracepoint to an application that uses
> -warn-common (see http://www.math.utah.edu/docs/info/ld_2.html). I created
> a simple tracepoint, had lttng-gen-tp produce tracepoints.o, then linked
> that to the application, along with -llttng-ust. This results in some
> warnings:
>
> tracepoints.o: warning: common of `handle' overridden by definition
> /usr/local/lib/liblttng-ust.so: warning: defined here
> tracepoints.o: warning: common of `lttng_client_callbacks_overwrite' overridden
> +by definition
> /usr/local/lib/liblttng-ust.so: warning: defined here
> tracepoints.o: warning: common of `lttng_client_callbacks_discard' overridden by
> +definition
> /usr/local/lib/liblttng-ust.so: warning: defined here
> tracepoints.o: warning: common of `lttng_client_callbacks_metadata' overridden
> +by definition
> /usr/local/lib/liblttng-ust.so: warning: defined here
> /usr/local/lib/liblttng-ust-tracepoint.so.0: warning: multiple common of
> +`handle'
> tracepoints.o: warning: previous common is here
>
> This seems to be a valid warning. The LTTng UST headers contain
> definitions like this in include/lttng/ringbuffer-config.h:
> struct lttng_ust_shm_handle *handle;
>
> If two objects use that header, each will get a copy of "handle", right?

handle: This was meant to be a forward declaration of

  struct lttng_ust_shm_handle

so just removing the "*handle" part. This can be considered as a
cleanup (or a fix without actual runtime effect).

lttng_client_callbacks_*: if the cb values would have been used in the
consumer daemon, this would have caused an issue: these would be set to
NULL instead of the actual callback pointers. So in a way this is a fix,
but it does not have any runtime impact at this point.

Reported-by: Hollis Blanchard <hollis_blanchard@mentor.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ringbuffer-config.h
include/lttng/ust-events.h

index 24fb1cc4c35cd9a51d1fcb9fae3733da358abb13..24e7dbeb6bf9e07fc8d1521a11ace7e8a830a016 100644 (file)
@@ -32,7 +32,7 @@ struct lttng_ust_lib_ring_buffer;
 struct channel;
 struct lttng_ust_lib_ring_buffer_config;
 struct lttng_ust_lib_ring_buffer_ctx;
-struct lttng_ust_shm_handle *handle;
+struct lttng_ust_shm_handle;
 
 /*
  * Ring buffer client callbacks. Only used by slow path, never on fast path.
index 9c015821b53a8f651f0e032098cd96e9fcea768b..da7a2299f055ec45ae7cd88c909b581536c65f15 100644 (file)
@@ -444,9 +444,9 @@ int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
 void lttng_context_vtid_reset(void);
 void lttng_context_vpid_reset(void);
 
-const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
-const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
-const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
+extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
+extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
+extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
 
 struct ltt_transport *ltt_transport_find(const char *name);
 
This page took 0.027309 seconds and 4 git commands to generate.