]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Refactor cleanup in qemuMonitorTestProcessCommandVerbatim
authorPeter Krempa <pkrempa@redhat.com>
Fri, 7 Jun 2019 08:27:50 +0000 (10:27 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 7 Jun 2019 14:18:45 +0000 (16:18 +0200)
Use VIR_AUTOFREE and get rid of the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
tests/qemumonitortestutils.c

index 4a108c382d7a3ecfac7ede08d5373e9e64f869b7..1cd35830aff66003e02c640ae70b3804243a367c 100644 (file)
@@ -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;
 }