From dba9698bc38623835715a4186d8749ca6312a79f Mon Sep 17 00:00:00 2001 From: Keith Busch Date: Fri, 28 Aug 2015 10:19:38 -0600 Subject: [PATCH] Fix unsigned integers Reported that using valid 32 bit integers causes errors do to type signedness. Signed-off-by: Keith Busch --- src/argconfig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) { -- 2.50.1