[PATCH 5/5] virnetlibsshsession: Don't check return value of 'virNetLibsshSessionAuthMethodNew'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The function can't return NULL to the callers so it doesn't make sense
to check it.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/rpc/virnetlibsshsession.c | 43 ++++++-----------------------------
 1 file changed, 7 insertions(+), 36 deletions(-)

diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
index d2e9e20ff2..bba37210df 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -843,7 +843,6 @@ int
 virNetLibsshSessionAuthAddPasswordAuth(virNetLibsshSession *sess,
                                        virURI *uri)
 {
-    int ret;
     virNetLibsshAuthMethod *auth;

     virObjectLock(sess);
@@ -857,43 +856,27 @@ virNetLibsshSessionAuthAddPasswordAuth(virNetLibsshSession *sess,
         }
     }

-
-    if (!(auth = virNetLibsshSessionAuthMethodNew(sess))) {
-        ret = -1;
-        goto cleanup;
-    }
-
+    auth = virNetLibsshSessionAuthMethodNew(sess);
     auth->method = VIR_NET_LIBSSH_AUTH_PASSWORD;
     auth->ssh_flags = SSH_AUTH_METHOD_PASSWORD;

-    ret = 0;
-
- cleanup:
     virObjectUnlock(sess);
-    return ret;
+    return 0;
 }

 int
 virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess)
 {
-    int ret;
     virNetLibsshAuthMethod *auth;

     virObjectLock(sess);

-    if (!(auth = virNetLibsshSessionAuthMethodNew(sess))) {
-        ret = -1;
-        goto cleanup;
-    }
-
+    auth = virNetLibsshSessionAuthMethodNew(sess);
     auth->method = VIR_NET_LIBSSH_AUTH_AGENT;
     auth->ssh_flags = SSH_AUTH_METHOD_PUBLICKEY;

-    ret = 0;
-
- cleanup:
     virObjectUnlock(sess);
-    return ret;
+    return 0;
 }

 int
@@ -910,11 +893,7 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSession *sess,

     virObjectLock(sess);

-    if (!(auth = virNetLibsshSessionAuthMethodNew(sess))) {
-        virObjectUnlock(sess);
-        return -1;
-    }
-
+    auth = virNetLibsshSessionAuthMethodNew(sess);
     auth->filename = g_strdup(keyfile);
     auth->method = VIR_NET_LIBSSH_AUTH_PRIVKEY;
     auth->ssh_flags = SSH_AUTH_METHOD_PUBLICKEY;
@@ -927,26 +906,18 @@ int
 virNetLibsshSessionAuthAddKeyboardAuth(virNetLibsshSession *sess,
                                        int tries)
 {
-    int ret;
     virNetLibsshAuthMethod *auth;

     virObjectLock(sess);

-    if (!(auth = virNetLibsshSessionAuthMethodNew(sess))) {
-        ret = -1;
-        goto cleanup;
-    }
+    auth = virNetLibsshSessionAuthMethodNew(sess);

     auth->tries = tries;
     auth->method = VIR_NET_LIBSSH_AUTH_KEYBOARD_INTERACTIVE;
     auth->ssh_flags = SSH_AUTH_METHOD_INTERACTIVE;

-    ret = 0;
-
- cleanup:
     virObjectUnlock(sess);
-    return ret;
-
+    return 0;
 }

 void
-- 
2.38.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux