[PATCH 06/12] tests: qemuMonitorReportError: use tmp variable properly

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

 



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@xxxxxxxxxx>
---
 tests/qemumonitortestutils.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index e2144923f0..a4fe397be6 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -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)
-- 
2.20.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]

  Powered by Linux