From: Peter Krempa Date: Wed, 21 Mar 2018 15:51:29 +0000 (+0100) Subject: qemu: qapi: Return correct entry in virQEMUQAPISchemaTraverse X-Git-Tag: v4.2.0-rc1~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3283950057cf1252c9358a99c8a5f2b8bac9631f;p=thirdparty%2Flibvirt.git qemu: qapi: Return correct entry in virQEMUQAPISchemaTraverse virQEMUQAPISchemaTraverse would return previous-to-last queried item on a query. It would not be a problem if checking if the given path exists since error reporting works properly but if the caller is interested in the result, it would be wrong. Signed-off-by: Peter Krempa --- diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c index 3cb0cf0139..d277ef1bde 100644 --- a/src/qemu/qemu_qapi.c +++ b/src/qemu/qemu_qapi.c @@ -76,7 +76,7 @@ virQEMUQAPISchemaTraverse(const char *baseName, virJSONValuePtr base; const char *metatype; - do { + while (1) { if (!(base = virHashLookup(schema, baseName))) return NULL; @@ -114,7 +114,7 @@ virQEMUQAPISchemaTraverse(const char *baseName, } query++; - } while (*query); + } return base; }