From 6bb8edafd96668fb8bab90506e35f74851599d7f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Tomko?= Date: Mon, 26 Aug 2019 22:23:50 +0200 Subject: [PATCH] qemuBuildSoundCommandLine: reduce scope of codecstr MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Copy the declaration into the smallest blocks it's used in and mark it as VIR_AUTOFREE. Signed-off-by: Ján Tomko Reviewed-by: Cole Robinson --- 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 0874cfe165..4ed3419b07 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4478,9 +4478,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], @@ -4489,9 +4489,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 @@ -4504,7 +4504,6 @@ qemuBuildSoundCommandLine(virCommandPtr cmd, } virCommandAddArg(cmd, codecstr); - VIR_FREE(codecstr); } } } -- 2.47.2