From d772d55704dad4e5c15c296097ceb2d6b408f572 Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 4 Aug 2016 23:23:00 -0700 Subject: [PATCH] args.c: add some explicit casts values are range checked before returning; quiets -Wshorten-64-to-32 warnings Change-Id: I806af11b2aaf6760c7ab234a2fe2fdf40e7bece7 --- args.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/args.c b/args.c index 51c0fb9c4..bd1ede038 100644 --- a/args.c +++ b/args.c @@ -124,7 +124,7 @@ unsigned int arg_parse_uint(const struct arg *arg) { rawval = strtol(arg->val, &endptr, 10); if (arg->val[0] != '\0' && endptr[0] == '\0') { - if (rawval >= 0 && rawval <= UINT_MAX) return rawval; + if (rawval >= 0 && rawval <= UINT_MAX) return (unsigned int)rawval; die("Option %s: Value %ld out of range for unsigned int\n", arg->name, rawval); @@ -141,7 +141,7 @@ int arg_parse_int(const struct arg *arg) { rawval = strtol(arg->val, &endptr, 10); if (arg->val[0] != '\0' && endptr[0] == '\0') { - if (rawval >= INT_MIN && rawval <= INT_MAX) return rawval; + if (rawval >= INT_MIN && rawval <= INT_MAX) return (int)rawval; die("Option %s: Value %ld out of range for signed int\n", arg->name, rawval); @@ -165,7 +165,7 @@ struct vpx_rational arg_parse_rational(const struct arg *arg) { if (arg->val[0] != '\0' && endptr[0] == '/') { if (rawval >= INT_MIN && rawval <= INT_MAX) - rat.num = rawval; + rat.num = (int)rawval; else die("Option %s: Value %ld out of range for signed int\n", arg->name, rawval); @@ -177,7 +177,7 @@ struct vpx_rational arg_parse_rational(const struct arg *arg) { if (arg->val[0] != '\0' && endptr[0] == '\0') { if (rawval >= INT_MIN && rawval <= INT_MAX) - rat.den = rawval; + rat.den = (int)rawval; else die("Option %s: Value %ld out of range for signed int\n", arg->name, rawval); @@ -197,7 +197,7 @@ int arg_parse_enum(const struct arg *arg) { if (arg->val[0] != '\0' && endptr[0] == '\0') { /* Got a raw value, make sure it's valid */ for (listptr = arg->def->enums; listptr->name; listptr++) - if (listptr->val == rawval) return rawval; + if (listptr->val == rawval) return (int)rawval; } /* Next see if it can be parsed as a string */