]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
argconfig: use strtoul for unsigned types
authorKeith Busch <keith.busch@intel.com>
Mon, 10 Oct 2016 19:50:27 +0000 (13:50 -0600)
committerKeith Busch <keith.busch@intel.com>
Mon, 10 Oct 2016 19:50:27 +0000 (13:50 -0600)
Signed-off-by: Keith Busch <keith.busch@intel.com>
argconfig.c

index bda8b03c1cbd95d47cca32eb63cd011e03bfb70a..94d9487b9b80f7668db006ea6e2821eaaab5f412 100644 (file)
@@ -244,7 +244,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
                        }
                        *((int *)value_addr) = tmp;
                } else if (s->config_type == CFG_BYTE) {
-                       uint8_t tmp = strtol(optarg, &endptr, 0);
+                       uint8_t tmp = strtoul(optarg, &endptr, 0);
                        if (errno || tmp < 0 || optarg == endptr) {
                                fprintf(stderr,
                                        "Expected positive argument for '%s' but got '%s'!\n",
@@ -253,7 +253,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
                        }
                        *((uint8_t *) value_addr) = tmp;
                } else if (s->config_type == CFG_SHORT) {
-                       uint16_t tmp = strtol(optarg, &endptr, 0);
+                       uint16_t tmp = strtoul(optarg, &endptr, 0);
                        if (errno || tmp < 0 || optarg == endptr) {
                                fprintf(stderr,
                                        "Expected positive argument for '%s' but got '%s'!\n",
@@ -262,7 +262,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
                        }
                        *((uint16_t *) value_addr) = tmp;
                } else if (s->config_type == CFG_POSITIVE) {
-                       uint32_t tmp = strtol(optarg, &endptr, 0);
+                       uint32_t tmp = strtoul(optarg, &endptr, 0);
                        if (errno || tmp < 0 || optarg == endptr) {
                                fprintf(stderr,
                                        "Expected positive argument for '%s' but got '%s'!\n",
@@ -273,7 +273,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
                } else if (s->config_type == CFG_INCREMENT) {
                        (*((int *)value_addr))++;
                } else if (s->config_type == CFG_LONG) {
-                       *((long *)value_addr) = strtol(optarg, &endptr, 0);
+                       *((long *)value_addr) = strtoul(optarg, &endptr, 0);
                        if (errno || optarg == endptr) {
                                fprintf(stderr,
                                        "Expected long integer argument for '%s' but got '%s'!\n",