[libvirt] [PATCH 34/42] logging: Use g_autofree on virLogDaemonExecRestartStatePath()

Fabiano Fidêncio posted 42 patches 6 years, 1 month ago
[libvirt] [PATCH 34/42] logging: Use g_autofree on virLogDaemonExecRestartStatePath()
Posted by Fabiano Fidêncio 6 years, 1 month ago
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>
---
 src/logging/log_daemon.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index d41d9caba9..3fee2b3b57 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -612,29 +612,23 @@ virLogDaemonExecRestartStatePath(bool privileged,
     if (privileged) {
         *state_file = g_strdup(RUNSTATEDIR "/virtlogd-restart-exec.json");
     } 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) {
             umask(old_umask);
-            VIR_FREE(rundir);
-            goto error;
+            return -1;
         }
         umask(old_umask);
 
         *state_file = g_strdup_printf("%s/virtlogd-restart-exec.json", 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
Re: [libvirt] [PATCH 34/42] logging: Use g_autofree on virLogDaemonExecRestartStatePath()
Posted by Ján Tomko 6 years, 1 month ago
s/on/in/

On Thu, Dec 19, 2019 at 11:04:39AM +0100, Fabiano Fidêncio wrote:
>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>
>---
> src/logging/log_daemon.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

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