net: add basic ping/pong type workload support
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index c8b7545a27b85ee3649d95798940b5746ae3576b..13783fa6d60c06f1df0fb82dcaf18ac2636750ae 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -14,6 +14,7 @@
 #include "parse.h"
 #include "debug.h"
 #include "options.h"
+#include "minmax.h"
 
 static struct fio_option *fio_options;
 extern unsigned int fio_get_kb_base(void *);
@@ -220,7 +221,7 @@ static unsigned long long get_mult_bytes(const char *str, int len, void *data,
 /*
  * Convert string into a floating number. Return 1 for success and 0 otherwise.
  */
-static int str_to_float(const char *str, double *val)
+int str_to_float(const char *str, double *val)
 {
        return (1 == sscanf(str, "%lf", val));
 }
@@ -360,7 +361,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
        long long ull, *ullp;
        long ul1, ul2;
        double uf;
-       char **cp;
+       char **cp = NULL;
        int ret = 0, is_time = 0;
        const struct value_pair *vp;
        struct value_pair posval[PARSE_MAX_VP];
@@ -430,13 +431,13 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                        break;
 
                if (o->maxval && ull > o->maxval) {
-                       log_err("max value out of range: %lld"
-                                       " (%d max)\n", ull, o->maxval);
+                       log_err("max value out of range: %llu"
+                                       " (%u max)\n", ull, o->maxval);
                        return 1;
                }
                if (o->minval && ull < o->minval) {
-                       log_err("min value out of range: %lld"
-                                       " (%d min)\n", ull, o->minval);
+                       log_err("min value out of range: %llu"
+                                       " (%u min)\n", ull, o->minval);
                        return 1;
                }
 
@@ -505,7 +506,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                                        o->maxlen);
                        return 1;
                }
-               if(!str_to_float(ptr, &uf)){
+               if (!str_to_float(ptr, &uf)){
                        log_err("not a floating point value: %s\n", ptr);
                        return 1;
                }
@@ -535,8 +536,6 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                                cp = td_var(data, o->off1);
 
                        *cp = strdup(ptr);
-               } else {
-                       cp = NULL;
                }
 
                if (fn)
@@ -1087,6 +1086,10 @@ void option_init(struct fio_option *o)
                o->minval = 0;
                o->maxval = 1;
        }
+       if (o->type == FIO_OPT_INT) {
+               if (!o->maxval)
+                       o->maxval = UINT_MAX;
+       }
        if (o->type == FIO_OPT_FLOAT_LIST) {
                o->minfp = NAN;
                o->maxfp = NAN;