]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: agent: Avoid unnecessary JSON object type check
authorPeter Krempa <pkrempa@redhat.com>
Thu, 29 Mar 2018 18:34:57 +0000 (20:34 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Apr 2018 11:34:33 +0000 (13:34 +0200)
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

index b99d5b10e331387853925faeeb39243a50e88c8a..dfec57d992f8a50a34302b671f20bcd3271778b0 100644 (file)
@@ -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)