[libvirt] [PATCH 35/42] logging: Don't check the output of virGetUserRuntimeDirectory()

Fabiano Fidêncio posted 42 patches 6 years, 1 month ago
[libvirt] [PATCH 35/42] logging: Don't check the output of virGetUserRuntimeDirectory()
Posted by Fabiano Fidêncio 6 years, 1 month ago
virGetUserRuntimeDirectory() *never* *ever* returns NULL, making the
checks for it completely unnecessary.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
---
 src/logging/log_daemon.c  | 11 +++--------
 src/logging/log_manager.c |  3 +--
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 3fee2b3b57..488f3b459d 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -394,8 +394,7 @@ virLogDaemonUnixSocketPaths(bool privileged,
         g_autofree char *rundir = NULL;
         mode_t old_umask;
 
-        if (!(rundir = virGetUserRuntimeDirectory()))
-            return -1;
+        rundir = virGetUserRuntimeDirectory();
 
         old_umask = umask(077);
         if (virFileMakePath(rundir) < 0) {
@@ -615,8 +614,7 @@ virLogDaemonExecRestartStatePath(bool privileged,
         g_autofree char *rundir = NULL;
         mode_t old_umask;
 
-        if (!(rundir = virGetUserRuntimeDirectory()))
-            return -1;
+        rundir = virGetUserRuntimeDirectory();
 
         old_umask = umask(077);
         if (virFileMakePath(rundir) < 0) {
@@ -992,10 +990,7 @@ int main(int argc, char **argv) {
     if (privileged) {
         run_dir = g_strdup(RUNSTATEDIR "/libvirt");
     } else {
-        if (!(run_dir = virGetUserRuntimeDirectory())) {
-            VIR_ERROR(_("Can't determine user directory"));
-            goto cleanup;
-        }
+        run_dir = virGetUserRuntimeDirectory();
     }
 
     if (privileged)
diff --git a/src/logging/log_manager.c b/src/logging/log_manager.c
index 7a4f036240..6b66218116 100644
--- a/src/logging/log_manager.c
+++ b/src/logging/log_manager.c
@@ -49,8 +49,7 @@ virLogManagerDaemonPath(bool privileged)
     } else {
         g_autofree char *rundir = NULL;
 
-        if (!(rundir = virGetUserRuntimeDirectory()))
-            return NULL;
+        rundir = virGetUserRuntimeDirectory();
 
         path = g_strdup_printf("%s/virtlogd-sock", rundir);
     }
-- 
2.24.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 35/42] logging: Don't check the output of virGetUserRuntimeDirectory()
Posted by Ján Tomko 6 years, 1 month ago
On Thu, Dec 19, 2019 at 11:04:40AM +0100, Fabiano Fidêncio wrote:
>virGetUserRuntimeDirectory() *never* *ever* returns NULL, making the
>checks for it completely unnecessary.
>
>Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
>---
> src/logging/log_daemon.c  | 11 +++--------
> src/logging/log_manager.c |  3 +--
> 2 files changed, 4 insertions(+), 10 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