Browse code

cmdutils: add OPT_INT check in parse_number_or_die()

Check that the value passed for an OPT_INT option is an int, fail
otherwise.

Stefano Sabatini authored on 2011/04/16 20:41:53
Showing 1 changed files
... ...
@@ -106,6 +106,8 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do
106 106
         error= "The value for %s was %s which is not within %f - %f\n";
107 107
     else if(type == OPT_INT64 && (int64_t)d != d)
108 108
         error= "Expected int64 for %s but found %s\n";
109
+    else if (type == OPT_INT && (int)d != d)
110
+        error= "Expected int for %s but found %s\n";
109 111
     else
110 112
         return d;
111 113
     fprintf(stderr, error, context, numstr, min, max);