[libvirt] [PATCH 4/9] qemu: agent: Avoid unnecessary JSON object type check

Peter Krempa posted 9 patches 7 years, 1 month ago
[libvirt] [PATCH 4/9] qemu: agent: Avoid unnecessary JSON object type check
Posted by Peter Krempa 7 years, 1 month ago
Use virJSONValueObjectGetArray instead of virJSONValueObjectGet so that
it's not necessary to check whether it's an array.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_agent.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index b99d5b10e3..dfec57d992 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1502,18 +1502,12 @@ qemuAgentGetVCPUs(qemuAgentPtr mon,
                          VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
         goto cleanup;

-    if (!(data = virJSONValueObjectGet(reply, "return"))) {
+    if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("guest-get-vcpus reply was missing return data"));
         goto cleanup;
     }

-    if (data->type != VIR_JSON_TYPE_ARRAY) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("guest-get-vcpus return information was not an array"));
-        goto cleanup;
-    }
-
     ndata = virJSONValueArraySize(data);

     if (VIR_ALLOC_N(*info, ndata) < 0)
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/9] qemu: agent: Avoid unnecessary JSON object type check
Posted by Ján Tomko 7 years, 1 month ago
On Fri, Mar 30, 2018 at 12:59:11PM +0200, Peter Krempa wrote:
>Use virJSONValueObjectGetArray instead of virJSONValueObjectGet so that
>it's not necessary to check whether it's an array.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_agent.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>

ACK

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