From 1e6b81cdec5de1508c98d1fbd28ce86273ffd05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 10 Dec 2021 14:49:23 +0100 Subject: [PATCH] lxc: refactor virLXCProcessBuildControllerCmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use automatic cleanup and remove the labels. Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- src/lxc/lxc_process.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 625208c86b..118d9cbdcc 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -935,7 +935,7 @@ virLXCProcessBuildControllerCmd(virLXCDriver *driver, size_t i; g_autofree char *filterstr = NULL; g_autofree char *outputstr = NULL; - virCommand *cmd; + g_autoptr(virCommand) cmd = NULL; g_autoptr(virLXCDriverConfig) cfg = virLXCDriverGetConfig(driver); cmd = virCommandNew(vm->def->emulator); @@ -955,7 +955,7 @@ virLXCProcessBuildControllerCmd(virLXCDriver *driver, if (cfg->log_libvirtd) { if (virLogGetNbOutputs() > 0) { if (!(outputstr = virLogGetOutputs())) - goto error; + return NULL; virCommandAddEnvPair(cmd, "LIBVIRT_LOG_OUTPUTS", outputstr); } @@ -1007,12 +1007,7 @@ virLXCProcessBuildControllerCmd(virLXCDriver *driver, * write the live domain status XML with the PID */ virCommandRequireHandshake(cmd); - cleanup: - return cmd; - error: - virCommandFree(cmd); - cmd = NULL; - goto cleanup; + return g_steal_pointer(&cmd); }