From 71dc58b8a48edee4b0a749d4723d622ffefde304 Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Wed, 28 Feb 2007 09:38:39 +0100 Subject: [PATCH] Fix parser bug If the option parser sees a ':', it automatically assumes that you meant a range. It will then try to parse the second half of the option. This isn't just my external: option, it happens to mem: as well. That is: 1) Option mem=mmaphuge:/dev/shm/foo 2) handle_option() notices the ':' and stores off ptr2. 3) __handle_option() corectly sees the option "mem" and maps "mmaphuge" to MEM_MMAPHUGE. It then calls str_mem_cb(), which stores off the "/dev/shm/foo" after the ':'. Still working great. 4) Control returns to handle_option(), which sees that ptr2 is non-NULL. It calls __handle_option() again, pointing to the string after the ':'. 5) __handle_option() prints an error, as "/dev/shm/foo" is not a known option. Fix it by breaking out early for the 2nd parse round if the option type is a string. Signed-off-by: Jens Axboe --- parse.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parse.c b/parse.c index 0e8cd5ff..11d745f1 100644 --- a/parse.c +++ b/parse.c @@ -197,6 +197,9 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, const struct value_pair *vp; int i; + if (!first) + break; + ret = 1; for (i = 0; i < PARSE_MAX_VP; i++) { vp = &o->posval[i]; -- 2.25.1