[PATCH 4/7] qemuBuildSoundCommandLine: reduce scope of codecstr

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

 



Copy the declaration into the smallest blocks it's used in
and mark it as VIR_AUTOFREE.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 06ac184f0d..bd6beb0e52 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4471,9 +4471,9 @@ qemuBuildSoundCommandLine(virCommandPtr cmd,
             virCommandAddArg(cmd, str);
             if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
                 sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
-                char *codecstr = NULL;
 
                 for (j = 0; j < sound->ncodecs; j++) {
+                    VIR_AUTOFREE(char *) codecstr = NULL;
                     virCommandAddArg(cmd, "-device");
                     if (!(codecstr =
                           qemuBuildSoundCodecStr(sound, sound->codecs[j],
@@ -4482,9 +4482,9 @@ qemuBuildSoundCommandLine(virCommandPtr cmd,
 
                     }
                     virCommandAddArg(cmd, codecstr);
-                    VIR_FREE(codecstr);
                 }
                 if (j == 0) {
+                    VIR_AUTOFREE(char *) codecstr = NULL;
                     virDomainSoundCodecDef codec = {
                         VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
                         0
@@ -4497,7 +4497,6 @@ qemuBuildSoundCommandLine(virCommandPtr cmd,
 
                     }
                     virCommandAddArg(cmd, codecstr);
-                    VIR_FREE(codecstr);
                 }
             }
         }
-- 
2.19.2

--
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