From: Keith Busch Date: Fri, 28 Aug 2015 16:19:38 +0000 (-0600) Subject: Fix unsigned integers X-Git-Tag: v0.1~12 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=dba9698bc38623835715a4186d8749ca6312a79f;p=users%2Fsagi%2Fnvme-cli.git Fix unsigned integers Reported that using valid 32 bit integers causes errors do to type signedness. Signed-off-by: Keith Busch --- diff --git a/src/argconfig.c b/src/argconfig.c index e2ce2a33..c89bbea4 100644 --- a/src/argconfig.c +++ b/src/argconfig.c @@ -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) {