[libvirt PATCH 10/14] qemu: agent: use GetArray to remove a check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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 b314c610e7..8cd1aa6cb0 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2213,13 +2213,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;
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux