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 <pkrempa@redhat.com>
This commit is contained in:
Peter Krempa 2018-03-29 20:34:57 +02:00
parent d78a91afee
commit 91813b8783

View File

@ -1502,18 +1502,12 @@ qemuAgentGetVCPUs(qemuAgentPtr mon,
VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
goto cleanup; goto cleanup;
if (!(data = virJSONValueObjectGet(reply, "return"))) { if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("guest-get-vcpus reply was missing return data")); _("guest-get-vcpus reply was missing return data"));
goto cleanup; 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); ndata = virJSONValueArraySize(data);
if (VIR_ALLOC_N(*info, ndata) < 0) if (VIR_ALLOC_N(*info, ndata) < 0)