Fix: lttng: poptGetArg doesn't provide string ownership
[lttng-tools.git] / src / bin / lttng / commands / list.c
index a2db7e6b14c6ff029013862ecb9f0e02fa79076b..79e4cf0e95d7cbb5c84e4e3987a68a157276e5b8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
  * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
  * SPDX-License-Identifier: GPL-2.0-only
@@ -18,6 +18,7 @@
 #include <common/mi-lttng.h>
 #include <common/time.h>
 #include <common/tracker.h>
+#include <lttng/domain-internal.h>
 #include <lttng/lttng.h>
 
 #include "../command.h"
@@ -576,7 +577,7 @@ static int list_agent_events(void)
                goto error;
        }
 
-       agent_domain_str = get_domain_str(domain.type);
+       agent_domain_str = lttng_domain_type_str(domain.type);
 
        DBG("Getting %s tracing events", agent_domain_str);
 
@@ -2128,19 +2129,19 @@ static int list_sessions(const char *session_name)
        } else {
                /* Pretty print */
                if (count == 0) {
-                       MSG("Currently no available tracing session");
+                       MSG("Currently no available recording session");
                        goto end;
                }
 
                if (session_name == NULL) {
-                       MSG("Available tracing sessions:");
+                       MSG("Available recording sessions:");
                }
 
                for (i = 0; i < count; i++) {
                        if (session_name != NULL) {
                                if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
                                        session_found = 1;
-                                       MSG("Tracing session %s: [%s%s]", session_name,
+                                       MSG("Recording session %s: [%s%s]", session_name,
                                                        active_string(sessions[i].enabled),
                                                        snapshot_string(sessions[i].snapshot_mode));
                                        if (*sessions[i].path) {
@@ -2281,7 +2282,7 @@ end:
 int cmd_list(int argc, const char **argv)
 {
        int opt, ret = CMD_SUCCESS;
-       const char *session_name, *leftover = NULL;
+       const char *arg_session_name, *leftover = NULL;
        static poptContext pc;
        struct lttng_domain domain;
        struct lttng_domain *domains = NULL;
@@ -2340,8 +2341,8 @@ int cmd_list(int argc, const char **argv)
        }
 
        /* Get session name (trailing argument) */
-       session_name = poptGetArg(pc);
-       DBG2("Session name: %s", session_name);
+       arg_session_name = poptGetArg(pc);
+       DBG2("Session name: %s", arg_session_name);
 
        leftover = poptGetArg(pc);
        if (leftover) {
@@ -2371,14 +2372,14 @@ int cmd_list(int argc, const char **argv)
        }
 
        if (opt_kernel || opt_userspace || opt_jul || opt_log4j || opt_python) {
-               the_handle = lttng_create_handle(session_name, &domain);
+               the_handle = lttng_create_handle(arg_session_name, &domain);
                if (the_handle == NULL) {
                        ret = CMD_FATAL;
                        goto end;
                }
        }
 
-       if (session_name == NULL) {
+       if (arg_session_name == NULL) {
                if (!opt_kernel && !opt_userspace && !opt_jul && !opt_log4j
                                && !opt_python) {
                        ret = list_sessions(NULL);
@@ -2426,19 +2427,19 @@ int cmd_list(int argc, const char **argv)
                        }
                }
                /* MI: the ouptut of list_sessions is an unclosed session element */
-               ret = list_sessions(session_name);
+               ret = list_sessions(arg_session_name);
                if (ret) {
                        goto end;
                }
 
-               ret = list_rotate_settings(session_name);
+               ret = list_rotate_settings(arg_session_name);
                if (ret) {
                        goto end;
                }
 
                /* Domain listing */
                if (opt_domain) {
-                       ret = list_domains(session_name);
+                       ret = list_domains(arg_session_name);
                        goto end;
                }
 
@@ -2489,7 +2490,7 @@ int cmd_list(int argc, const char **argv)
                        int i, nb_domain;
 
                        /* We want all domain(s) */
-                       nb_domain = lttng_list_domains(session_name, &domains);
+                       nb_domain = lttng_list_domains(arg_session_name, &domains);
                        if (nb_domain < 0) {
                                ret = CMD_ERROR;
                                ERR("%s", lttng_strerror(nb_domain));
@@ -2544,7 +2545,7 @@ int cmd_list(int argc, const char **argv)
                                }
 
                                the_handle = lttng_create_handle(
-                                               session_name, &domains[i]);
+                                               arg_session_name, &domains[i]);
                                if (the_handle == NULL) {
                                        ret = CMD_FATAL;
                                        goto end;
This page took 0.028404 seconds and 4 git commands to generate.