]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
remote: use autofree for many string variables
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 4 Jul 2019 10:22:11 +0000 (11:22 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 5 Jul 2019 17:27:21 +0000 (18:27 +0100)
Simplify the clean code paths for doRemoteOpen by using VIR_AUTOFREE

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/remote/remote_driver.c

index 86f061825aa7124441417cbf38b56ea203a2126b..c66775021eaa920e0e6a3c08cf3050583491b3f3 100644 (file)
@@ -786,25 +786,24 @@ doRemoteOpen(virConnectPtr conn,
         trans_libssh,
     } transport;
 #ifndef WIN32
-    char *daemonPath = NULL;
+    VIR_AUTOFREE(char *) daemonPath = NULL;
 #endif
-    char *tls_priority = NULL;
-    char *name = NULL;
-    char *command = NULL;
-    char *sockname = NULL;
-    char *netcat = NULL;
-    char *port = NULL;
-    char *authtype = NULL;
-    char *username = NULL;
-    char *pkipath = NULL;
-    char *keyfile = NULL;
-    char *sshauth = NULL;
-    char *knownHostsVerify = NULL;
-    char *knownHosts = NULL;
+    VIR_AUTOFREE(char *) tls_priority = NULL;
+    VIR_AUTOFREE(char *) name = NULL;
+    VIR_AUTOFREE(char *) command = NULL;
+    VIR_AUTOFREE(char *) sockname = NULL;
+    VIR_AUTOFREE(char *) netcat = NULL;
+    VIR_AUTOFREE(char *) port = NULL;
+    VIR_AUTOFREE(char *) authtype = NULL;
+    VIR_AUTOFREE(char *) username = NULL;
+    VIR_AUTOFREE(char *) pkipath = NULL;
+    VIR_AUTOFREE(char *) keyfile = NULL;
+    VIR_AUTOFREE(char *) sshauth = NULL;
+    VIR_AUTOFREE(char *) knownHostsVerify = NULL;
+    VIR_AUTOFREE(char *) knownHosts = NULL;
     bool sanity = true;
     bool verify = true;
     bool tty ATTRIBUTE_UNUSED = true;
-    int retcode = VIR_DRV_OPEN_ERROR;
 
     /* We handle *ALL* URIs here. The caller has rejected any
      * URIs we don't care about */
@@ -1257,29 +1256,7 @@ doRemoteOpen(virConnectPtr conn,
                  "by the remote side.");
     }
 
-    /* Successful. */
-    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;
+    return VIR_DRV_OPEN_SUCCESS;
 
  failed:
     virObjectUnref(priv->remoteProgram);
@@ -1296,7 +1273,7 @@ doRemoteOpen(virConnectPtr conn,
 #endif
 
     VIR_FREE(priv->hostname);
-    goto cleanup;
+    return VIR_DRV_OPEN_ERROR;
 }
 #undef EXTRACT_URI_ARG_STR
 #undef EXTRACT_URI_ARG_BOOL