[libvirt PATCH 09/14] lxc: refactor virLXCProcessBuildControllerCmd

Ján Tomko jtomko at redhat.com
Mon Dec 13 13:59:38 UTC 2021


Use automatic cleanup and remove the labels.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 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);
 }
 
 
-- 
2.31.1




More information about the libvir-list mailing list