]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
locking: Use g_autofree in virLockDaemonExecRestartStatePath()
authorFabiano Fidêncio <fidencio@redhat.com>
Thu, 19 Dec 2019 09:37:20 +0000 (10:37 +0100)
committerFabiano Fidêncio <fidencio@redhat.com>
Fri, 20 Dec 2019 08:38:43 +0000 (09:38 +0100)
Together with the change, let's also simplify the function and get rid
of the goto.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/locking/lock_daemon.c

index 9bcd36a8691ba05d10ade0d9300b994c733021b4..7c89adf077fde0a7c9e178d3f960687cb956ff11 100644 (file)
@@ -820,29 +820,23 @@ virLockDaemonExecRestartStatePath(bool privileged,
     if (privileged) {
         *state_file = g_strdup(RUNSTATEDIR "/virtlockd-restart-exec.json");
     } else {
-        char *rundir = NULL;
+        g_autofree char *rundir = NULL;
         mode_t old_umask;
 
         if (!(rundir = virGetUserRuntimeDirectory()))
-            goto error;
+            return -1;
 
         old_umask = umask(077);
         if (virFileMakePath(rundir) < 0) {
             umask(old_umask);
-            VIR_FREE(rundir);
-            goto error;
+            return -1;
         }
         umask(old_umask);
 
         *state_file = g_strdup_printf("%s/virtlockd-restart-exec.json", rundir);
-
-        VIR_FREE(rundir);
     }
 
     return 0;
-
- error:
-    return -1;
 }