]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Fix unsigned integers
authorKeith Busch <keith.busch@intel.com>
Fri, 28 Aug 2015 16:19:38 +0000 (10:19 -0600)
committerKeith Busch <keith.busch@intel.com>
Fri, 28 Aug 2015 16:19:38 +0000 (10:19 -0600)
Reported that using valid 32 bit integers causes errors do to type
signedness.

Signed-off-by: Keith Busch <keith.busch@intel.com>
src/argconfig.c

index e2ce2a33fd5ed5d219e5e404d08584e61f45a8b8..c89bbea4b2c41bd0f099da7be7174ac11a68bdac 100644 (file)
@@ -299,13 +299,13 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
             }
             *((uint16_t *) value_addr) = tmp;
         } else if (s->config_type == CFG_POSITIVE) {
-            int tmp = strtol(optarg, &endptr, 0);
+            uint32_t tmp = strtol(optarg, &endptr, 0);
             if (errno || tmp < 0 || optarg == endptr) {
                 fprintf(stderr, "Expected positive argument for '%s' but got '%s'!\n",
                         long_opts[option_index].name, optarg);
                 goto exit;
             }
-            *((int *) value_addr) = tmp;
+            *((uint32_t *) value_addr) = tmp;
         } else if (s->config_type == CFG_INCREMENT) {
             (*((int *) value_addr))++;
         } else if (s->config_type == CFG_LONG) {