[libvirt] [PATCH v1 04/21] remote: remove unneeded cleanup labels

Daniel Henrique Barboza danielhb413 at gmail.com
Mon Oct 21 18:18:54 UTC 2019


Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/remote/remote_daemon.c | 38 +++++++++++++++++---------------------
 src/remote/remote_driver.c | 15 +++++----------
 2 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index 7e63e18034..346415e96b 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -399,7 +399,6 @@ daemonSetupNetworking(virNetServerPtr srv,
     int unix_sock_ro_mask = 0;
     int unix_sock_rw_mask = 0;
     int unix_sock_adm_mask = 0;
-    int ret = -1;
     g_autoptr(virSystemdActivation) act = NULL;
     virSystemdActivationMap actmap[] = {
         { .name = DAEMON_NAME ".socket", .family = AF_UNIX, .path = sock_path },
@@ -453,22 +452,22 @@ daemonSetupNetworking(virNetServerPtr srv,
 
     if (config->unix_sock_group) {
         if (virGetGroupID(config->unix_sock_group, &unix_sock_gid) < 0)
-            return ret;
+            return -1;
     }
 
     if (virStrToLong_i(config->unix_sock_ro_perms, NULL, 8, &unix_sock_ro_mask) != 0) {
         VIR_ERROR(_("Failed to parse mode '%s'"), config->unix_sock_ro_perms);
-        goto cleanup;
+        return -1;
     }
 
     if (virStrToLong_i(config->unix_sock_admin_perms, NULL, 8, &unix_sock_adm_mask) != 0) {
         VIR_ERROR(_("Failed to parse mode '%s'"), config->unix_sock_admin_perms);
-        goto cleanup;
+        return -1;
     }
 
     if (virStrToLong_i(config->unix_sock_rw_perms, NULL, 8, &unix_sock_rw_mask) != 0) {
         VIR_ERROR(_("Failed to parse mode '%s'"), config->unix_sock_rw_perms);
-        goto cleanup;
+        return -1;
     }
 
     if (virNetServerAddServiceUNIX(srv,
@@ -482,7 +481,7 @@ daemonSetupNetworking(virNetServerPtr srv,
                                    false,
                                    config->max_queued_clients,
                                    config->max_client_requests) < 0)
-        goto cleanup;
+        return -1;
     if (sock_path_ro &&
         virNetServerAddServiceUNIX(srv,
                                    act,
@@ -495,7 +494,7 @@ daemonSetupNetworking(virNetServerPtr srv,
                                    true,
                                    config->max_queued_clients,
                                    config->max_client_requests) < 0)
-        goto cleanup;
+        return -1;
 
     if (sock_path_adm &&
         virNetServerAddServiceUNIX(srvAdm,
@@ -509,7 +508,7 @@ daemonSetupNetworking(virNetServerPtr srv,
                                    false,
                                    config->admin_max_queued_clients,
                                    config->admin_max_client_requests) < 0)
-        goto cleanup;
+        return -1;
 
 #ifdef WITH_IP
     if (((ipsock && config->listen_tcp) || act) &&
@@ -524,7 +523,7 @@ daemonSetupNetworking(virNetServerPtr srv,
                                   false,
                                   config->max_queued_clients,
                                   config->max_client_requests) < 0)
-        goto cleanup;
+        return -1;
 
     if (((ipsock && config->listen_tls) || (act && virSystemdActivationHasName(act, DAEMON_NAME "-tls.socket")))) {
         virNetTLSContextPtr ctxt = NULL;
@@ -535,17 +534,17 @@ daemonSetupNetworking(virNetServerPtr srv,
             if (!config->ca_file) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("No CA certificate path set to match server key/cert"));
-                goto cleanup;
+                return -1;
             }
             if (!config->cert_file) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("No server certificate path set to match server key"));
-                goto cleanup;
+                return -1;
             }
             if (!config->key_file) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("No server key path set to match server cert"));
-                goto cleanup;
+                return -1;
             }
             VIR_DEBUG("Using CA='%s' cert='%s' key='%s'",
                       config->ca_file, config->cert_file, config->key_file);
@@ -557,7 +556,7 @@ daemonSetupNetworking(virNetServerPtr srv,
                                                    config->tls_priority,
                                                    config->tls_no_sanity_certificate ? false : true,
                                                    config->tls_no_verify_certificate ? false : true)))
-                goto cleanup;
+                return -1;
         } else {
             if (!(ctxt = virNetTLSContextNewServerPath(NULL,
                                                        !privileged,
@@ -565,7 +564,7 @@ daemonSetupNetworking(virNetServerPtr srv,
                                                        config->tls_priority,
                                                        config->tls_no_sanity_certificate ? false : true,
                                                        config->tls_no_verify_certificate ? false : true)))
-                goto cleanup;
+                return -1;
         }
 
         VIR_DEBUG("Registering TLS socket %s:%s",
@@ -582,7 +581,7 @@ daemonSetupNetworking(virNetServerPtr srv,
                                       config->max_queued_clients,
                                       config->max_client_requests) < 0) {
             virObjectUnref(ctxt);
-            goto cleanup;
+            return -1;
         }
         virObjectUnref(ctxt);
     }
@@ -590,19 +589,16 @@ daemonSetupNetworking(virNetServerPtr srv,
 
     if (act &&
         virSystemdActivationComplete(act) < 0)
-        goto cleanup;
+        return -1;
 
 #if WITH_SASL
     if (virNetServerNeedsAuth(srv, REMOTE_AUTH_SASL) &&
         !(saslCtxt = virNetSASLContextNewServer(
               (const char *const*)config->sasl_allowed_username_list)))
-        goto cleanup;
+        return -1;
 #endif
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 83477243fc..67ae0fe286 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4182,20 +4182,18 @@ static int remoteAuthInteract(virConnectPtr conn,
                               struct remoteAuthInteractState *state,
                               virConnectAuthPtr auth)
 {
-    int ret = -1;
-
     VIR_DEBUG("Starting SASL interaction");
     remoteAuthInteractStateClear(state, false);
 
     /* Fills state->interact with any values from the auth config file */
     if (remoteAuthFillFromConfig(conn, state) < 0)
-        goto cleanup;
+        return -1;
 
     /* Populates state->cred for anything not found in the auth config */
     if (remoteAuthMakeCredentials(state->interact, &state->cred, &state->ncred) < 0) {
         virReportError(VIR_ERR_AUTH_FAILED, "%s",
                        _("Failed to make auth credentials"));
-        goto cleanup;
+        return -1;
     }
 
     /* If there was anything not in the auth config, we need to
@@ -4206,13 +4204,13 @@ static int remoteAuthInteract(virConnectPtr conn,
         if (!auth || !auth->cb) {
             virReportError(VIR_ERR_AUTH_FAILED, "%s",
                            _("No authentication callback available"));
-            goto cleanup;
+            return -1;
         }
 
         if ((*(auth->cb))(state->cred, state->ncred, auth->cbdata) < 0) {
             virReportError(VIR_ERR_AUTH_FAILED, "%s",
                            _("Failed to collect auth credentials"));
-            goto cleanup;
+            return -1;
         }
 
         /* Copy user's responses from cred into interact */
@@ -4227,10 +4225,7 @@ static int remoteAuthInteract(virConnectPtr conn,
      * of this method, rather than the end.
      */
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
-- 
2.21.0




More information about the libvir-list mailing list