args.c: add some explicit casts
values are range checked before returning; quiets -Wshorten-64-to-32 warnings Change-Id: I806af11b2aaf6760c7ab234a2fe2fdf40e7bece7
This commit is contained in:
parent
c79665d0ad
commit
d772d55704
10
args.c
10
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user