[libvirt] [PATCH 06/11] qemu: qapi: Return correct entry in virQEMUQapiSchemaTraverse

Peter Krempa pkrempa at redhat.com
Thu Mar 22 18:31:43 UTC 2018


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 interrested in
the result, it would be wrong.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_qapi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c
index e63896397f..c821e2eb55 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;
 }
-- 
2.16.2




More information about the libvir-list mailing list