Fix: userspace probe accessors are not const-correct
[lttng-tools.git] / src / bin / lttng / commands / create.c
index 525464aa822d90b556308d830196eb38ed92b898..60ca1f5d45fc7e0b6271f022b382d9ff8ce9a162 100644 (file)
@@ -24,7 +24,7 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <time.h>
+#include <common/compat/time.h>
 #include <unistd.h>
 #include <signal.h>
 #include <sys/wait.h>
@@ -49,7 +49,13 @@ static char *opt_shm_path;
 static int opt_no_consumer;
 static int opt_no_output;
 static int opt_snapshot;
-static unsigned int opt_live_timer;
+static uint32_t opt_live_timer;
+
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-create.1.h>
+;
+#endif
 
 enum {
        OPT_HELP = 1,
@@ -141,18 +147,15 @@ static int set_consumer_url(const char *session_name, const char *ctrl_url,
 {
        int ret;
        struct lttng_handle *handle;
-       struct lttng_domain dom;
 
        assert(session_name);
 
        /*
-        * Set handle with the session name and the domain set to 0. This means to
-        * the session daemon that the next action applies on the tracing session
-        * rather then the domain specific session.
+        * Set handle with the session_name, but no domain. This implies that
+        * the actions taken with this handle apply on the tracing session
+        * rather then the domain-specific session.
         */
-       memset(&dom, 0, sizeof(dom));
-
-       handle = lttng_create_handle(session_name, &dom);
+       handle = lttng_create_handle(session_name, NULL);
        if (handle == NULL) {
                ret = CMD_FATAL;
                goto error;
@@ -345,6 +348,10 @@ static int create_session(void)
 
        /* Use default live URL if NO url is/are found. */
        if ((opt_live_timer && !opt_url) && (opt_live_timer && !opt_data_url)) {
+               /* Override the url */
+               free(url);
+               url = NULL;
+
                ret = asprintf(&alloc_url, "net://127.0.0.1");
                if (ret < 0) {
                        PERROR("asprintf default live URL");
@@ -442,7 +449,7 @@ static int create_session(void)
                        MSG("Default snapshot output set to: %s", print_str_url);
                }
                MSG("Snapshot mode set. Every channel enabled for that session will "
-                               "be set in overwrite mode and mmap output.");
+                               "be set to mmap output, and default to overwrite mode.");
        }
        if (opt_shm_path) {
                MSG("Session %s set to shm_path: %s.", session_name,
@@ -618,6 +625,7 @@ int cmd_create(int argc, const char **argv)
 {
        int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
        char *opt_arg = NULL;
+       const char *leftover = NULL;
        static poptContext pc;
 
        pc = poptGetContext(NULL, argc, argv, long_options, 0);
@@ -633,7 +641,7 @@ int cmd_create(int argc, const char **argv)
                        goto end;
                case OPT_LIVE_TIMER:
                {
-                       unsigned long v;
+                       uint64_t v;
 
                        errno = 0;
                        opt_arg = poptGetOptArg(pc);
@@ -645,22 +653,24 @@ int cmd_create(int argc, const char **argv)
                                break;
                        }
 
-                       v = strtoul(opt_arg, NULL, 0);
-                       if (errno != 0 || !isdigit(opt_arg[0])) {
-                               ERR("Wrong value in --live parameter: %s", opt_arg);
+                       if (utils_parse_time_suffix(opt_arg, &v) < 0) {
+                               ERR("Wrong value for --live parameter: %s", opt_arg);
                                ret = CMD_ERROR;
                                goto end;
                        }
+
                        if (v != (uint32_t) v) {
                                ERR("32-bit overflow in --live parameter: %s", opt_arg);
                                ret = CMD_ERROR;
                                goto end;
                        }
+
                        if (v == 0) {
                                ERR("Live timer interval must be greater than zero");
                                ret = CMD_ERROR;
                                goto end;
                        }
+
                        opt_live_timer = (uint32_t) v;
                        DBG("Session live timer interval set to %d", opt_live_timer);
                        break;
@@ -712,6 +722,13 @@ int cmd_create(int argc, const char **argv)
        }
        opt_session_name = (char*) poptGetArg(pc);
 
+       leftover = poptGetArg(pc);
+       if (leftover) {
+               ERR("Unknown argument: %s", leftover);
+               ret = CMD_ERROR;
+               goto end;
+       }
+
        command_ret = create_session();
        if (command_ret) {
                success = 0;
This page took 0.026402 seconds and 5 git commands to generate.