Use separate variables for the chardev and the device.

Signed-off-by: Ján Tomko <jto...@redhat.com>
---
 src/qemu/qemu_command.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 298a1c3fea..67de0fc35e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6022,7 +6022,8 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
         VIR_AUTOPTR(virJSONValue) props = NULL;
         virBuffer buf = VIR_BUFFER_INITIALIZER;
         virDomainRNGDefPtr rng = def->rngs[i];
-        char *tmp;
+        VIR_AUTOFREE(char *) chardev = NULL;
+        VIR_AUTOFREE(char *) devstr = NULL;
         int rc;
 
         if (!rng->info.alias) {
@@ -6033,14 +6034,12 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
 
         /* possibly add character device for backend */
         if (qemuBuildRNGBackendChrdevStr(logManager, secManager, cmd, cfg, def,
-                                         rng, qemuCaps, &tmp,
+                                         rng, qemuCaps, &chardev,
                                          chardevStdioLogd) < 0)
             return -1;
 
-        if (tmp) {
-            virCommandAddArgList(cmd, "-chardev", tmp, NULL);
-            VIR_FREE(tmp);
-        }
+        if (chardev)
+            virCommandAddArgList(cmd, "-chardev", chardev, NULL);
 
         if (qemuBuildRNGBackendProps(rng, qemuCaps, &props) < 0)
             return -1;
@@ -6057,10 +6056,9 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
         if (qemuCommandAddExtDevice(cmd, &rng->info) < 0)
             return -1;
 
-        if (!(tmp = qemuBuildRNGDevStr(def, rng, qemuCaps)))
+        if (!(devstr = qemuBuildRNGDevStr(def, rng, qemuCaps)))
             return -1;
-        virCommandAddArgList(cmd, "-device", tmp, NULL);
-        VIR_FREE(tmp);
+        virCommandAddArgList(cmd, "-device", devstr, NULL);
     }
 
     return 0;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to