Commit 12ec6c65 authored by James Zern's avatar James Zern

args.c: add some explicit casts

values are range checked before returning; quiets -Wshorten-64-to-32
warnings

ported from libvpx:
d772d5570 args.c: add some explicit casts

Change-Id: I806af11b2aaf6760c7ab234a2fe2fdf40e7bece7
parent d92d6031
......@@ -126,7 +126,7 @@ unsigned int arg_parse_uint(const struct arg *arg) {
rawval = strtoul(arg->val, &endptr, 10);
if (arg->val[0] != '\0' && endptr[0] == '\0') {
if (rawval <= UINT_MAX) return rawval;
if (rawval <= UINT_MAX) return (unsigned int)rawval;
die("Option %s: Value %ld out of range for unsigned int\n", arg->name,
rawval);
......@@ -143,7 +143,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);
......@@ -167,7 +167,7 @@ struct aom_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);
......@@ -179,7 +179,7 @@ struct aom_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);
......@@ -199,7 +199,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 */
......
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