[PATCH 1/3] qemuMonitorJSONQueryRxFilter: Validate qemu reply prior parsing it

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

 



Usually, the flow in this area of the code is as follows:

qemuMonitorJSONMakeCommand()
qemuMonitorJSONCommand()
qemuMonitorJSONCheckError()
parseReply()

But in this function, for some reasons, the last two steps were
swapped. This makes no sense.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_monitor_json.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a48a263..81970b9 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3220,9 +3220,6 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg,
     size_t i;
     virNetDevRxFilterPtr fil = virNetDevRxFilterNew();
 
-    if (!fil)
-        goto cleanup;
-
     if (!(returnArray = virJSONValueObjectGetArray(msg, "return"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-rx-filter reply was missing return data"));
@@ -3401,14 +3398,14 @@ qemuMonitorJSONQueryRxFilter(qemuMonitorPtr mon, const char *alias,
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
         goto cleanup;
 
+    if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+        goto cleanup;
+
     if (qemuMonitorJSONQueryRxFilterParse(reply, filter) < 0)
         goto cleanup;
 
     ret = 0;
  cleanup:
-    if (ret == 0)
-        ret = qemuMonitorJSONCheckError(cmd, reply);
-
     if (ret < 0) {
         virNetDevRxFilterFree(*filter);
         *filter = NULL;
-- 
2.8.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]