From: Oleg Latin Date: Wed, 24 Nov 2021 17:17:04 +0000 (+0300) Subject: parse: handle comma-separated options X-Git-Tag: fio-3.29~29^2 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=ff236b51e8b92470eaed72a3a3b1fbf45d786645;hp=1d08bfb018e600cc47f122fb78c02bf74b84dee8 parse: handle comma-separated options Option parser does not properly handle 'sync_file_range' option with multiple flags. It was due to opt_len() only use ':' as delimiter, so only last flag in comma-separated list have effect. This patch adds ',' as a delimiter. All flags are correctly ORed now. Fixes: https://github.com/axboe/fio/issues/1234 Signed-off-by: Oleg Latin --- diff --git a/parse.c b/parse.c index 45f4f2d3..d086ee48 100644 --- a/parse.c +++ b/parse.c @@ -477,13 +477,17 @@ static int check_int(const char *p, int *val) static size_t opt_len(const char *str) { + char delimiter[] = {',', ':'}; char *postfix; + unsigned int i; - postfix = strchr(str, ':'); - if (!postfix) - return strlen(str); + for (i = 0; i < FIO_ARRAY_SIZE(delimiter); i++) { + postfix = strchr(str, delimiter[i]); + if (postfix) + return (int)(postfix - str); + } - return (int)(postfix - str); + return strlen(str); } static int str_match_len(const struct value_pair *vp, const char *str)