提交 53655ba2 编写于 作者: F Fabiano Fidêncio

locking: Use g_autofree in virLockDaemonExecRestartStatePath()

Together with the change, let's also simplify the function and get rid
of the goto.
Signed-off-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 bfdb3bb1
...@@ -820,29 +820,23 @@ virLockDaemonExecRestartStatePath(bool privileged, ...@@ -820,29 +820,23 @@ virLockDaemonExecRestartStatePath(bool privileged,
if (privileged) { if (privileged) {
*state_file = g_strdup(RUNSTATEDIR "/virtlockd-restart-exec.json"); *state_file = g_strdup(RUNSTATEDIR "/virtlockd-restart-exec.json");
} else { } else {
char *rundir = NULL; g_autofree char *rundir = NULL;
mode_t old_umask; mode_t old_umask;
if (!(rundir = virGetUserRuntimeDirectory())) if (!(rundir = virGetUserRuntimeDirectory()))
goto error; return -1;
old_umask = umask(077); old_umask = umask(077);
if (virFileMakePath(rundir) < 0) { if (virFileMakePath(rundir) < 0) {
umask(old_umask); umask(old_umask);
VIR_FREE(rundir); return -1;
goto error;
} }
umask(old_umask); umask(old_umask);
*state_file = g_strdup_printf("%s/virtlockd-restart-exec.json", rundir); *state_file = g_strdup_printf("%s/virtlockd-restart-exec.json", rundir);
VIR_FREE(rundir);
} }
return 0; return 0;
error:
return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册