[PATCH 1/4] tests: Refactor cleanup in qemuMonitorTestProcessCommandVerbatim

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

 



Use VIR_AUTOFREE and get rid of the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/qemumonitortestutils.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 4a108c382d..1cd35830af 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -688,8 +688,8 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPtr test,
                                       const char *cmdstr)
 {
     struct qemuMonitorTestHandlerData *data = item->opaque;
-    char *reformatted = NULL;
-    char *errmsg = NULL;
+    VIR_AUTOFREE(char *) reformatted = NULL;
+    VIR_AUTOFREE(char *) errmsg = NULL;
     int ret = -1;

     /* JSON strings will be reformatted to simplify checking */
@@ -705,7 +705,7 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPtr test,
     } else {
         if (data->cmderr) {
             if (virAsprintf(&errmsg, "%s: %s", data->cmderr, cmdstr) < 0)
-                goto cleanup;
+                return -1;

             ret = qemuMonitorTestAddErrorResponse(test, errmsg);
         } else {
@@ -715,9 +715,6 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPtr test,
         }
     }

- cleanup:
-    VIR_FREE(errmsg);
-    VIR_FREE(reformatted);
     return ret;
 }

-- 
2.21.0

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

  Powered by Linux