提交 6a2e551f 编写于 作者: D Daniel P. Berrangé

remote: use autofree for many string variables

Simplify the clean code paths for doRemoteOpen by using VIR_AUTOFREE
Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 9d9b19c0
...@@ -786,25 +786,24 @@ doRemoteOpen(virConnectPtr conn, ...@@ -786,25 +786,24 @@ doRemoteOpen(virConnectPtr conn,
trans_libssh, trans_libssh,
} transport; } transport;
#ifndef WIN32 #ifndef WIN32
char *daemonPath = NULL; VIR_AUTOFREE(char *) daemonPath = NULL;
#endif #endif
char *tls_priority = NULL; VIR_AUTOFREE(char *) tls_priority = NULL;
char *name = NULL; VIR_AUTOFREE(char *) name = NULL;
char *command = NULL; VIR_AUTOFREE(char *) command = NULL;
char *sockname = NULL; VIR_AUTOFREE(char *) sockname = NULL;
char *netcat = NULL; VIR_AUTOFREE(char *) netcat = NULL;
char *port = NULL; VIR_AUTOFREE(char *) port = NULL;
char *authtype = NULL; VIR_AUTOFREE(char *) authtype = NULL;
char *username = NULL; VIR_AUTOFREE(char *) username = NULL;
char *pkipath = NULL; VIR_AUTOFREE(char *) pkipath = NULL;
char *keyfile = NULL; VIR_AUTOFREE(char *) keyfile = NULL;
char *sshauth = NULL; VIR_AUTOFREE(char *) sshauth = NULL;
char *knownHostsVerify = NULL; VIR_AUTOFREE(char *) knownHostsVerify = NULL;
char *knownHosts = NULL; VIR_AUTOFREE(char *) knownHosts = NULL;
bool sanity = true; bool sanity = true;
bool verify = true; bool verify = true;
bool tty ATTRIBUTE_UNUSED = true; bool tty ATTRIBUTE_UNUSED = true;
int retcode = VIR_DRV_OPEN_ERROR;
/* We handle *ALL* URIs here. The caller has rejected any /* We handle *ALL* URIs here. The caller has rejected any
* URIs we don't care about */ * URIs we don't care about */
...@@ -1257,29 +1256,7 @@ doRemoteOpen(virConnectPtr conn, ...@@ -1257,29 +1256,7 @@ doRemoteOpen(virConnectPtr conn,
"by the remote side."); "by the remote side.");
} }
/* Successful. */ return VIR_DRV_OPEN_SUCCESS;
retcode = VIR_DRV_OPEN_SUCCESS;
cleanup:
/* Free up the URL and strings. */
VIR_FREE(name);
VIR_FREE(command);
VIR_FREE(sockname);
VIR_FREE(authtype);
VIR_FREE(netcat);
VIR_FREE(sshauth);
VIR_FREE(keyfile);
VIR_FREE(username);
VIR_FREE(port);
VIR_FREE(pkipath);
VIR_FREE(tls_priority);
VIR_FREE(knownHostsVerify);
VIR_FREE(knownHosts);
#ifndef WIN32
VIR_FREE(daemonPath);
#endif
return retcode;
failed: failed:
virObjectUnref(priv->remoteProgram); virObjectUnref(priv->remoteProgram);
...@@ -1296,7 +1273,7 @@ doRemoteOpen(virConnectPtr conn, ...@@ -1296,7 +1273,7 @@ doRemoteOpen(virConnectPtr conn,
#endif #endif
VIR_FREE(priv->hostname); VIR_FREE(priv->hostname);
goto cleanup; return VIR_DRV_OPEN_ERROR;
} }
#undef EXTRACT_URI_ARG_STR #undef EXTRACT_URI_ARG_STR
#undef EXTRACT_URI_ARG_BOOL #undef EXTRACT_URI_ARG_BOOL
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册