From nobody Wed May 14 12:04:09 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 1522272015284498.80481723808; Wed, 28 Mar 2018 14:20:15 -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 B4DA5C0528AC; Wed, 28 Mar 2018 21:20:13 +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 8CE8A60240; Wed, 28 Mar 2018 21:20: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 4E615180BAD3; Wed, 28 Mar 2018 21:20:13 +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 w2SLJhAP000521 for ; Wed, 28 Mar 2018 17:19:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id DDA4563143; Wed, 28 Mar 2018 21:19:43 +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 9CAA563142 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:30 -0400 Message-Id: <20180328211933.8033-7-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 6/9] storage: Clean up storagePoolCreateXML 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.31]); Wed, 28 Mar 2018 21:20:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than 3 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/storage/storage_driver.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index d5e38af5a..6276545eb 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -744,22 +744,14 @@ storagePoolCreateXML(virConnectPtr conn, =20 if (build_flags || (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) { - if (backend->buildPool(obj, build_flags) < 0) { - virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; - goto cleanup; - } + if (backend->buildPool(obj, build_flags) < 0) + goto error; } } =20 if (backend->startPool && - backend->startPool(obj) < 0) { - virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; - goto cleanup; - } + backend->startPool(obj) < 0) + goto error; =20 stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xml"); =20 @@ -770,10 +762,7 @@ storagePoolCreateXML(virConnectPtr conn, unlink(stateFile); if (backend->stopPool) backend->stopPool(obj); - virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; - goto cleanup; + goto error; } =20 event =3D virStoragePoolEventLifecycleNew(def->name, @@ -793,6 +782,12 @@ storagePoolCreateXML(virConnectPtr conn, virObjectEventStateQueue(driver->storageEventState, event); virStoragePoolObjEndAPI(&obj); return pool; + + error: + virStoragePoolObjRemove(driver->pools, obj); + virObjectUnref(obj); + obj =3D NULL; + goto cleanup; } =20 static virStoragePoolPtr --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list