Use utils_parse_time_suffix in create and enable-channel command
[lttng-tools.git] / src / bin / lttng / commands / enable_channels.c
index 214c8a3621660c8cf83cbd31edf26e7b7c06aebc..3314bde0d6da4f7ff37d8747d2b1129e746bda92 100644 (file)
@@ -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;
This page took 0.026196 seconds and 5 git commands to generate.