From: Peter Krempa Date: Thu, 29 Mar 2018 18:34:57 +0000 (+0200) Subject: qemu: agent: Avoid unnecessary JSON object type check X-Git-Tag: v4.3.0-rc1~454 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91813b8783517fef002c6616104177891022bad2;p=thirdparty%2Flibvirt.git qemu: agent: Avoid unnecessary JSON object type check Use virJSONValueObjectGetArray instead of virJSONValueObjectGet so that it's not necessary to check whether it's an array. Signed-off-by: Peter Krempa --- 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)