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