Fix: Possible use-after-free in create_ctx_type()
[lttng-tools.git] / src / bin / lttng / commands / disable_channels.c
index 7ae2ed79ad9439f036d2b1606581174321ba290c..f1f2e51b9a21c2296189c6813758fe7dfc3aa183 100644 (file)
@@ -15,7 +15,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <popt.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -33,11 +33,6 @@ static char *opt_channels;
 static int opt_kernel;
 static char *opt_session_name;
 static int opt_userspace;
-#if 0
-/* Not implemented yet */
-static char *opt_cmd_name;
-static pid_t opt_pid;
-#endif
 
 enum {
        OPT_HELP = 1,
@@ -53,13 +48,7 @@ static struct poptOption long_options[] = {
        {"help",           'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
        {"session",        's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
        {"kernel",         'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
-#if 0
-       /* Not implemented yet */
-       {"userspace",      'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0},
-       {"pid",            'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
-#else
        {"userspace",      'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
-#endif
        {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
        {0, 0, 0, 0, 0, 0, 0}
 };
@@ -110,7 +99,7 @@ static int mi_partial_channel_print(char *channel_name, unsigned int enabled,
 
        /* Success ? */
        ret = mi_lttng_writer_write_element_bool(writer,
-                       mi_lttng_element_command, success);
+                       mi_lttng_element_success, success);
        if (ret) {
                goto end;
        }
@@ -142,9 +131,8 @@ static int disable_channels(char *session_name)
        } else if (opt_userspace) {
                dom.type = LTTNG_DOMAIN_UST;
        } else {
-               print_missing_domain();
-               ret = CMD_ERROR;
-               goto error;
+               /* Checked by the caller. */
+               assert(0);
        }
 
        handle = lttng_create_handle(session_name, &dom);
@@ -179,7 +167,8 @@ static int disable_channels(char *session_name)
                         * Mi:
                         * We assume that if an error occurred the channel is still active.
                         * This might not be the case but is a good assumption.
-                        * The client should look at the stderr stream for more informations.
+                        * The client should look at the stderr stream
+                        * for more informations.
                         */
                        enabled = 1;
                        success = 0;
@@ -259,6 +248,12 @@ int cmd_disable_channels(int argc, const char **argv)
                }
        }
 
+       ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace);
+       if (ret) {
+               ret = CMD_ERROR;
+               goto end;
+       }
+
        opt_channels = (char*) poptGetArg(pc);
        if (opt_channels == NULL) {
                ERR("Missing channel name(s).\n");
This page took 0.025592 seconds and 4 git commands to generate.