From nobody Thu May 2 07:07:19 2024 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=1562317296; cv=none; d=zoho.com; s=zohoarc; b=PuR1i3NQOQYvEAXfJkIZepP1oMteCskuCavLP1M8vPaFHYBPrSN9Hlj6QFmVydBC48efo1S6iLKnO1ES9Er+TO/QwcCEgKOPr62aVLCddcUC814eUdjwUResKX5I7zvjqjjlcdktmSnzTWodwS6e683twhPQb04Pk3byoPyh4z8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562317296; 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=QFII9F7A7wIja7vfCukH/OE3m3TZBeLoQJqcyfYqGGU=; b=X4HvpPArpfNKtIZqwPhoMiJRsGAdjPVmngsNjpF5aMyywNRuqV97hl9O6aW+Se1f4tbK36a+89mUalGk8xlkneYqq+uxsMlF9qrBh4IvMuV02LwMiXL+5ZInJUW5ktNrdmUlgRwu1IFROvy/teXEk14UCHIIiZhW5OyIEAsiqbw= 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 156231729638158.73063660142793; Fri, 5 Jul 2019 02:01:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C589F307D860; Fri, 5 Jul 2019 09:01:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 522308D65A; Fri, 5 Jul 2019 09:01:13 +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 9A33E1833002; Fri, 5 Jul 2019 09:01:06 +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 x6590X79008323 for ; Fri, 5 Jul 2019 05:00:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA71D1BC40; Fri, 5 Jul 2019 09:00:33 +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 8CB811BC3F; Fri, 5 Jul 2019 09:00:32 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 5 Jul 2019 10:00:24 +0100 Message-Id: <20190705090026.3113-2-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 1/3] remote: stop declaring variables in the middle of a function 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 05 Jul 2019 09:01:35 +0000 (UTC) The doRemoteOpen method was a little unusual in declaring a bunch of local variables in the middle of the function. Move them to the top as it is normal libvirt style. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/remote/remote_driver.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index df58b23c8c..eb128a87a6 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -789,6 +789,22 @@ doRemoteOpen(virConnectPtr conn, 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; + 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 */ @@ -848,18 +864,6 @@ doRemoteOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } =20 - /* Local variables which we will initialize. These can - * get freed in the failed: path. - */ - char *name =3D NULL, *command =3D NULL, *sockname =3D NULL, *netcat = =3D NULL; - char *port =3D NULL, *authtype =3D NULL, *username =3D NULL; - bool sanity =3D true, verify =3D true, tty ATTRIBUTE_UNUSED =3D true; - char *pkipath =3D NULL, *keyfile =3D NULL, *sshauth =3D NULL; - - char *knownHostsVerify =3D NULL, *knownHosts =3D NULL; - - /* Return code from this function, and the private data. */ - int retcode =3D VIR_DRV_OPEN_ERROR; =20 /* Remote server defaults to "localhost" if not specified. */ if (conn->uri && conn->uri->port !=3D 0) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:07:19 2024 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 Reviewed-by: Fabiano Fid=C3=AAncio --- 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 From nobody Thu May 2 07:07:19 2024 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=1562317250; cv=none; d=zoho.com; s=zohoarc; b=hvA1BmLTNKvZHfEbDR9JERnU+jGlsXlb/bSiv+axMTLF+Ctm5iaBdlGbp8GSOh/OMBVHBc6+sdubGVxNZBmIxNbKZPIRUixGGAGrmRLJGP5QIoOI1Uc43LwLmflU20B25xNza8Ey0aqrnpzRFcAeNuJPLNZFIN09IdZYezUBciw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562317250; 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=mZbvJdHLCXLxHpOJHLOAJAcJGOYTrUg3EnuL40NdDwk=; b=Q0DF3GOzyapIC2ST2W+IBV3QhNW8BPgM3LYjZ+hTq0g2Sz5MTQZ1/qFEu9DFrZiUMjrF/UFo4F4/ncnseu5sFcKNIqOrDqi2O8f/PHxlZ7EqE+wCAtAezDcv4BDgJuxWfba6sfWgcXaGI3rmGkFkDUVzLIVH9hEuRdzI6ZfXSEc= 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 1562317250195930.5585995929018; Fri, 5 Jul 2019 02:00:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E3A030832C6; Fri, 5 Jul 2019 09:00:41 +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 4752B68C6B; Fri, 5 Jul 2019 09:00:39 +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 EE7E419727; Fri, 5 Jul 2019 09:00:36 +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 x6590aFu008343 for ; Fri, 5 Jul 2019 05:00:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 224F61BC40; Fri, 5 Jul 2019 09:00:36 +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 391071BC3E; Fri, 5 Jul 2019 09:00:35 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 5 Jul 2019 10:00:26 +0100 Message-Id: <20190705090026.3113-4-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 3/3] remote: conditionally declare tty variable for non-Win32 platforms 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 05 Jul 2019 09:00:49 +0000 (UTC) The 'tty' variable is only used on Win32. Instead of just annotating it with ATTRIBUTE_UNUSED, make its declaration conditional on WIN32 so that it is clear why it is not used. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/remote/remote_driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index aae1976008..acc6a87bb3 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -803,7 +803,9 @@ doRemoteOpen(virConnectPtr conn, VIR_AUTOFREE(char *) knownHosts =3D NULL; bool sanity =3D true; bool verify =3D true; - bool tty ATTRIBUTE_UNUSED =3D true; +#ifndef WIN32 + bool tty =3D true; +#endif =20 /* We handle *ALL* URIs here. The caller has rejected any * URIs we don't care about */ @@ -908,7 +910,9 @@ doRemoteOpen(virConnectPtr conn, =20 EXTRACT_URI_ARG_BOOL("no_sanity", sanity); EXTRACT_URI_ARG_BOOL("no_verify", verify); +#ifndef WIN32 EXTRACT_URI_ARG_BOOL("no_tty", tty); +#endif =20 if (STRCASEEQ(var->name, "authfile")) { /* Strip this param, used by virauth.c */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list