提交 2d13431d 编写于 作者: D Daniel Henrique Barboza 提交者: Ján Tomko

rpc: remove unneeded cleanup labels

Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 215007f2
...@@ -109,7 +109,6 @@ static int virNetServerProcessMsg(virNetServerPtr srv, ...@@ -109,7 +109,6 @@ static int virNetServerProcessMsg(virNetServerPtr srv,
virNetServerProgramPtr prog, virNetServerProgramPtr prog,
virNetMessagePtr msg) virNetMessagePtr msg)
{ {
int ret = -1;
if (!prog) { if (!prog) {
/* Only send back an error for type == CALL. Other /* Only send back an error for type == CALL. Other
* message types are not expecting replies, so we * message types are not expecting replies, so we
...@@ -120,7 +119,7 @@ static int virNetServerProcessMsg(virNetServerPtr srv, ...@@ -120,7 +119,7 @@ static int virNetServerProcessMsg(virNetServerPtr srv,
if (virNetServerProgramUnknownError(client, if (virNetServerProgramUnknownError(client,
msg, msg,
&msg->header) < 0) &msg->header) < 0)
goto cleanup; return -1;
} else { } else {
VIR_INFO("Dropping client message, unknown program %d version %d type %d proc %d", VIR_INFO("Dropping client message, unknown program %d version %d type %d proc %d",
msg->header.prog, msg->header.vers, msg->header.prog, msg->header.vers,
...@@ -129,22 +128,18 @@ static int virNetServerProcessMsg(virNetServerPtr srv, ...@@ -129,22 +128,18 @@ static int virNetServerProcessMsg(virNetServerPtr srv,
virNetMessageClear(msg); virNetMessageClear(msg);
msg->header.type = VIR_NET_REPLY; msg->header.type = VIR_NET_REPLY;
if (virNetServerClientSendMessage(client, msg) < 0) if (virNetServerClientSendMessage(client, msg) < 0)
goto cleanup; return -1;
} }
goto done; return 0;
} }
if (virNetServerProgramDispatch(prog, if (virNetServerProgramDispatch(prog,
srv, srv,
client, client,
msg) < 0) msg) < 0)
goto cleanup; return -1;
done:
ret = 0;
cleanup: return 0;
return ret;
} }
static void virNetServerHandleJob(void *jobOpaque, void *opaque) static void virNetServerHandleJob(void *jobOpaque, void *opaque)
......
...@@ -312,10 +312,8 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog, ...@@ -312,10 +312,8 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
/* Send a dummy reply to free up 'msg' & unblock client rx */ /* Send a dummy reply to free up 'msg' & unblock client rx */
virNetMessageClear(msg); virNetMessageClear(msg);
msg->header.type = VIR_NET_REPLY; msg->header.type = VIR_NET_REPLY;
if (virNetServerClientSendMessage(client, msg) < 0) { if (virNetServerClientSendMessage(client, msg) < 0)
ret = -1; return -1;
goto cleanup;
}
ret = 0; ret = 0;
break; break;
...@@ -340,14 +338,11 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog, ...@@ -340,14 +338,11 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
/* Send a dummy reply to free up 'msg' & unblock client rx */ /* Send a dummy reply to free up 'msg' & unblock client rx */
virNetMessageClear(msg); virNetMessageClear(msg);
msg->header.type = VIR_NET_REPLY; msg->header.type = VIR_NET_REPLY;
if (virNetServerClientSendMessage(client, msg) < 0) { if (virNetServerClientSendMessage(client, msg) < 0)
ret = -1; return -1;
goto cleanup;
}
ret = 0; ret = 0;
} }
cleanup:
return ret; return ret;
} }
......
...@@ -159,7 +159,6 @@ int virNetSocketCheckProtocols(bool *hasIPv4, ...@@ -159,7 +159,6 @@ int virNetSocketCheckProtocols(bool *hasIPv4,
struct ifaddrs *ifaddr = NULL, *ifa; struct ifaddrs *ifaddr = NULL, *ifa;
struct addrinfo hints; struct addrinfo hints;
struct addrinfo *ai = NULL; struct addrinfo *ai = NULL;
int ret = -1;
int gaierr; int gaierr;
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
...@@ -169,7 +168,7 @@ int virNetSocketCheckProtocols(bool *hasIPv4, ...@@ -169,7 +168,7 @@ int virNetSocketCheckProtocols(bool *hasIPv4,
if (getifaddrs(&ifaddr) < 0) { if (getifaddrs(&ifaddr) < 0) {
virReportSystemError(errno, "%s", virReportSystemError(errno, "%s",
_("Cannot get host interface addresses")); _("Cannot get host interface addresses"));
goto cleanup; return -1;
} }
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
...@@ -197,7 +196,7 @@ int virNetSocketCheckProtocols(bool *hasIPv4, ...@@ -197,7 +196,7 @@ int virNetSocketCheckProtocols(bool *hasIPv4,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot resolve ::1 address: %s"), _("Cannot resolve ::1 address: %s"),
gai_strerror(gaierr)); gai_strerror(gaierr));
goto cleanup; return -1;
} }
} }
...@@ -205,9 +204,7 @@ int virNetSocketCheckProtocols(bool *hasIPv4, ...@@ -205,9 +204,7 @@ int virNetSocketCheckProtocols(bool *hasIPv4,
VIR_DEBUG("Protocols: v4 %d v6 %d", *hasIPv4, *hasIPv6); VIR_DEBUG("Protocols: v4 %d v6 %d", *hasIPv4, *hasIPv6);
ret = 0; return 0;
cleanup:
return ret;
#else #else
*hasIPv4 = *hasIPv6 = false; *hasIPv4 = *hasIPv6 = false;
virReportError(VIR_ERR_NO_SUPPORT, "%s", virReportError(VIR_ERR_NO_SUPPORT, "%s",
......
...@@ -610,12 +610,11 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt, ...@@ -610,12 +610,11 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
const char *cert, const char *cert,
const char *key) const char *key)
{ {
int ret = -1;
int err; int err;
if (cacert && cacert[0] != '\0') { if (cacert && cacert[0] != '\0') {
if (virNetTLSContextCheckCertFile("CA certificate", cacert, false) < 0) if (virNetTLSContextCheckCertFile("CA certificate", cacert, false) < 0)
goto cleanup; return -1;
VIR_DEBUG("loading CA cert from %s", cacert); VIR_DEBUG("loading CA cert from %s", cacert);
err = gnutls_certificate_set_x509_trust_file(ctxt->x509cred, err = gnutls_certificate_set_x509_trust_file(ctxt->x509cred,
...@@ -625,14 +624,14 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt, ...@@ -625,14 +624,14 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
virReportError(VIR_ERR_SYSTEM_ERROR, virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to set x509 CA certificate: %s: %s"), _("Unable to set x509 CA certificate: %s: %s"),
cacert, gnutls_strerror(err)); cacert, gnutls_strerror(err));
goto cleanup; return -1;
} }
} }
if (cacrl && cacrl[0] != '\0') { if (cacrl && cacrl[0] != '\0') {
int rv; int rv;
if ((rv = virNetTLSContextCheckCertFile("CA revocation list", cacrl, true)) < 0) if ((rv = virNetTLSContextCheckCertFile("CA revocation list", cacrl, true)) < 0)
goto cleanup; return -1;
if (rv == 0) { if (rv == 0) {
VIR_DEBUG("loading CRL from %s", cacrl); VIR_DEBUG("loading CRL from %s", cacrl);
...@@ -643,7 +642,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt, ...@@ -643,7 +642,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
virReportError(VIR_ERR_SYSTEM_ERROR, virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to set x509 certificate revocation list: %s: %s"), _("Unable to set x509 certificate revocation list: %s: %s"),
cacrl, gnutls_strerror(err)); cacrl, gnutls_strerror(err));
goto cleanup; return -1;
} }
} else { } else {
VIR_DEBUG("Skipping non-existent CA CRL %s", cacrl); VIR_DEBUG("Skipping non-existent CA CRL %s", cacrl);
...@@ -653,10 +652,10 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt, ...@@ -653,10 +652,10 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
if (cert && cert[0] != '\0' && key && key[0] != '\0') { if (cert && cert[0] != '\0' && key && key[0] != '\0') {
int rv; int rv;
if ((rv = virNetTLSContextCheckCertFile("certificate", cert, !isServer)) < 0) if ((rv = virNetTLSContextCheckCertFile("certificate", cert, !isServer)) < 0)
goto cleanup; return -1;
if (rv == 0 && if (rv == 0 &&
(rv = virNetTLSContextCheckCertFile("private key", key, !isServer)) < 0) (rv = virNetTLSContextCheckCertFile("private key", key, !isServer)) < 0)
goto cleanup; return -1;
if (rv == 0) { if (rv == 0) {
VIR_DEBUG("loading cert and key from %s and %s", cert, key); VIR_DEBUG("loading cert and key from %s and %s", cert, key);
...@@ -668,7 +667,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt, ...@@ -668,7 +667,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
virReportError(VIR_ERR_SYSTEM_ERROR, virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to set x509 key and certificate: %s, %s: %s"), _("Unable to set x509 key and certificate: %s, %s: %s"),
key, cert, gnutls_strerror(err)); key, cert, gnutls_strerror(err));
goto cleanup; return -1;
} }
} else { } else {
VIR_DEBUG("Skipping non-existent cert %s key %s on client", VIR_DEBUG("Skipping non-existent cert %s key %s on client",
...@@ -676,10 +675,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt, ...@@ -676,10 +675,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
} }
} }
ret = 0; return 0;
cleanup:
return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部