[PATCH 13/42] util: Use g_autofree on virLogSetDefaultOutputToFile()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 src/util/virlog.c | 12 ++++--------
 1 file 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;
 }
 
 
-- 
2.24.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux