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

Signed-off-by: Fabiano Fidêncio <fiden...@redhat.com>
---
 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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to