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

Fabiano Fidêncio posted 42 patches 6 years, 1 month ago
[libvirt] [PATCH 28/42] remote: 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/remote/remote_daemon.c | 8 +-------
 src/remote/remote_driver.c | 3 +--
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index b400b1dd10..5893492875 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -245,8 +245,7 @@ daemonUnixSocketPaths(struct daemonConfig *config,
         } else {
             mode_t old_umask;
 
-            if (!(rundir = virGetUserRuntimeDirectory()))
-                goto cleanup;
+            rundir = virGetUserRuntimeDirectory();
 
             old_umask = umask(077);
             if (virFileMakePath(rundir) < 0) {
@@ -1208,11 +1207,6 @@ int main(int argc, char **argv) {
         run_dir = g_strdup(RUNSTATEDIR "/libvirt");
     } else {
         run_dir = virGetUserRuntimeDirectory();
-
-        if (!run_dir) {
-            VIR_ERROR(_("Can't determine user directory"));
-            goto cleanup;
-        }
     }
     if (privileged)
         old_umask = umask(022);
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index e684fcba09..c11f73ab4d 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -779,8 +779,7 @@ remoteGetUNIXSocketHelper(remoteDriverTransport transport,
                            remoteDriverTransportTypeToString(transport));
             return NULL;
         }
-        if (!(userdir = virGetUserRuntimeDirectory()))
-            return NULL;
+        userdir = virGetUserRuntimeDirectory();
 
         sockname = g_strdup_printf("%s/%s-sock", userdir, sock_prefix);
     } else {
-- 
2.24.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 28/42] remote: 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:33AM +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/remote/remote_daemon.c | 8 +-------
> src/remote/remote_driver.c | 3 +--
> 2 files changed, 2 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