From aa5de748c1150c17624abce3cc74839fea3234f6 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 7 Feb 2012 13:28:19 -0500 Subject: [PATCH] Fix list command Broken by commit 081311398b0deca05eebaac8672efbc9af272d36 Fix by only creating the handle if kernel or ust is specified (so it still fixes the valgrind warning). Signed-off-by: Mathieu Desnoyers --- src/bin/lttng/commands/list.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 6040d008d..4a5396874 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -604,16 +604,14 @@ int cmd_list(int argc, const char **argv) } else if (opt_userspace) { DBG2("Listing userspace global domain"); domain.type = LTTNG_DOMAIN_UST; - } else { - usage(stderr); - ret = CMD_UNDEFINED; - goto end; } - handle = lttng_create_handle(session_name, &domain); - if (handle == NULL) { - ret = CMD_FATAL; - goto end; + if (opt_kernel || opt_userspace) { + handle = lttng_create_handle(session_name, &domain); + if (handle == NULL) { + ret = CMD_FATAL; + goto end; + } } if (session_name == NULL) { @@ -676,7 +674,9 @@ int cmd_list(int argc, const char **argv) } /* Clean handle before creating a new one */ - lttng_destroy_handle(handle); + if (handle) { + lttng_destroy_handle(handle); + } handle = lttng_create_handle(session_name, &domains[i]); if (handle == NULL) { @@ -696,7 +696,9 @@ end: if (domains) { free(domains); } - lttng_destroy_handle(handle); + if (handle) { + lttng_destroy_handle(handle); + } poptFreeContext(pc); return ret; -- 2.34.1