[libvirt] [PATCH 05/21] qemu: qapi: Return schema entry via argument in virQEMUQAPISchemaTraverse
Ján Tomko
jtomko at redhat.com
Thu Apr 25 11:46:14 UTC 2019
On Mon, Apr 15, 2019 at 06:01:58PM +0200, Peter Krempa wrote:
>To allow for boolean query string, let's return the queried schema entry
>via argument rather than a return value.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/qemu/qemu_qapi.c | 30 +++++++++++++++++-------------
> 1 file changed, 17 insertions(+), 13 deletions(-)
>
>diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c
>index de663d4408..7155f2d084 100644
>--- a/src/qemu/qemu_qapi.c
>+++ b/src/qemu/qemu_qapi.c
>@@ -101,10 +101,11 @@ virQEMUQAPISchemaObjectGetType(const char *field,
> }
>
>
>-static virJSONValuePtr
>+static int
> virQEMUQAPISchemaTraverse(const char *baseName,
> char **query,
>- virHashTablePtr schema)
>+ virHashTablePtr schema,
>+ virJSONValuePtr *type)
> {
> virJSONValuePtr base;
> virJSONValuePtr obj;
>@@ -114,18 +115,20 @@ virQEMUQAPISchemaTraverse(const char *baseName,
>
Adding
*type = NULL;
here would make sure we consistently set the return value.
> while (1) {
> if (!(base = virHashLookup(schema, baseName)))
>- return NULL;
>+ return 0;
>
>- if (!*query)
>- return base;
>+ if (!*query) {
>+ *type = base;
>+ return 0;
>+ }
>
> if (!(metatype = virJSONValueObjectGetString(base, "meta-type")))
>- return NULL;
>+ return 0;
>
> /* flatten arrays by default */
> if (STREQ(metatype, "array")) {
> if (!(baseName = virJSONValueObjectGetString(base, "element-type")))
>- return NULL;
>+ return 0;
>
> continue;
> } else if (STREQ(metatype, "object")) {
Reviewed-by: Ján Tomko <jtomko at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190425/43c5bd98/attachment-0001.sig>
More information about the libvir-list
mailing list