From nobody Wed May 14 15:45:57 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522272018554848.9842229098223; Wed, 28 Mar 2018 14:20:18 -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 D289C7F7AE; Wed, 28 Mar 2018 21:20:16 +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 A925860C8C; Wed, 28 Mar 2018 21:20:16 +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 6F88A4CAAB; Wed, 28 Mar 2018 21:20:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2SLJikO000527 for ; Wed, 28 Mar 2018 17:19:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 508BB63142; Wed, 28 Mar 2018 21:19:44 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-109.phx2.redhat.com [10.3.116.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10DE265AC0 for ; Wed, 28 Mar 2018 21:19:43 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 28 Mar 2018 17:19:31 -0400 Message-Id: <20180328211933.8033-8-jferlan@redhat.com> In-Reply-To: <20180328211933.8033-1-jferlan@redhat.com> References: <20180328211933.8033-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 7/9] test: Clean up testStoragePoolCreateXML error processing 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: , MIME-Version: 1.0 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.28]); Wed, 28 Mar 2018 21:20:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than 2 separate, but same 4 lines of code - let's create an error label to make a common error path. This will help shortly when the error path changes slightly. Signed-off-by: John Ferlan --- src/test/test_driver.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 568d537e9..0a284e3d1 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4562,20 +4562,12 @@ testStoragePoolCreateXML(virConnectPtr conn, * rename a few fields to mock that. */ if (testCreateVport(privconn, def->source.adapter.data.fchost.wwnn, - def->source.adapter.data.fchost.wwpn) < 0) { - virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); - obj =3D NULL; - goto cleanup; - } + def->source.adapter.data.fchost.wwpn) < 0) + goto error; } =20 - if (testStoragePoolObjSetDefaults(obj) =3D=3D -1) { - virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); - obj =3D NULL; - goto cleanup; - } + if (testStoragePoolObjSetDefaults(obj) =3D=3D -1) + goto error; =20 /* *SetDefaults fills this in for the persistent pools, but this * would be a transient pool so remove it; otherwise, the Destroy @@ -4596,6 +4588,12 @@ testStoragePoolCreateXML(virConnectPtr conn, virStoragePoolObjEndAPI(&obj); testDriverUnlock(privconn); return pool; + + error: + virStoragePoolObjRemove(privconn->pools, obj); + virObjectUnref(obj); + obj =3D NULL; + goto cleanup; } =20 =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list