[PATCH 06/15] virNetSSHSessionAuthAddPrivKeyAuth: Refactor cleanup

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

 



With g_strdup not failing we can remove all of the 'error' section.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/rpc/virnetsshsession.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index 08f246be61..9f2aa17131 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -1060,9 +1060,6 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSession *sess,
 {
     virNetSSHAuthMethod *auth;

-    char *user = NULL;
-    char *file = NULL;
-
     if (!username || !keyfile) {
         virReportError(VIR_ERR_SSH, "%s",
                        _("Username and key file path must be provided "
@@ -1072,24 +1069,15 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSession *sess,

     virObjectLock(sess);

-    user = g_strdup(username);
-    file = g_strdup(keyfile);
-
     if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
-        goto error;
+        return -1;

-    auth->username = user;
-    auth->filename = file;
+    auth->username = g_strdup(username);
+    auth->filename = g_strdup(keyfile);
     auth->method = VIR_NET_SSH_AUTH_PRIVKEY;

     virObjectUnlock(sess);
     return 0;
-
- error:
-    VIR_FREE(user);
-    VIR_FREE(file);
-    virObjectUnlock(sess);
-    return -1;
 }

 int
-- 
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