From nobody Sun Feb 8 14:12:13 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.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; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1493159846434285.22804180067544; Tue, 25 Apr 2017 15:37:26 -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 C69FC46D091; Tue, 25 Apr 2017 22:37:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A75A18115; Tue, 25 Apr 2017 22:37:24 +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 357865EC62; Tue, 25 Apr 2017 22:37:24 +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 v3PMb30w029187 for ; Tue, 25 Apr 2017 18:37:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3AEB91811B; Tue, 25 Apr 2017 22:37:03 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB99360E3E for ; Tue, 25 Apr 2017 22:37:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C69FC46D091 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C69FC46D091 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 25 Apr 2017 18:36:50 -0400 Message-Id: <20170425223656.20740-3-jferlan@redhat.com> In-Reply-To: <20170425223656.20740-1-jferlan@redhat.com> References: <20170425223656.20740-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/8] interface: Remove some unnecessary goto's for Interface tests 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.29]); Tue, 25 Apr 2017 22:37:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than using goto cleanup on object find failure and having cleanup need to check if the obj was present before unlocking, just return immediat= ely. Signed-off-by: John Ferlan --- src/test/test_driver.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c2697e8..da45542 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3709,13 +3709,11 @@ testInterfaceLookupByName(virConnectPtr conn, virInterfacePtr ret =3D NULL; =20 if (!(obj =3D testInterfaceObjFindByName(privconn, name))) - goto cleanup; + return NULL; =20 ret =3D virGetInterface(conn, obj->def->name, obj->def->mac); =20 - cleanup: - if (obj) - virInterfaceObjUnlock(obj); + virInterfaceObjUnlock(obj); return ret; } =20 @@ -3760,13 +3758,11 @@ testInterfaceIsActive(virInterfacePtr iface) int ret =3D -1; =20 if (!(obj =3D testInterfaceObjFindByName(privconn, iface->name))) - goto cleanup; + return -1; =20 ret =3D virInterfaceObjIsActive(obj); =20 - cleanup: - if (obj) - virInterfaceObjUnlock(obj); + virInterfaceObjUnlock(obj); return ret; } =20 @@ -3875,13 +3871,11 @@ testInterfaceGetXMLDesc(virInterfacePtr iface, virCheckFlags(0, NULL); =20 if (!(obj =3D testInterfaceObjFindByName(privconn, iface->name))) - goto cleanup; + return NULL; =20 ret =3D virInterfaceDefFormat(obj->def); =20 - cleanup: - if (obj) - virInterfaceObjUnlock(obj); + virInterfaceObjUnlock(obj); return ret; } =20 @@ -3899,7 +3893,7 @@ testInterfaceDefineXML(virConnectPtr conn, virCheckFlags(0, NULL); =20 testDriverLock(privconn); - if ((def =3D virInterfaceDefParseString(xmlStr)) =3D=3D NULL) + if (!(def =3D virInterfaceDefParseString(xmlStr))) goto cleanup; =20 if ((obj =3D virInterfaceObjAssignDef(&privconn->ifaces, def)) =3D=3D = NULL) @@ -3922,16 +3916,13 @@ testInterfaceUndefine(virInterfacePtr iface) { testDriverPtr privconn =3D iface->conn->privateData; virInterfaceObjPtr obj; - int ret =3D -1; =20 if (!(obj =3D testInterfaceObjFindByName(privconn, iface->name))) - goto cleanup; + return -1; =20 virInterfaceObjRemove(&privconn->ifaces, obj); - ret =3D 0; =20 - cleanup: - return ret; + return 0; } =20 =20 @@ -3946,7 +3937,7 @@ testInterfaceCreate(virInterfacePtr iface, virCheckFlags(0, -1); =20 if (!(obj =3D testInterfaceObjFindByName(privconn, iface->name))) - goto cleanup; + return -1; =20 if (obj->active !=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, NULL); @@ -3957,8 +3948,7 @@ testInterfaceCreate(virInterfacePtr iface, ret =3D 0; =20 cleanup: - if (obj) - virInterfaceObjUnlock(obj); + virInterfaceObjUnlock(obj); return ret; } =20 @@ -3974,7 +3964,7 @@ testInterfaceDestroy(virInterfacePtr iface, virCheckFlags(0, -1); =20 if (!(obj =3D testInterfaceObjFindByName(privconn, iface->name))) - goto cleanup; + return -1; =20 if (obj->active =3D=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, NULL); @@ -3985,8 +3975,7 @@ testInterfaceDestroy(virInterfacePtr iface, ret =3D 0; =20 cleanup: - if (obj) - virInterfaceObjUnlock(obj); + virInterfaceObjUnlock(obj); return ret; } =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list