Enforce const-correctness in UNIX socket wrappers
[lttng-tools.git] / src / bin / lttng / commands / add_context.c
index e50ed84b6e97b9e0e7756ebf4b4a8c3b1bcaffba..fb37c0aa738f202b6d9a8dbd1a32f1470e91420c 100644 (file)
@@ -15,7 +15,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <ctype.h>
 #include <popt.h>
 #include <stdio.h>
@@ -24,6 +24,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <assert.h>
 
 #include <urcu/list.h>
 
@@ -39,12 +40,6 @@ static int opt_kernel;
 static int opt_userspace;
 static char *opt_type;
 
-#if 0
-/* Not implemented yet */
-static char *opt_cmd_name;
-static pid_t opt_pid;
-#endif
-
 enum {
        OPT_HELP = 1,
        OPT_TYPE,
@@ -567,9 +562,7 @@ static int add_context(char *session_name)
        } else if (opt_userspace) {
                dom.type = LTTNG_DOMAIN_UST;
        } else {
-               print_missing_domain();
-               ret = CMD_ERROR;
-               goto error;
+               assert(0);
        }
 
        handle = lttng_create_handle(session_name, &dom);
@@ -715,9 +708,9 @@ int cmd_add_context(int argc, const char **argv)
                                goto end;
                        }
 
-                       type = malloc(sizeof(struct ctx_type));
+                       type = zmalloc(sizeof(struct ctx_type));
                        if (type == NULL) {
-                               perror("malloc ctx_type");
+                               PERROR("malloc ctx_type");
                                ret = CMD_FATAL;
                                goto end;
                        }
@@ -734,9 +727,6 @@ int cmd_add_context(int argc, const char **argv)
                        break;
                case OPT_USERSPACE:
                        opt_userspace = 1;
-#if 0
-                       opt_cmd_name = poptGetOptArg(pc);
-#endif
                        break;
                case OPT_LIST_OPTIONS:
                        list_cmd_options(stdout, long_options);
@@ -748,6 +738,13 @@ int cmd_add_context(int argc, const char **argv)
                }
        }
 
+       ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace);
+
+       if (ret) {
+               ret = CMD_ERROR;
+               goto end;
+       }
+
        if (!opt_type) {
                ERR("Missing mandatory -t TYPE");
                usage(stderr);
This page took 0.023991 seconds and 4 git commands to generate.