Fix parser bug
authorJoel Becker <Joel.Becker@oracle.com>
Wed, 28 Feb 2007 08:38:39 +0000 (09:38 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 28 Feb 2007 08:38:39 +0000 (09:38 +0100)
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 <jens.axboe@oracle.com>
parse.c

diff --git a/parse.c b/parse.c
index 0e8cd5ff1454f53309cc260019d7b3d27e898a7e..11d745f15649ddd40e2aab2baca52582802ab2b3 100644 (file)
--- 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];