Ensure that .minfp and .maxfp are respected for FIO_OPT_FLOAT_LIST
authorBart Van Assche <bart.vanassche@wdc.com>
Tue, 3 Apr 2018 18:23:11 +0000 (11:23 -0700)
committerBart Van Assche <bart.vanassche@wdc.com>
Wed, 4 Apr 2018 20:53:45 +0000 (13:53 -0700)
option_init() overwrites the .minfp and .maxfp members defined in
fio_options[] which is wrong. Remove the code that overwrites these two
members and change the convention for no FIO_OPT_FLOAT_LIST limits from
(minfp == DBL_MIN && maxfp == DBL_MAX) into (minfp != 0 || maxfp != 0).

Fixes: 833491908a1a ("stats: Add a function to report completion latency percentiles")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
parse.c

diff --git a/parse.c b/parse.c
index adeb63fff5866787a26872c9f199bb0c0ec6ae9b..deb4120fdc4d9f432a6e16dd8fd9507a0dadda5f 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -71,10 +71,11 @@ static void show_option_range(const struct fio_option *o,
                              size_t (*logger)(const char *format, ...))
 {
        if (o->type == FIO_OPT_FLOAT_LIST) {
-               if (o->minfp == DBL_MIN && o->maxfp == DBL_MAX)
+               if (!o->minfp && !o->maxfp)
                        return;
 
-               logger("%20s: min=%f", "range", o->minfp);
+               if (o->minfp != DBL_MIN)
+                       logger("%20s: min=%f", "range", o->minfp);
                if (o->maxfp != DBL_MAX)
                        logger(", max=%f", o->maxfp);
                logger("\n");
@@ -668,15 +669,17 @@ static int __handle_option(const struct fio_option *o, const char *ptr,
                        log_err("not a floating point value: %s\n", ptr);
                        return 1;
                }
-               if (uf > o->maxfp) {
-                       log_err("value out of range: %f"
-                               " (range max: %f)\n", uf, o->maxfp);
-                       return 1;
-               }
-               if (uf < o->minfp) {
-                       log_err("value out of range: %f"
-                               " (range min: %f)\n", uf, o->minfp);
-                       return 1;
+               if (o->minfp || o->maxfp) {
+                       if (uf > o->maxfp) {
+                               log_err("value out of range: %f"
+                                       " (range max: %f)\n", uf, o->maxfp);
+                               return 1;
+                       }
+                       if (uf < o->minfp) {
+                               log_err("value out of range: %f"
+                                       " (range min: %f)\n", uf, o->minfp);
+                               return 1;
+                       }
                }
 
                flp = td_var(data, o, o->off1);
@@ -1316,10 +1319,6 @@ static void option_init(struct fio_option *o)
                if (!o->maxval)
                        o->maxval = UINT_MAX;
        }
-       if (o->type == FIO_OPT_FLOAT_LIST) {
-               o->minfp = DBL_MIN;
-               o->maxfp = DBL_MAX;
-       }
        if (o->type == FIO_OPT_STR_SET && o->def && !o->no_warn_def) {
                log_err("Option %s: string set option with"
                                " default will always be true\n", o->name);