mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
virNetSSHSessionAuthAddPrivKeyAuth: Refactor cleanup
With g_strdup not failing we can remove all of the 'error' section. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
7f6b632b73
commit
3267ce58cf
@ -1060,9 +1060,6 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSession *sess,
|
|||||||
{
|
{
|
||||||
virNetSSHAuthMethod *auth;
|
virNetSSHAuthMethod *auth;
|
||||||
|
|
||||||
char *user = NULL;
|
|
||||||
char *file = NULL;
|
|
||||||
|
|
||||||
if (!username || !keyfile) {
|
if (!username || !keyfile) {
|
||||||
virReportError(VIR_ERR_SSH, "%s",
|
virReportError(VIR_ERR_SSH, "%s",
|
||||||
_("Username and key file path must be provided "
|
_("Username and key file path must be provided "
|
||||||
@ -1072,24 +1069,17 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSession *sess,
|
|||||||
|
|
||||||
virObjectLock(sess);
|
virObjectLock(sess);
|
||||||
|
|
||||||
user = g_strdup(username);
|
if (!(auth = virNetSSHSessionAuthMethodNew(sess))) {
|
||||||
file = g_strdup(keyfile);
|
virObjectUnlock(sess);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
|
auth->username = g_strdup(username);
|
||||||
goto error;
|
auth->filename = g_strdup(keyfile);
|
||||||
|
|
||||||
auth->username = user;
|
|
||||||
auth->filename = file;
|
|
||||||
auth->method = VIR_NET_SSH_AUTH_PRIVKEY;
|
auth->method = VIR_NET_SSH_AUTH_PRIVKEY;
|
||||||
|
|
||||||
virObjectUnlock(sess);
|
virObjectUnlock(sess);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
VIR_FREE(user);
|
|
||||||
VIR_FREE(file);
|
|
||||||
virObjectUnlock(sess);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user