X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fenable_channels.c;h=3314bde0d6da4f7ff37d8747d2b1129e746bda92;hb=bb77204a261b474f7b659247c5fda93de4e40b86;hp=9c84d02634c8612740b914c4a1c6d0d5e806b210;hpb=68c7f6e55254fd6e54d7bb4a6c1316bb77843a6e;p=lttng-tools.git diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c index 9c84d0263..3314bde0d 100644 --- a/src/bin/lttng/commands/enable_channels.c +++ b/src/bin/lttng/commands/enable_channels.c @@ -493,16 +493,17 @@ int cmd_enable_channels(int argc, const char **argv) } case OPT_SWITCH_TIMER: { - unsigned long v; + uint64_t v; errno = 0; opt_arg = poptGetOptArg(pc); - v = strtoul(opt_arg, NULL, 0); - if (errno != 0 || !isdigit(opt_arg[0])) { - ERR("Wrong value in --switch-timer parameter: %s", opt_arg); + + if (utils_parse_time_suffix(opt_arg, &v) < 0) { + ERR("Wrong value for --switch-timer parameter: %s", opt_arg); ret = CMD_ERROR; goto end; } + if (v != (uint32_t) v) { ERR("32-bit overflow in --switch-timer parameter: %s", opt_arg); ret = CMD_ERROR; @@ -514,16 +515,17 @@ int cmd_enable_channels(int argc, const char **argv) } case OPT_READ_TIMER: { - unsigned long v; + uint64_t v; errno = 0; opt_arg = poptGetOptArg(pc); - v = strtoul(opt_arg, NULL, 0); - if (errno != 0 || !isdigit(opt_arg[0])) { - ERR("Wrong value in --read-timer parameter: %s", opt_arg); + + if (utils_parse_time_suffix(opt_arg, &v) < 0) { + ERR("Wrong value for --read-timer parameter: %s", opt_arg); ret = CMD_ERROR; goto end; } + if (v != (uint32_t) v) { ERR("32-bit overflow in --read-timer parameter: %s", opt_arg); ret = CMD_ERROR; @@ -535,13 +537,13 @@ int cmd_enable_channels(int argc, const char **argv) } case OPT_MONITOR_TIMER: { - unsigned long long v; + uint64_t v; errno = 0; opt_arg = poptGetOptArg(pc); - v = strtoull(opt_arg, NULL, 0); - if (errno != 0 || !isdigit(opt_arg[0])) { - ERR("Wrong value in --monitor-timer parameter: %s", opt_arg); + + if (utils_parse_time_suffix(opt_arg, &v) < 0) { + ERR("Wrong value for --monitor-timer parameter: %s", opt_arg); ret = CMD_ERROR; goto end; } @@ -552,7 +554,7 @@ int cmd_enable_channels(int argc, const char **argv) } case OPT_BLOCKING_TIMEOUT: { - long long v; /* in usec */ + uint64_t v; long long v_msec; errno = 0; @@ -565,10 +567,8 @@ int cmd_enable_channels(int argc, const char **argv) break; } - v = strtoll(opt_arg, NULL, 0); - if (errno != 0 || (!isdigit(opt_arg[0]) && opt_arg[0] != '-') - || v < 0) { - ERR("Wrong value in --blocking-timeout parameter: %s", opt_arg); + if (utils_parse_time_suffix(opt_arg, &v) < 0) { + ERR("Wrong value for --blocking-timeout parameter: %s", opt_arg); ret = CMD_ERROR; goto end; }