From nobody Sun Feb 8 03:57:59 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 1550674034468824.1530308335316; Wed, 20 Feb 2019 06:47:14 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B567DB8392; Wed, 20 Feb 2019 14:47:07 +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 3E5D05D706; Wed, 20 Feb 2019 14:47:07 +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 BB3B5181A00C; Wed, 20 Feb 2019 14:47:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KEl2Wk021324 for ; Wed, 20 Feb 2019 09:47:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 63899611B6; Wed, 20 Feb 2019 14:47:02 +0000 (UTC) Received: from libvirt-fedora-29.redhat.com (ovpn-117-20.phx2.redhat.com [10.3.117.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id C243F17976; Wed, 20 Feb 2019 14:47:01 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 09:46:57 -0500 Message-Id: <20190220144659.7445-3-jferlan@redhat.com> In-Reply-To: <20190220144659.7445-1-jferlan@redhat.com> References: <20190220144659.7445-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] conf: Use VIR_AUTOPTR(virBitmap) in domain_conf 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-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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Feb 2019 14:47:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Let's make use of the auto __cleanup capabilities cleaning up any now unnecessary goto paths. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 53 ++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ceeb247ef4..ddcb76f05d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1803,8 +1803,8 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, virBitmapPtr autoCpuset) { int maxvcpus =3D virDomainDefGetVcpusMax(def); - virBitmapPtr allcpumap =3D NULL; size_t i; + VIR_AUTOPTR(virBitmap) allcpumap =3D NULL; =20 if (hostcpus < 0) return -1; @@ -1831,7 +1831,6 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, i), map= len); } =20 - virBitmapFree(allcpumap); return i; } =20 @@ -2984,11 +2983,10 @@ static int virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, unsigned int iothreads) { - int retval =3D -1; size_t i; ssize_t nxt =3D -1; virDomainIOThreadIDDefPtr iothrid =3D NULL; - virBitmapPtr thrmap =3D NULL; + VIR_AUTOPTR(virBitmap) thrmap =3D NULL; =20 /* Same value (either 0 or some number), then we have none to fill in = or * the iothreadid array was filled from the XML @@ -2998,7 +2996,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, =20 /* iothread's are numbered starting at 1, account for that */ if (!(thrmap =3D virBitmapNew(iothreads + 1))) - goto error; + return -1; virBitmapSetAll(thrmap); =20 /* Clear 0 since we don't use it, then mark those which are @@ -3010,27 +3008,23 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, =20 /* resize array */ if (VIR_REALLOC_N(def->iothreadids, iothreads) < 0) - goto error; + return -1; =20 /* Populate iothreadids[] using the set bit number from thrmap */ while (def->niothreadids < iothreads) { if ((nxt =3D virBitmapNextSetBit(thrmap, nxt)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to populate iothreadids")); - goto error; + return -1; } if (VIR_ALLOC(iothrid) < 0) - goto error; + return -1; iothrid->iothread_id =3D nxt; iothrid->autofill =3D true; def->iothreadids[def->niothreadids++] =3D iothrid; } =20 - retval =3D 0; - - error: - virBitmapFree(thrmap); - return retval; + return 0; } =20 =20 @@ -18327,9 +18321,9 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, { int ret =3D -1; virDomainIOThreadIDDefPtr iothrid; - virBitmapPtr cpumask =3D NULL; unsigned int iothreadid; char *tmp =3D NULL; + VIR_AUTOPTR(virBitmap) cpumask =3D NULL; =20 if (!(tmp =3D virXMLPropString(node, "iothread"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -18385,7 +18379,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, =20 cleanup: VIR_FREE(tmp); - virBitmapFree(cpumask); return ret; } =20 @@ -18397,8 +18390,9 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, static virBitmapPtr virDomainEmulatorPinDefParseXML(xmlNodePtr node) { - virBitmapPtr def =3D NULL; + virBitmapPtr ret =3D NULL; char *tmp =3D NULL; + VIR_AUTOPTR(virBitmap) def =3D NULL; =20 if (!(tmp =3D virXMLPropString(node, "cpuset"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -18412,14 +18406,14 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node) if (virBitmapIsAllClear(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid value of 'cpuset': %s"), tmp); - virBitmapFree(def); - def =3D NULL; goto cleanup; } =20 + VIR_STEAL_PTR(ret, def); + cleanup: VIR_FREE(tmp); - return def; + return ret; } =20 =20 @@ -18778,35 +18772,30 @@ virDomainThreadSchedParseHelper(xmlNodePtr node, virDomainDefPtr def) { ssize_t next =3D -1; - virBitmapPtr map =3D NULL; virDomainThreadSchedParamPtr sched; virProcessSchedPolicy policy; int priority; - int ret =3D -1; + VIR_AUTOPTR(virBitmap) map =3D NULL; =20 if (!(map =3D virDomainSchedulerParse(node, name, &policy, &priority))) - goto cleanup; + return -1; =20 while ((next =3D virBitmapNextSetBit(map, next)) > -1) { if (!(sched =3D func(def, next))) - goto cleanup; + return -1; =20 if (sched->policy !=3D VIR_PROC_POLICY_NONE) { virReportError(VIR_ERR_XML_DETAIL, _("%ssched attributes 'vcpus' must not overlap"= ), name); - goto cleanup; + return -1; } =20 sched->policy =3D policy; sched->priority =3D priority; } =20 - ret =3D 0; - - cleanup: - virBitmapFree(map); - return ret; + return 0; } =20 =20 @@ -19509,12 +19498,12 @@ virDomainCachetuneDefParse(virDomainDefPtr def, { xmlNodePtr oldnode =3D ctxt->node; xmlNodePtr *nodes =3D NULL; - virBitmapPtr vcpus =3D NULL; virResctrlAllocPtr alloc =3D NULL; virDomainResctrlDefPtr resctrl =3D NULL; ssize_t i =3D 0; int n; int ret =3D -1; + VIR_AUTOPTR(virBitmap) vcpus =3D NULL; =20 ctxt->node =3D node; =20 @@ -19574,7 +19563,6 @@ virDomainCachetuneDefParse(virDomainDefPtr def, ctxt->node =3D oldnode; virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); - virBitmapFree(vcpus); VIR_FREE(nodes); return ret; } @@ -19728,9 +19716,9 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, { xmlNodePtr oldnode =3D ctxt->node; xmlNodePtr *nodes =3D NULL; - virBitmapPtr vcpus =3D NULL; virResctrlAllocPtr alloc =3D NULL; virDomainResctrlDefPtr resctrl =3D NULL; + VIR_AUTOPTR(virBitmap) vcpus =3D NULL; =20 ssize_t i =3D 0; int n; @@ -19789,7 +19777,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, ctxt->node =3D oldnode; virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); - virBitmapFree(vcpus); VIR_FREE(nodes); return ret; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list