Commit 3a57ce44 authored by Johann's avatar Johann

Cast strto[u]l down

Change-Id: I945b2f8754cf484a08e5ba511cfd2d4a44181b08
parent 348cff04
......@@ -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;
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment