[PATCH 37/42] locking: Use g_autofree on virLockDaemonUnixSocketPaths()

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

 



Together with the change, let's also simplify the function and get rid
of the goto.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 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 0d12a97231..9bcd36a869 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -449,29 +449,23 @@ virLockDaemonUnixSocketPaths(bool privileged,
         *sockfile = g_strdup(RUNSTATEDIR "/libvirt/virtlockd-sock");
         *adminSockfile = g_strdup(RUNSTATEDIR "/libvirt/virtlockd-admin-sock");
     } 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) {
-            VIR_FREE(rundir);
             umask(old_umask);
-            goto error;
+            return -1;
         }
         umask(old_umask);
 
         *sockfile = g_strdup_printf("%s/virtlockd-sock", rundir);
         *adminSockfile = g_strdup_printf("%s/virtlockd-admin-sock", rundir);
-
-        VIR_FREE(rundir);
     }
     return 0;
-
- error:
-    return -1;
 }
 
 
-- 
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