From: Ján Tomko Date: Mon, 26 Aug 2019 20:23:50 +0000 (+0200) Subject: qemuBuildSoundCommandLine: reduce scope of codecstr X-Git-Tag: v5.8.0-rc1~157 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bb8edafd96668fb8bab90506e35f74851599d7f;p=thirdparty%2Flibvirt.git qemuBuildSoundCommandLine: reduce scope of codecstr 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 --- 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); } } }