From nobody Sun Feb 8 11:25:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562317303; cv=none; d=zoho.com; s=zohoarc; b=c9RaOJyeQbo/y96AzPkgcpA+6ZL55a8pO7OVfySkckrJ88A4c7/2TB0/uZCh3mqFElLP0/hKufghGCDl2ud3ed2GSZ6AG5oYflQ/+B1TKvLFWIPqTiVe0vFXzijzt5q+ThUu6xm31juBKFuvy1AB30/L8c0Rc4O94SmXHqSkEHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562317303; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lD3x62hNs6HPAdvKW3mXKzLRr4sSF5/gBNBY6HwJhEQ=; b=DBoa/Q2JP2+w3/vn6HcYPB+07XmiwYTeRW2kC6cXJyWo3em5C9mig9ZgB70/T9ubYHYowGJtr4uViA7u/4FbY6iBtX40NsbpfQ39Ww/vMwHN9Mb8GtdCux8r6q2i5cTTWGG3E53YE1qLrkLPBDMhUIX9VfwS9EChen4PQR0xGjk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562317303851613.3896132624977; Fri, 5 Jul 2019 02:01:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 892393E2BB; Fri, 5 Jul 2019 09:01:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B8A08226A; Fri, 5 Jul 2019 09:01:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 32B7019726; Fri, 5 Jul 2019 09:01:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6590YJ1008332 for ; Fri, 5 Jul 2019 05:00:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE6971BC3F; Fri, 5 Jul 2019 09:00:34 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-48.ams2.redhat.com [10.36.112.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1592E1BC3E; Fri, 5 Jul 2019 09:00:33 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 5 Jul 2019 10:00:25 +0100 Message-Id: <20190705090026.3113-3-berrange@redhat.com> In-Reply-To: <20190705090026.3113-1-berrange@redhat.com> References: <20190705090026.3113-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] remote: use autofree for many string variables X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 05 Jul 2019 09:01:42 +0000 (UTC) Simplify the clean code paths for doRemoteOpen by using VIR_AUTOFREE Signed-off-by: Daniel P. Berrang=C3=A9 --- src/remote/remote_driver.c | 55 +++++++++++--------------------------- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index eb128a87a6..aae1976008 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -786,25 +786,24 @@ doRemoteOpen(virConnectPtr conn, trans_libssh, } transport; #ifndef WIN32 - char *daemonPath =3D NULL; + VIR_AUTOFREE(char *) daemonPath =3D NULL; #endif - char *tls_priority =3D NULL; - char *name =3D NULL; - char *command =3D NULL; - char *sockname =3D NULL; - char *netcat =3D NULL; - char *port =3D NULL; - char *authtype =3D NULL; - char *username =3D NULL; - char *pkipath =3D NULL; - char *keyfile =3D NULL; - char *sshauth =3D NULL; - char *knownHostsVerify =3D NULL; - char *knownHosts =3D NULL; + VIR_AUTOFREE(char *) tls_priority =3D NULL; + VIR_AUTOFREE(char *) name =3D NULL; + VIR_AUTOFREE(char *) command =3D NULL; + VIR_AUTOFREE(char *) sockname =3D NULL; + VIR_AUTOFREE(char *) netcat =3D NULL; + VIR_AUTOFREE(char *) port =3D NULL; + VIR_AUTOFREE(char *) authtype =3D NULL; + VIR_AUTOFREE(char *) username =3D NULL; + VIR_AUTOFREE(char *) pkipath =3D NULL; + VIR_AUTOFREE(char *) keyfile =3D NULL; + VIR_AUTOFREE(char *) sshauth =3D NULL; + VIR_AUTOFREE(char *) knownHostsVerify =3D NULL; + VIR_AUTOFREE(char *) knownHosts =3D NULL; bool sanity =3D true; bool verify =3D true; bool tty ATTRIBUTE_UNUSED =3D true; - int retcode =3D VIR_DRV_OPEN_ERROR; =20 /* 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."); } =20 - /* Successful. */ - retcode =3D 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; =20 failed: virObjectUnref(priv->remoteProgram); @@ -1296,7 +1273,7 @@ doRemoteOpen(virConnectPtr conn, #endif =20 VIR_FREE(priv->hostname); - goto cleanup; + return VIR_DRV_OPEN_ERROR; } #undef EXTRACT_URI_ARG_STR #undef EXTRACT_URI_ARG_BOOL --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list