Fix list command
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 7 Feb 2012 18:28:19 +0000 (13:28 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 7 Feb 2012 18:28:19 +0000 (13:28 -0500)
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 <mathieu.desnoyers@efficios.com>
src/bin/lttng/commands/list.c

index 6040d008d09a7b5f55f06dfdb05f7eb42981bf53..4a53968740bd789aa8216bfda39029396c346b72 100644 (file)
@@ -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;
This page took 0.02671 seconds and 4 git commands to generate.