From aec7a14efc8ef77db92bb470eb84cab637b16954 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 8 Jun 2012 13:17:05 -0400 Subject: [PATCH] Fix: don't define variables in headers From Hollis Blanchard : > 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 Signed-off-by: Mathieu Desnoyers --- include/lttng/ringbuffer-config.h | 2 +- include/lttng/ust-events.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h index 24fb1cc4..24e7dbeb 100644 --- a/include/lttng/ringbuffer-config.h +++ b/include/lttng/ringbuffer-config.h @@ -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. diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 9508e766..5e7821b5 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -433,9 +433,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); -- 2.34.1