]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: qemuMonitorReportError: use tmp variable properly
authorJán Tomko <jtomko@redhat.com>
Sat, 15 Jun 2019 09:58:32 +0000 (11:58 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 17 Jun 2019 14:12:57 +0000 (16:12 +0200)
There is no obvious benefit in putting the escaped message
back into msg while tmp holds the original message.

Remove the assignment and use 'tmp' directly'.

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

index bb30bed51e432449f6b31c46995eed910c162a04..7d336e1aa7c4220227537db73f76fac955d759db 100644 (file)
@@ -213,16 +213,14 @@ qemuMonitorReportError(qemuMonitorTestPtr test, const char *errmsg, ...)
         goto cleanup;
 
     if (test->agent || test->json) {
-        char *tmp = msg;
-        msg = qemuMonitorEscapeArg(tmp);
-        VIR_FREE(tmp);
-        if (!msg)
+        VIR_AUTOFREE(char *) tmp = NULL;
+        if (!(tmp = qemuMonitorEscapeArg(msg)))
             goto cleanup;
 
         if (virAsprintf(&jsonmsg, "{ \"error\": "
                                   " { \"desc\": \"%s\", "
                                   "   \"class\": \"UnexpectedCommand\" } }",
-                                  msg) < 0)
+                                  tmp) < 0)
             goto cleanup;
     } else {
         if (virAsprintf(&jsonmsg, "error: '%s'", msg) < 0)