]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: qemuMonitorTestAddErrorResponse: use VIR_AUTOFREE
authorJán Tomko <jtomko@redhat.com>
Sat, 15 Jun 2019 10:06:36 +0000 (12:06 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 17 Jun 2019 14:12:57 +0000 (16:12 +0200)
Use VIR_AUTOFREE.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
tests/qemumonitortestutils.c

index 86883e682b3e3bbf0aae470e7e962f0d269cae78..bb30bed51e432449f6b31c46995eed910c162a04 100644 (file)
@@ -124,11 +124,10 @@ qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test,
                                 const char *usermsg)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    char *escapemsg = NULL;
-    char *jsonmsg = NULL;
+    VIR_AUTOFREE(char *) escapemsg = NULL;
+    VIR_AUTOFREE(char *) jsonmsg = NULL;
     const char *monmsg = NULL;
     char *tmp;
-    int ret = -1;
 
     if (!usermsg)
         usermsg = "unexpected command";
@@ -136,7 +135,7 @@ qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test,
     if (test->json || test->agent) {
         virBufferEscape(&buf, '\\', "\"", "%s", usermsg);
         if (virBufferCheckError(&buf) < 0)
-            goto error;
+            return -1;
         escapemsg = virBufferContentAndReset(&buf);
 
         /* replace newline/carriage return with space */
@@ -153,19 +152,14 @@ qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test,
                                   " { \"desc\": \"%s\", "
                                   "   \"class\": \"UnexpectedCommand\" } }",
                                   escapemsg) < 0)
-            goto error;
+            return -1;
 
         monmsg = jsonmsg;
     } else {
         monmsg = usermsg;
     }
 
-    ret = qemuMonitorTestAddResponse(test, monmsg);
-
- error:
-    VIR_FREE(escapemsg);
-    VIR_FREE(jsonmsg);
-    return ret;
+    return qemuMonitorTestAddResponse(test, monmsg);
 }