[lttng-dev] [lttng-tools PATCH] lttng-sessiond: do not call ustctl_register_done()

Gerlando Falauto gerlando.falauto at keymile.com
Thu Jan 5 06:25:29 EST 2012


When lttng-ust support is not enabled, compilation might
fail with:
lttng-tools.git/lttng-sessiond/main.c:1167: undefined reference to `ustctl_register_done'

Actually when HAVE_LIBLTTNG_UST_CTL is not defined,
the function call is normally optimized out by the compiler
because ust_app_register() is a static inline alway returning
a negative value, leaving the call within unreachable code.

Depending on the compiler version and optimization flags,
this may however not always happen, leading to the above error.

Therefore replace ustctl_register_done() with ustapp_register_done(),
which calls the original function when lttng-ust is enabled, and
returns an error otherwise (it is unreachable code anyway).
---
 lttng-sessiond/main.c    |    2 +-
 lttng-sessiond/ust-app.h |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c
index 84cff5b..7523a17 100644
--- a/lttng-sessiond/main.c
+++ b/lttng-sessiond/main.c
@@ -1164,7 +1164,7 @@ static void *thread_manage_apps(void *data)
 					 */
 					update_ust_app(ust_cmd.sock);
 
-					ret = ustctl_register_done(ust_cmd.sock);
+					ret = ust_app_register_done(ust_cmd.sock);
 					if (ret < 0) {
 						/*
 						 * If the registration is not possible, we simply
diff --git a/lttng-sessiond/ust-app.h b/lttng-sessiond/ust-app.h
index 0c753ab..d05bf11 100644
--- a/lttng-sessiond/ust-app.h
+++ b/lttng-sessiond/ust-app.h
@@ -119,6 +119,11 @@ struct ust_app {
 #ifdef HAVE_LIBLTTNG_UST_CTL
 
 int ust_app_register(struct ust_register_msg *msg, int sock);
+static inline
+int ust_app_register_done(int sock)
+{
+	return ust_ctl_register_done(sock);
+}
 void ust_app_unregister(int sock);
 unsigned long ust_app_list_count(void);
 int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app);
@@ -195,6 +200,11 @@ int ust_app_register(struct ust_register_msg *msg, int sock)
 	return -ENOSYS;
 }
 static inline
+int ust_app_register_done(int sock)
+{
+	return -ENOSYS;
+}
+static inline
 void ust_app_unregister(int sock)
 {
 }
-- 
1.7.1




More information about the lttng-dev mailing list