logging: Use g_autofree in virLogDaemonUnixSocketPaths()

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>
This commit is contained in:
Fabiano Fidêncio 2019-12-19 10:30:34 +01:00
parent 40449e44bc
commit 441c668b82

View File

@ -391,29 +391,23 @@ virLogDaemonUnixSocketPaths(bool privileged,
*sockfile = g_strdup(RUNSTATEDIR "/libvirt/virtlogd-sock"); *sockfile = g_strdup(RUNSTATEDIR "/libvirt/virtlogd-sock");
*adminSockfile = g_strdup(RUNSTATEDIR "/libvirt/virtlogd-admin-sock"); *adminSockfile = g_strdup(RUNSTATEDIR "/libvirt/virtlogd-admin-sock");
} 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);
*sockfile = g_strdup_printf("%s/virtlogd-sock", rundir); *sockfile = g_strdup_printf("%s/virtlogd-sock", rundir);
*adminSockfile = g_strdup_printf("%s/virtlogd-admin-sock", rundir); *adminSockfile = g_strdup_printf("%s/virtlogd-admin-sock", rundir);
VIR_FREE(rundir);
} }
return 0; return 0;
error:
return -1;
} }