From nobody Sun Feb 8 21:48:08 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554104024034626.5974996796464; Mon, 1 Apr 2019 00:33:44 -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 C1A7EF74B5; Mon, 1 Apr 2019 07:33:42 +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 946AF26DF5; Mon, 1 Apr 2019 07:33:42 +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 4EFDC3FA4C; Mon, 1 Apr 2019 07:33:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x317XOgK013839 for ; Mon, 1 Apr 2019 03:33:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id F3A8160BFC; Mon, 1 Apr 2019 07:33:23 +0000 (UTC) Received: from lpt.redhat.com (ovpn-204-90.brq.redhat.com [10.40.204.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BC5760BE6 for ; Mon, 1 Apr 2019 07:33:23 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 1 Apr 2019 09:33:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/14] virsh-completer: add a cleanup label everywhere 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.38]); Mon, 01 Apr 2019 07:33:43 +0000 (UTC) Unify the cleanup paths for error and success. Now that 'ret' is only set (from tmp) on the success path, it is safe to jump right before 'return ret' after processing the error block. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-completer.c | 45 +++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 0750945b84..46fedc06d9 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -111,6 +111,7 @@ virshDomainNameCompleter(vshControl *ctl, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: @@ -120,7 +121,7 @@ virshDomainNameCompleter(vshControl *ctl, for (i =3D 0; i < ndomains; i++) VIR_FREE(tmp[i]); VIR_FREE(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -263,6 +264,7 @@ virshStoragePoolNameCompleter(vshControl *ctl, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: @@ -272,7 +274,7 @@ virshStoragePoolNameCompleter(vshControl *ctl, for (i =3D 0; i < npools; i++) VIR_FREE(tmp[i]); VIR_FREE(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -319,6 +321,7 @@ virshStorageVolNameCompleter(vshControl *ctl, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: @@ -329,7 +332,7 @@ virshStorageVolNameCompleter(vshControl *ctl, VIR_FREE(tmp[i]); VIR_FREE(tmp); virStoragePoolFree(pool); - return NULL; + goto cleanup; } =20 =20 @@ -370,6 +373,7 @@ virshInterfaceNameCompleter(vshControl *ctl, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: @@ -379,7 +383,7 @@ virshInterfaceNameCompleter(vshControl *ctl, for (i =3D 0; i < nifaces; i++) VIR_FREE(tmp[i]); VIR_FREE(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -421,6 +425,7 @@ virshNetworkNameCompleter(vshControl *ctl, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: @@ -430,7 +435,7 @@ virshNetworkNameCompleter(vshControl *ctl, for (i =3D 0; i < nnets; i++) VIR_FREE(tmp[i]); VIR_FREE(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -455,11 +460,12 @@ virshNetworkEventNameCompleter(vshControl *ctl ATTRIB= UTE_UNUSED, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: virStringListFree(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -498,6 +504,7 @@ virshNodeDeviceNameCompleter(vshControl *ctl, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: @@ -507,7 +514,7 @@ virshNodeDeviceNameCompleter(vshControl *ctl, for (i =3D 0; i < ndevs; i++) VIR_FREE(tmp[i]); VIR_FREE(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -546,6 +553,7 @@ virshNWFilterNameCompleter(vshControl *ctl, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: @@ -555,7 +563,7 @@ virshNWFilterNameCompleter(vshControl *ctl, for (i =3D 0; i < nnwfilters; i++) VIR_FREE(tmp[i]); VIR_FREE(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -594,6 +602,7 @@ virshNWFilterBindingNameCompleter(vshControl *ctl, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: @@ -603,7 +612,7 @@ virshNWFilterBindingNameCompleter(vshControl *ctl, for (i =3D 0; i < nbindings; i++) VIR_FREE(tmp[i]); VIR_FREE(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -643,6 +652,7 @@ virshSecretUUIDCompleter(vshControl *ctl, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: @@ -652,7 +662,7 @@ virshSecretUUIDCompleter(vshControl *ctl, for (i =3D 0; i < nsecrets; i++) VIR_FREE(tmp[i]); VIR_FREE(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -698,6 +708,7 @@ virshSnapshotNameCompleter(vshControl *ctl, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: @@ -708,7 +719,7 @@ virshSnapshotNameCompleter(vshControl *ctl, VIR_FREE(tmp[i]); VIR_FREE(tmp); virshDomainFree(dom); - return NULL; + goto cleanup; } =20 char ** @@ -820,11 +831,12 @@ virshSecretEventNameCompleter(vshControl *ctl ATTRIBU= TE_UNUSED, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: virStringListFree(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -849,11 +861,12 @@ virshDomainEventNameCompleter(vshControl *ctl ATTRIBU= TE_UNUSED, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: virStringListFree(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -878,11 +891,12 @@ virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE= _UNUSED, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: virStringListFree(tmp); - return NULL; + goto cleanup; } =20 =20 @@ -982,11 +996,12 @@ virshNodedevEventNameCompleter(vshControl *ctl ATTRIB= UTE_UNUSED, =20 VIR_STEAL_PTR(ret, tmp); =20 + cleanup: return ret; =20 error: virStringListFree(tmp); - return NULL; + goto cleanup; } =20 =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list