[PATCH v1 11/21] rpc: remove unneeded cleanup labels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 src/rpc/virnetserver.c        | 15 +++++----------
 src/rpc/virnetserverprogram.c | 13 ++++---------
 src/rpc/virnetsocket.c        |  9 +++------
 src/rpc/virnettlscontext.c    | 20 ++++++++------------
 4 files changed, 20 insertions(+), 37 deletions(-)

diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 042661ffa5..590e780b64 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -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)
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index e3fa810a3f..8df92fb8df 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -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;
 }
 
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 6574ee0d16..a031133626 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -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",
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 2420ad8681..e15cd7f64a 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -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;
 }
 
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux