X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fcreate.c;h=d2741c37309239697ab9d7b30fed98ee5011f2c9;hp=faf9f3e0d780274d2beb69ab838d2302e4713dcd;hb=2a1135fa25ad1fcad3b395e795aa6d41afc90c54;hpb=68c7f6e55254fd6e54d7bb4a6c1316bb77843a6e diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index faf9f3e0d..d2741c373 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -49,7 +49,7 @@ 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[] = @@ -442,7 +442,7 @@ static int create_session(void) MSG("Traces will be written in %s", print_str_url); if (opt_live_timer) { - MSG("Live timer set to %u usec", opt_live_timer); + MSG("Live timer set to %u %s", opt_live_timer, USEC_UNIT); } } else if (opt_snapshot) { if (print_str_url) { @@ -641,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); @@ -653,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;