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

Peter Krempa posted 11 patches 7 years, 1 month ago
[libvirt] [PATCH 06/11] qemu: qapi: Return correct entry in virQEMUQapiSchemaTraverse
Posted by Peter Krempa 7 years, 1 month ago
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@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 06/11] qemu: qapi: Return correct entry in virQEMUQapiSchemaTraverse
Posted by Ján Tomko 7 years, 1 month ago
On Thu, Mar 22, 2018 at 07:31:43PM +0100, Peter Krempa wrote:
>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

s/interrested/interested/

>the result, it would be wrong.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_qapi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>

ACK

Jan
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list