From 53655ba2c9cbc2213684c504f558d65b822223bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 19 Dec 2019 10:37:20 +0100 Subject: [PATCH] locking: Use g_autofree in virLockDaemonExecRestartStatePath() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Together with the change, let's also simplify the function and get rid of the goto. Signed-off-by: Fabiano Fidêncio Reviewed-by: Ján Tomko --- src/locking/lock_daemon.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 9bcd36a869..7c89adf077 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -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; }