diff options
author | Fabiano Fidêncio <fidencio@redhat.com> | 2019-12-19 10:11:49 +0100 |
---|---|---|
committer | Fabiano Fidêncio <fidencio@redhat.com> | 2019-12-20 09:38:43 +0100 |
commit | e09f723bf11d8bb771484f60663e5a1d830997e1 (patch) | |
tree | 62964bc6ff94dd9c5be619f3002f228f5aeb1ca8 /src/util | |
parent | aa88882c41fbdbf16a4836ac9bdf62453965c598 (diff) | |
download | libvirt-e09f723bf11d8bb771484f60663e5a1d830997e1.tar.gz |
util: Use g_autofree in virLogSetDefaultOutputToFile()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/virlog.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/util/virlog.c b/src/util/virlog.c index d45e2dd316..10639d7328 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -173,8 +173,7 @@ virLogSetDefaultOutputToJournald(void) static int virLogSetDefaultOutputToFile(const char *binary, bool privileged) { - int ret = -1; - char *logdir = NULL; + g_autofree char *logdir = NULL; mode_t old_umask; if (privileged) { @@ -182,12 +181,12 @@ virLogSetDefaultOutputToFile(const char *binary, bool privileged) virLogDefaultPriority, LOCALSTATEDIR, binary); } else { if (!(logdir = virGetUserCacheDirectory())) - goto cleanup; + return -1; old_umask = umask(077); if (virFileMakePath(logdir) < 0) { umask(old_umask); - goto cleanup; + return -1; } umask(old_umask); @@ -195,10 +194,7 @@ virLogSetDefaultOutputToFile(const char *binary, bool privileged) virLogDefaultPriority, logdir, binary); } - ret = 0; - cleanup: - VIR_FREE(logdir); - return ret; + return 0; } |