On 1/17/23 10:20 AM, Peter Krempa wrote:
With g_strdup not failing we can remove all of the 'error'
section.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
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;
In this path, you no longer unlock the session.
- 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