]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lxc: refactor virLXCProcessBuildControllerCmd
authorJán Tomko <jtomko@redhat.com>
Fri, 10 Dec 2021 13:49:23 +0000 (14:49 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 13 Dec 2021 17:20:46 +0000 (18:20 +0100)
Use automatic cleanup and remove the labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/lxc/lxc_process.c

index 625208c86bae68a57afb1cc0b85b1062359ba828..118d9cbdccb6cc9a9a14e878dc86c4eef4ad6c8e 100644 (file)
@@ -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);
 }