Skip to content

Commit

Permalink
Cast strto[u]l down
Browse files Browse the repository at this point in the history
Change-Id: I945b2f8754cf484a08e5ba511cfd2d4a44181b08
  • Loading branch information
Johann committed Sep 27, 2016
1 parent 348cff0 commit 3a57ce4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions args.c
Expand Up @@ -122,7 +122,7 @@ unsigned int arg_parse_uint(const struct arg *arg) {
uint32_t rawval;
char *endptr;

rawval = strtoul(arg->val, &endptr, 10);
rawval = (uint32_t)strtoul(arg->val, &endptr, 10);

if (arg->val[0] != '\0' && endptr[0] == '\0') {
if (rawval <= UINT_MAX) return rawval;
Expand All @@ -139,7 +139,7 @@ int arg_parse_int(const struct arg *arg) {
int32_t rawval;
char *endptr;

rawval = strtol(arg->val, &endptr, 10);
rawval = (int32_t)strtol(arg->val, &endptr, 10);

if (arg->val[0] != '\0' && endptr[0] == '\0') {
if (rawval >= INT_MIN && rawval <= INT_MAX) return (int)rawval;
Expand Down

0 comments on commit 3a57ce4

Please sign in to comment.