mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
qemu: agent: use GetArray to remove a check
The error check for ValueObjectGet("return") is redundant, qemuAgentCommand already checked for us that the reply contains a "return" object. It does not guarantee, that it is an array. Use virJSONValueObjectGetArray that combines getting the object with checking for its type and return the more helpful of the two error messages. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Neal Gompa <ngompa13@gmail.com>
This commit is contained in:
parent
67e744cb57
commit
9e48b02840
@ -2232,13 +2232,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent,
|
||||
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(ret_array = virJSONValueObjectGet(reply, "return"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("qemu agent didn't provide 'return' field"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!virJSONValueIsArray(ret_array)) {
|
||||
if (!(ret_array = virJSONValueObjectGetArray(reply, "return"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("qemu agent didn't return an array of interfaces"));
|
||||
goto cleanup;
|
||||
|
Loading…
Reference in New Issue
Block a user