X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=parse.c;h=3e94c7d577746e251845245ce4fad018b76829ef;hb=71deafc693ad77947f5c3f72e7247eefcb97bd63;hp=7912212ecda47594bac999e8abbecdacaf81aeb1;hpb=209e10374bb57565f0a61286d1ed8effd50fa95c;p=fio.git diff --git a/parse.c b/parse.c index 7912212e..3e94c7d5 100644 --- a/parse.c +++ b/parse.c @@ -17,6 +17,7 @@ #include "options.h" #include "minmax.h" #include "lib/ieee754.h" +#include "lib/pow2.h" #ifdef CONFIG_ARITHMETIC #include "y.tab.h" @@ -521,6 +522,10 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (ret) break; + if (o->pow2 && !is_power_of_2(ull)) { + log_err("%s: must be a power-of-2\n", o->name); + return 1; + } if (o->maxval && ull > o->maxval) { log_err("max value out of range: %llu" @@ -1056,6 +1061,19 @@ int string_distance(const char *s1, const char *s2) return i; } +/* + * Make a guess of whether the distance from 's1' is significant enough + * to warrant printing the guess. We set this to a 1/2 match. + */ +int string_distance_ok(const char *opt, int distance) +{ + size_t len; + + len = strlen(opt); + len = (len + 1) / 2; + return distance <= len; +} + static struct fio_option *find_child(struct fio_option *options, struct fio_option *o) {