]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
rpc: Don't check the output of virGetUserDirectory()
authorFabiano Fidêncio <fidencio@redhat.com>
Thu, 19 Dec 2019 08:23:58 +0000 (09:23 +0100)
committerFabiano Fidêncio <fidencio@redhat.com>
Fri, 20 Dec 2019 08:38:43 +0000 (09:38 +0100)
virGetUserDirectory() *never* *ever* returns NULL, making the checks for
it completely unnecessary.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/rpc/virnetclient.c
src/rpc/virnettlscontext.c

index 1b882a261ac45f2f71c7e25bbd9482031fd694d8..40e5fa35e2cb95cae33c554d92111a47f1a5f549 100644 (file)
@@ -466,10 +466,8 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host,
         privkey = g_strdup(privkeyPath);
     } else {
         homedir = virGetUserDirectory();
-        if (homedir) {
-            if (virNetClientFindDefaultSshKey(homedir, &privkey) < 0)
-                goto no_memory;
-        }
+        if (virNetClientFindDefaultSshKey(homedir, &privkey) < 0)
+            goto no_memory;
     }
 
     if (!authMethods) {
@@ -566,10 +564,8 @@ virNetClientPtr virNetClientNewLibssh(const char *host,
         privkey = g_strdup(privkeyPath);
     } else {
         homedir = virGetUserDirectory();
-        if (homedir) {
-            if (virNetClientFindDefaultSshKey(homedir, &privkey) < 0)
-                goto no_memory;
-        }
+        if (virNetClientFindDefaultSshKey(homedir, &privkey) < 0)
+            goto no_memory;
     }
 
     if (!authMethods) {
index ec9dd35c46641211190c5e19c137f5ad7160c87f..08944f67713b066fcac3010a1c586bcc3481040f 100644 (file)
@@ -805,9 +805,6 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
          */
         userdir = virGetUserDirectory();
 
-        if (!userdir)
-            goto error;
-
         user_pki_path = g_strdup_printf("%s/.pki/libvirt", userdir);
 
         VIR_DEBUG("Trying to find TLS user credentials in %s", user_pki_path);
@@ -864,15 +861,6 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
     VIR_FREE(userdir);
 
     return 0;
-
- error:
-    VIR_FREE(*cacert);
-    VIR_FREE(*cacrl);
-    VIR_FREE(*key);
-    VIR_FREE(*cert);
-    VIR_FREE(user_pki_path);
-    VIR_FREE(userdir);
-    return -1;
 }