From 7676a1c25fcdacfe27d84a0f86fe68077b7de79a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 25 Sep 2018 20:15:05 -0600 Subject: [PATCH] parse: fix negative FIO_OPT_INT too-large check 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 --- parse.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parse.c b/parse.c index 84d112dc..a7d4516e 100644 --- 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; } -- 2.25.1