parse: fix negative FIO_OPT_INT too-large check
authorJens Axboe <axboe@kernel.dk>
Wed, 26 Sep 2018 02:15:05 +0000 (20:15 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 26 Sep 2018 02:15:05 +0000 (20:15 -0600)
If we have an option, like nice, that has a minval that is negative,
then we need to ensure we cast properly for the check.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
parse.c

diff --git a/parse.c b/parse.c
index 84d112dceb9efc3d433e13b39693aee3de46a6e1..a7d4516e47028b9373c7012bd8b56877c8f493cf 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -512,8 +512,11 @@ static bool val_too_large(const struct fio_option *o, unsigned long long val,
        if (!o->maxval)
                return false;
 
-       if (is_uint)
+       if (is_uint) {
+               if ((int) val < 0)
+                       return (int) val > (int) o->maxval;
                return (unsigned int) val > o->maxval;
+       }
 
        return val > o->maxval;
 }