From nobody Thu May 2 11:26:13 2024 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 1550687662363355.0077819829037; Wed, 20 Feb 2019 10:34:22 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27C1B14BFE2; Wed, 20 Feb 2019 18:34:20 +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 E65A419023; Wed, 20 Feb 2019 18:34:19 +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 9E94D181A00A; Wed, 20 Feb 2019 18:34:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KIY6Ec026205 for ; Wed, 20 Feb 2019 13:34:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id B81F31001E78; Wed, 20 Feb 2019 18:34:06 +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 71AC21001943 for ; Wed, 20 Feb 2019 18:34:06 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 13:33:59 -0500 Message-Id: <20190220183404.31810-2-jferlan@redhat.com> In-Reply-To: <20190220183404.31810-1-jferlan@redhat.com> References: <20190220183404.31810-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/6] conf: Rework virDomainEmulatorPinDefParseXML 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Feb 2019 18:34:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In preparation for using auto free mechanism, change to using the VIR_STEAL_PTR on @def to @ret and of course be sure to properly clean up @def in cleanup. Signed-off-by: John Ferlan Reviewed-by: Erik Skultety --- src/conf/domain_conf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ceeb247ef4..542d53e709 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18398,6 +18398,7 @@ static virBitmapPtr virDomainEmulatorPinDefParseXML(xmlNodePtr node) { virBitmapPtr def =3D NULL; + virBitmapPtr ret =3D NULL; char *tmp =3D NULL; =20 if (!(tmp =3D virXMLPropString(node, "cpuset"))) { @@ -18412,14 +18413,15 @@ 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: + virBitmapFree(def); VIR_FREE(tmp); - return def; + return ret; } =20 =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 11:26:13 2024 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 1550687667605233.48948208428828; Wed, 20 Feb 2019 10:34:27 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 906213CBFF; Wed, 20 Feb 2019 18:34:24 +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 5F65E1001E96; Wed, 20 Feb 2019 18:34: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 0FA7E181A010; Wed, 20 Feb 2019 18:34:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KIY7UC026210 for ; Wed, 20 Feb 2019 13:34:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3DADC1001DE2; Wed, 20 Feb 2019 18:34:07 +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 E4AAB1001E8B for ; Wed, 20 Feb 2019 18:34:06 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 13:34:00 -0500 Message-Id: <20190220183404.31810-3-jferlan@redhat.com> In-Reply-To: <20190220183404.31810-1-jferlan@redhat.com> References: <20190220183404.31810-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/6] 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 20 Feb 2019 18:34:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Let's make use of the auto __cleanup capabilities for virBitmapPtr. Signed-off-by: John Ferlan Reviewed-by: Erik Skultety --- src/conf/domain_conf.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 542d53e709..f27af65d80 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 @@ -2988,7 +2987,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, 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 @@ -3029,7 +3028,6 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, retval =3D 0; =20 error: - virBitmapFree(thrmap); return retval; } =20 @@ -18327,9 +18325,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 +18383,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, =20 cleanup: VIR_FREE(tmp); - virBitmapFree(cpumask); return ret; } =20 @@ -18397,9 +18394,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", @@ -18419,7 +18416,6 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node) VIR_STEAL_PTR(ret, def); =20 cleanup: - virBitmapFree(def); VIR_FREE(tmp); return ret; } @@ -18780,11 +18776,11 @@ 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; @@ -18807,7 +18803,6 @@ virDomainThreadSchedParseHelper(xmlNodePtr node, ret =3D 0; =20 cleanup: - virBitmapFree(map); return ret; } =20 @@ -19511,12 +19506,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 @@ -19576,7 +19571,6 @@ virDomainCachetuneDefParse(virDomainDefPtr def, ctxt->node =3D oldnode; virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); - virBitmapFree(vcpus); VIR_FREE(nodes); return ret; } @@ -19730,9 +19724,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; @@ -19791,7 +19785,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 From nobody Thu May 2 11:26:13 2024 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 1550687654811679.8857181287808; Wed, 20 Feb 2019 10:34: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 04C3435A805; Wed, 20 Feb 2019 18:34:12 +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 8F13F5D71B; Wed, 20 Feb 2019 18:34:11 +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 CF4DB3FB14; Wed, 20 Feb 2019 18:34:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KIY7eh026215 for ; Wed, 20 Feb 2019 13:34:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id B192A1001DE2; Wed, 20 Feb 2019 18:34:07 +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 6B0DC1001E8B for ; Wed, 20 Feb 2019 18:34:07 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 13:34:01 -0500 Message-Id: <20190220183404.31810-4-jferlan@redhat.com> In-Reply-To: <20190220183404.31810-1-jferlan@redhat.com> References: <20190220183404.31810-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/6] conf: Clean up some unnecessary goto paths 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.29]); Wed, 20 Feb 2019 18:34:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Now that we're using VIR_AUTOPTR(virBitmap) there's a couple of methods that we can clean up some now unnecessary goto paths. Signed-off-by: John Ferlan Reviewed-by: Erik Skultety --- src/conf/domain_conf.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f27af65d80..ddcb76f05d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2983,7 +2983,6 @@ static int virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, unsigned int iothreads) { - int retval =3D -1; size_t i; ssize_t nxt =3D -1; virDomainIOThreadIDDefPtr iothrid =3D NULL; @@ -2997,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 @@ -3009,26 +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: - return retval; + return 0; } =20 =20 @@ -18779,31 +18775,27 @@ virDomainThreadSchedParseHelper(xmlNodePtr node, 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: - return ret; + return 0; } =20 =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 11:26:13 2024 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 1550687662430811.8180865509968; Wed, 20 Feb 2019 10:34:22 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8DF262072BD; Wed, 20 Feb 2019 18:34:20 +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 53429600C0; Wed, 20 Feb 2019 18:34:20 +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 ECE5C181A00C; Wed, 20 Feb 2019 18:34:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KIY8B9026225 for ; Wed, 20 Feb 2019 13:34:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id D90D21001E96; Wed, 20 Feb 2019 18:34:08 +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 DBB8C1001E8B for ; Wed, 20 Feb 2019 18:34:07 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 13:34:02 -0500 Message-Id: <20190220183404.31810-5-jferlan@redhat.com> In-Reply-To: <20190220183404.31810-1-jferlan@redhat.com> References: <20190220183404.31810-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 4/6] conf: Remove a few unused variables 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Feb 2019 18:34:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In preparation for VIR_AUTOFREE usage, let's remove a couple of unused variables so that clang compilations won't fail. Signed-off-by: John Ferlan Reviewed-by: Erik Skultety --- src/conf/domain_conf.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ddcb76f05d..1ec521a35d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7138,7 +7138,6 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xml= opt ATTRIBUTE_UNUSED, xmlNodePtr alias =3D NULL; xmlNodePtr boot =3D NULL; xmlNodePtr rom =3D NULL; - char *type =3D NULL; char *romenabled =3D NULL; char *rombar =3D NULL; char *aliasStr =3D NULL; @@ -7224,7 +7223,6 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xml= opt ATTRIBUTE_UNUSED, cleanup: if (ret < 0) virDomainDeviceInfoClear(info); - VIR_FREE(type); VIR_FREE(rombar); VIR_FREE(romenabled); VIR_FREE(aliasStr); @@ -13012,7 +13010,6 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlop= t, xmlXPathContextPtr ctxt, unsigned int flags) { - char *type =3D NULL; char *path =3D NULL; char *model =3D NULL; char *backend =3D NULL; @@ -13093,7 +13090,6 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; =20 cleanup: - VIR_FREE(type); VIR_FREE(path); VIR_FREE(model); VIR_FREE(backend); @@ -18548,7 +18544,7 @@ virDomainHugepagesParseXML(xmlNodePtr node, { int ret =3D -1; xmlNodePtr oldnode =3D ctxt->node; - char *unit =3D NULL, *nodeset =3D NULL; + char *nodeset =3D NULL; =20 ctxt->node =3D node; =20 @@ -18576,7 +18572,6 @@ virDomainHugepagesParseXML(xmlNodePtr node, =20 ret =3D 0; cleanup: - VIR_FREE(unit); VIR_FREE(nodeset); ctxt->node =3D oldnode; return ret; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 11:26:13 2024 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 1550687670458816.3100651782694; Wed, 20 Feb 2019 10:34:30 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95DB3357314; Wed, 20 Feb 2019 18:34:28 +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 4FFCC6014C; Wed, 20 Feb 2019 18:34:28 +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 0309A3FB14; Wed, 20 Feb 2019 18:34:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KIYAxK026235 for ; Wed, 20 Feb 2019 13:34:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2B94B1001E96; Wed, 20 Feb 2019 18:34:10 +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 144F31001E78 for ; Wed, 20 Feb 2019 18:34:08 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 13:34:03 -0500 Message-Id: <20190220183404.31810-6-jferlan@redhat.com> In-Reply-To: <20190220183404.31810-1-jferlan@redhat.com> References: <20190220183404.31810-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 5/6] conf: Use VIR_AUTOFREE 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 20 Feb 2019 18:34:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Let's make use of the auto __cleanup capabilities for VIR_FREE consumers. In some cases adding or removing blank lines for readability. Signed-off-by: John Ferlan Reviewed-by: Erik Skultety --- src/conf/domain_conf.c | 1080 +++++++++++++--------------------------- 1 file changed, 347 insertions(+), 733 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1ec521a35d..98a35b0296 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1099,11 +1099,11 @@ static int virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap, xmlNodePtr node) { - char *name =3D NULL; - char *state =3D NULL; int state_type; int name_type; int ret =3D -1; + VIR_AUTOFREE(char *) name =3D NULL; + VIR_AUTOFREE(char *) state =3D NULL; =20 if (!(name =3D virXMLPropString(node, "name"))) { virReportError(VIR_ERR_CONF_SYNTAX, "%s", @@ -1161,8 +1161,6 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDef= Ptr keywrap, ret =3D 0; =20 cleanup: - VIR_FREE(name); - VIR_FREE(state); return ret; } =20 @@ -1171,8 +1169,8 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlX= PathContextPtr ctxt) { size_t i; int ret =3D -1; - xmlNodePtr *nodes =3D NULL; int n; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 if ((n =3D virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0) return n; @@ -1194,7 +1192,6 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlX= PathContextPtr ctxt) cleanup: if (ret < 0) VIR_FREE(def->keywrap); - VIR_FREE(nodes); return ret; } =20 @@ -1267,10 +1264,10 @@ static int virDomainVirtioOptionsParseXML(xmlNodePtr driver, virDomainVirtioOptionsPtr *virtio) { - char *str =3D NULL; int ret =3D -1; int val; virDomainVirtioOptionsPtr res; + VIR_AUTOFREE(char *) str =3D NULL; =20 if (*virtio || !driver) return 0; @@ -1302,7 +1299,6 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver, ret =3D 0; =20 cleanup: - VIR_FREE(str); return ret; } =20 @@ -1344,8 +1340,8 @@ static int virDomainBlkioDeviceParseXML(xmlNodePtr root, virBlkioDevicePtr dev) { - char *c =3D NULL; xmlNodePtr node; + VIR_AUTOFREE(char *) c =3D NULL; =20 node =3D root->children; while (node) { @@ -1410,7 +1406,6 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root, return 0; =20 error: - VIR_FREE(c); VIR_FREE(dev->path); return -1; } @@ -5338,8 +5333,8 @@ virDomainDefCollectBootOrder(virDomainDefPtr def ATTR= IBUTE_UNUSED, void *data) { virHashTablePtr bootHash =3D data; - char *order =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) order =3D NULL; =20 if (info->bootIndex =3D=3D 0) return 0; @@ -5368,7 +5363,6 @@ virDomainDefCollectBootOrder(virDomainDefPtr def ATTR= IBUTE_UNUSED, ret =3D 0; =20 cleanup: - VIR_FREE(order); return ret; } =20 @@ -6889,8 +6883,8 @@ static int virDomainDeviceUSBMasterParseXML(xmlNodePtr node, virDomainDeviceUSBMasterPtr master) { - char *startport; int ret =3D -1; + VIR_AUTOFREE(char *) startport =3D NULL; =20 memset(master, 0, sizeof(*master)); =20 @@ -6906,7 +6900,6 @@ virDomainDeviceUSBMasterParseXML(xmlNodePtr node, ret =3D 0; =20 cleanup: - VIR_FREE(startport); return ret; } =20 @@ -6914,9 +6907,9 @@ static int virDomainDeviceBootParseXML(xmlNodePtr node, virDomainDeviceInfoPtr info) { - char *order; - char *loadparm =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) order =3D NULL; + VIR_AUTOFREE(char *) loadparm =3D NULL; =20 if (!(order =3D virXMLPropString(node, "order"))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -6950,8 +6943,6 @@ virDomainDeviceBootParseXML(xmlNodePtr node, ret =3D 0; =20 cleanup: - VIR_FREE(order); - VIR_FREE(loadparm); return ret; } =20 @@ -6960,8 +6951,8 @@ virDomainDeviceISAAddressParseXML(xmlNodePtr node, virDomainDeviceISAAddressPtr addr) { int ret =3D -1; - char *iobase; - char *irq; + VIR_AUTOFREE(char *) iobase =3D NULL; + VIR_AUTOFREE(char *) irq =3D NULL; =20 memset(addr, 0, sizeof(*addr)); =20 @@ -6984,8 +6975,6 @@ virDomainDeviceISAAddressParseXML(xmlNodePtr node, =20 ret =3D 0; cleanup: - VIR_FREE(iobase); - VIR_FREE(irq); return ret; } =20 @@ -6995,7 +6984,7 @@ virDomainDeviceDimmAddressParseXML(xmlNodePtr node, virDomainDeviceDimmAddressPtr addr) { int ret =3D -1; - char *tmp =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 if (!(tmp =3D virXMLPropString(node, "slot")) || virStrToLong_uip(tmp, NULL, 10, &addr->slot) < 0) { @@ -7012,15 +7001,11 @@ virDomainDeviceDimmAddressParseXML(xmlNodePtr node, _("invalid dimm base address '%s'"), tmp); goto cleanup; } - - VIR_FREE(tmp); } =20 ret =3D 0; =20 cleanup: - VIR_FREE(tmp); - return ret; } =20 @@ -7030,7 +7015,7 @@ virDomainDeviceAddressParseXML(xmlNodePtr address, virDomainDeviceInfoPtr info) { int ret =3D -1; - char *type =3D virXMLPropString(address, "type"); + VIR_AUTOFREE(char *) type =3D virXMLPropString(address, "type"); =20 if (type) { if ((info->type =3D virDomainDeviceAddressTypeFromString(type)) <= =3D 0) { @@ -7107,7 +7092,6 @@ virDomainDeviceAddressParseXML(xmlNodePtr address, =20 ret =3D 0; cleanup: - VIR_FREE(type); return ret; } =20 @@ -7138,10 +7122,10 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr x= mlopt ATTRIBUTE_UNUSED, xmlNodePtr alias =3D NULL; xmlNodePtr boot =3D NULL; xmlNodePtr rom =3D NULL; - char *romenabled =3D NULL; - char *rombar =3D NULL; - char *aliasStr =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) romenabled =3D NULL; + VIR_AUTOFREE(char *) rombar =3D NULL; + VIR_AUTOFREE(char *) aliasStr =3D NULL; =20 virDomainDeviceInfoClear(info); =20 @@ -7223,9 +7207,6 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xml= opt ATTRIBUTE_UNUSED, cleanup: if (ret < 0) virDomainDeviceInfoClear(info); - VIR_FREE(rombar); - VIR_FREE(romenabled); - VIR_FREE(aliasStr); return ret; } =20 @@ -7254,9 +7235,9 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, int ret =3D -1; bool got_product, got_vendor; xmlNodePtr cur; - char *startupPolicy =3D NULL; - char *autoAddress; virDomainHostdevSubsysUSBPtr usbsrc =3D &def->source.subsys.u.usb; + VIR_AUTOFREE(char *) startupPolicy =3D NULL; + VIR_AUTOFREE(char *) autoAddress =3D NULL; =20 if ((startupPolicy =3D virXMLPropString(node, "startupPolicy"))) { def->startupPolicy =3D @@ -7265,16 +7246,13 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr nod= e, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown startup policy '%s'"), startupPolicy); - VIR_FREE(startupPolicy); goto out; } - VIR_FREE(startupPolicy); } =20 if ((autoAddress =3D virXMLPropString(node, "autoAddress"))) { if (STREQ(autoAddress, "yes")) usbsrc->autoAddress =3D true; - VIR_FREE(autoAddress); } =20 /* Product can validly be 0, so we need some extra help to determine @@ -7286,24 +7264,22 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr nod= e, while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { if (virXMLNodeNameEqual(cur, "vendor")) { - char *vendor =3D virXMLPropString(cur, "id"); + VIR_AUTOFREE(char *) vendor =3D virXMLPropString(cur, "id"= ); =20 if (vendor) { got_vendor =3D true; if (virStrToLong_ui(vendor, NULL, 0, &usbsrc->vendor) = < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse vendor id %s"), ven= dor); - VIR_FREE(vendor); goto out; } - VIR_FREE(vendor); } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("usb vendor needs id")); goto out; } } else if (virXMLNodeNameEqual(cur, "product")) { - char* product =3D virXMLPropString(cur, "id"); + VIR_AUTOFREE(char *) product =3D virXMLPropString(cur, "id= "); =20 if (product) { got_product =3D true; @@ -7312,27 +7288,24 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr nod= e, virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse product %s"), product); - VIR_FREE(product); goto out; } - VIR_FREE(product); } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("usb product needs id")); goto out; } } else if (virXMLNodeNameEqual(cur, "address")) { - char *bus, *device; + VIR_AUTOFREE(char *) bus =3D NULL; + VIR_AUTOFREE(char *) device =3D NULL; =20 bus =3D virXMLPropString(cur, "bus"); if (bus) { if (virStrToLong_ui(bus, NULL, 0, &usbsrc->bus) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse bus %s"), bus); - VIR_FREE(bus); goto out; } - VIR_FREE(bus); } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("usb address needs bus id")); @@ -7345,10 +7318,8 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse device %s"), device); - VIR_FREE(device); goto out; } - VIR_FREE(device); } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("usb address needs device id")); @@ -7442,14 +7413,13 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr nod= e, } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && virXMLNodeNameEqual(cur, "state")) { /* Legacy back-compat. Don't add any more attributes here = */ - char *devaddr =3D virXMLPropString(cur, "devaddr"); + VIR_AUTOFREE(char *) devaddr =3D virXMLPropString(cur, "de= vaddr"); if (devaddr && virDomainParseLegacyDeviceAddress(devaddr, &def->info->addr.pci= ) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse devaddr parameter '%= s'"), devaddr); - VIR_FREE(devaddr); goto out; } def->info->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -7480,9 +7450,9 @@ virDomainStorageNetworkParseHost(xmlNodePtr hostnode, size_t *nhosts) { int ret =3D -1; - char *transport =3D NULL; - char *port =3D NULL; virStorageNetHostDef host; + VIR_AUTOFREE(char *) transport =3D NULL; + VIR_AUTOFREE(char *) port =3D NULL; =20 memset(&host, 0, sizeof(host)); host.transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; @@ -7536,8 +7506,6 @@ virDomainStorageNetworkParseHost(xmlNodePtr hostnode, =20 cleanup: virStorageNetHostDefClear(&host); - VIR_FREE(transport); - VIR_FREE(port); return ret; } =20 @@ -7569,8 +7537,10 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr= sourcenode, int ret =3D -1; bool got_address =3D false, got_adapter =3D false; xmlNodePtr cur; - char *bus =3D NULL, *target =3D NULL, *unit =3D NULL; virDomainHostdevSubsysSCSIHostPtr scsihostsrc =3D &scsisrc->u.host; + VIR_AUTOFREE(char *) bus =3D NULL; + VIR_AUTOFREE(char *) target =3D NULL; + VIR_AUTOFREE(char *) unit =3D NULL; =20 cur =3D sourcenode->children; while (cur !=3D NULL) { @@ -7645,9 +7615,6 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr = sourcenode, =20 ret =3D 0; cleanup: - VIR_FREE(bus); - VIR_FREE(target); - VIR_FREE(unit); return ret; } =20 @@ -7727,8 +7694,8 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sour= cenode, virDomainHostdevSubsysSCSIPtr scsisr= c, xmlXPathContextPtr ctxt) { - char *protocol =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) protocol =3D NULL; =20 if ((protocol =3D virXMLPropString(sourcenode, "protocol"))) { scsisrc->protocol =3D @@ -7747,7 +7714,6 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sour= cenode, ret =3D virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsi= src); =20 cleanup: - VIR_FREE(protocol); return ret; } =20 @@ -7755,10 +7721,10 @@ static int virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr sourcenode, virDomainHostdevDefPtr def) { - char *protocol =3D NULL; - char *wwpn =3D NULL; virDomainHostdevSubsysSCSIVHostPtr hostsrc =3D &def->source.subsys.u.s= csi_host; int ret =3D -1; + VIR_AUTOFREE(char *) protocol =3D NULL; + VIR_AUTOFREE(char *) wwpn =3D NULL; =20 if (!(protocol =3D virXMLPropString(sourcenode, "protocol"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -7800,8 +7766,6 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr= sourcenode, =20 ret =3D 0; cleanup: - VIR_FREE(wwpn); - VIR_FREE(protocol); return ret; } =20 @@ -7811,9 +7775,9 @@ virDomainHostdevSubsysMediatedDevDefParseXML(virDomai= nHostdevDefPtr def, { int ret =3D -1; unsigned char uuid[VIR_UUID_BUFLEN] =3D {0}; - char *uuidxml =3D NULL; xmlNodePtr node =3D NULL; virDomainHostdevSubsysMediatedDevPtr mdevsrc =3D &def->source.subsys.u= .mdev; + VIR_AUTOFREE(char *) uuidxml =3D NULL; =20 if (!(node =3D virXPathNode("./source/address", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -7837,7 +7801,6 @@ virDomainHostdevSubsysMediatedDevDefParseXML(virDomai= nHostdevDefPtr def, virUUIDFormat(uuid, mdevsrc->uuidstr); ret =3D 0; cleanup: - VIR_FREE(uuidxml); return ret; } =20 @@ -7849,17 +7812,17 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, unsigned int flags) { xmlNodePtr sourcenode; - char *managed =3D NULL; - char *sgio =3D NULL; - char *rawio =3D NULL; - char *backendStr =3D NULL; - char *model =3D NULL; - char *display =3D NULL; int backend; int ret =3D -1; virDomainHostdevSubsysPCIPtr pcisrc =3D &def->source.subsys.u.pci; virDomainHostdevSubsysSCSIPtr scsisrc =3D &def->source.subsys.u.scsi; virDomainHostdevSubsysMediatedDevPtr mdevsrc =3D &def->source.subsys.u= .mdev; + VIR_AUTOFREE(char *) managed =3D NULL; + VIR_AUTOFREE(char *) sgio =3D NULL; + VIR_AUTOFREE(char *) rawio =3D NULL; + VIR_AUTOFREE(char *) backendStr =3D NULL; + VIR_AUTOFREE(char *) model =3D NULL; + VIR_AUTOFREE(char *) display =3D NULL; =20 /* @managed can be read from the xml document - it is always an * attribute of the toplevel element, no matter what type of @@ -8019,12 +7982,6 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, =20 ret =3D 0; cleanup: - VIR_FREE(managed); - VIR_FREE(sgio); - VIR_FREE(rawio); - VIR_FREE(backendStr); - VIR_FREE(model); - VIR_FREE(display); return ret; } =20 @@ -8032,12 +7989,14 @@ static virNetDevIPAddrPtr virDomainNetIPParseXML(xmlNodePtr node) { /* Parse the prefix in every case */ - virNetDevIPAddrPtr ip =3D NULL, ret =3D NULL; - char *prefixStr =3D NULL; + virNetDevIPAddrPtr ret =3D NULL; unsigned int prefixValue =3D 0; - char *familyStr =3D NULL; int family =3D AF_UNSPEC; - char *address =3D NULL, *peer =3D NULL; + VIR_AUTOFREE(virNetDevIPAddrPtr) ip =3D NULL; + VIR_AUTOFREE(char *) prefixStr =3D NULL; + VIR_AUTOFREE(char *) familyStr =3D NULL; + VIR_AUTOFREE(char *) address =3D NULL; + VIR_AUTOFREE(char *) peer =3D NULL; =20 if (!(address =3D virXMLPropString(node, "address"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -8085,11 +8044,6 @@ virDomainNetIPParseXML(xmlNodePtr node) VIR_STEAL_PTR(ret, ip); =20 cleanup: - VIR_FREE(prefixStr); - VIR_FREE(familyStr); - VIR_FREE(address); - VIR_FREE(peer); - VIR_FREE(ip); return ret; } =20 @@ -8104,12 +8058,12 @@ virDomainNetIPInfoParseXML(const char *source, xmlXPathContextPtr ctxt, virNetDevIPInfoPtr def) { - xmlNodePtr *nodes =3D NULL; - virNetDevIPAddrPtr ip =3D NULL; virNetDevIPRoutePtr route =3D NULL; int nnodes; int ret =3D -1; size_t i; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; + VIR_AUTOFREE(virNetDevIPAddrPtr) ip =3D NULL; =20 if ((nnodes =3D virXPathNodeSet("./ip", ctxt, &nodes)) < 0) goto cleanup; @@ -8134,9 +8088,7 @@ virDomainNetIPInfoParseXML(const char *source, cleanup: if (ret < 0) virNetDevIPInfoClear(def); - VIR_FREE(ip); virNetDevIPRouteFree(route); - VIR_FREE(nodes); return ret; } =20 @@ -8147,8 +8099,8 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node, { virNetDevCoalescePtr ret =3D NULL; xmlNodePtr save =3D NULL; - char *str =3D NULL; unsigned long long tmp =3D 0; + VIR_AUTOFREE(char *) str =3D NULL; =20 save =3D ctxt->node; ctxt->node =3D node; @@ -8164,10 +8116,8 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node, virReportError(VIR_ERR_XML_DETAIL, _("cannot parse value '%s' for coalesce parameter"), str); - VIR_FREE(str); goto error; } - VIR_FREE(str); =20 if (tmp > UINT32_MAX) { virReportError(VIR_ERR_OVERFLOW, @@ -8179,7 +8129,6 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node, ret->rx_max_coalesced_frames =3D tmp; =20 cleanup: - VIR_FREE(str); ctxt->node =3D save; return ret; =20 @@ -8554,8 +8503,9 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, { size_t i =3D 0, j; int n; - xmlNodePtr *list =3D NULL, saved_node; + xmlNodePtr saved_node; virCapsHostPtr host =3D &caps->host; + VIR_AUTOFREE(xmlNodePtr *) list =3D NULL; =20 /* Check args and save context */ if (def =3D=3D NULL || ctxt =3D=3D NULL) @@ -8593,7 +8543,6 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, } def->nseclabels =3D n; ctxt->node =3D saved_node; - VIR_FREE(list); =20 /* libvirt versions prior to 0.10.0 support just a single seclabel ele= ment * in guest's XML and model attribute can be suppressed if type is non= e or @@ -8648,7 +8597,6 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, virSecurityLabelDefFree(def->seclabels[i - 1]); VIR_FREE(def->seclabels); def->nseclabels =3D 0; - VIR_FREE(list); return -1; } =20 @@ -8663,8 +8611,8 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLa= belDefPtr **seclabels_rtn, size_t nseclabels =3D 0; int n; size_t i, j; - xmlNodePtr *list =3D NULL; char *model, *relabel, *label, *labelskip; + VIR_AUTOFREE(xmlNodePtr *) list =3D NULL; =20 if ((n =3D virXPathNodeSet("./seclabel", ctxt, &list)) < 0) goto error; @@ -8732,7 +8680,6 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLa= belDefPtr **seclabels_rtn, goto error; } } - VIR_FREE(list); =20 *nseclabels_rtn =3D nseclabels; *seclabels_rtn =3D seclabels; @@ -8743,7 +8690,6 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLa= belDefPtr **seclabels_rtn, for (i =3D 0; i < nseclabels; i++) virSecurityDeviceLabelDefFree(seclabels[i]); VIR_FREE(seclabels); - VIR_FREE(list); return -1; } =20 @@ -8786,10 +8732,10 @@ virDomainLeaseDefParseXML(xmlNodePtr node) { virDomainLeaseDefPtr def; xmlNodePtr cur; - char *lockspace =3D NULL; - char *key =3D NULL; - char *path =3D NULL; - char *offset =3D NULL; + VIR_AUTOFREE(char *) lockspace =3D NULL; + VIR_AUTOFREE(char *) key =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; + VIR_AUTOFREE(char *) offset =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -8834,11 +8780,6 @@ virDomainLeaseDefParseXML(xmlNodePtr node) VIR_STEAL_PTR(def->path, path); =20 cleanup: - VIR_FREE(lockspace); - VIR_FREE(key); - VIR_FREE(path); - VIR_FREE(offset); - return def; =20 error: @@ -8851,9 +8792,9 @@ static int virDomainDiskSourcePoolDefParse(xmlNodePtr node, virStorageSourcePoolDefPtr *srcpool) { - char *mode =3D NULL; virStorageSourcePoolDefPtr source; int ret =3D -1; + VIR_AUTOFREE(char *) mode =3D NULL; =20 *srcpool =3D NULL; =20 @@ -8890,7 +8831,6 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, =20 cleanup: virStorageSourcePoolDefFree(source); - VIR_FREE(mode); return ret; } =20 @@ -8901,11 +8841,11 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, virStorageSourcePtr src, unsigned int flags) { - char *protocol =3D NULL; - char *haveTLS =3D NULL; - char *tlsCfg =3D NULL; int tlsCfgVal; int ret =3D -1; + VIR_AUTOFREE(char *) protocol =3D NULL; + VIR_AUTOFREE(char *) haveTLS =3D NULL; + VIR_AUTOFREE(char *) tlsCfg =3D NULL; =20 if (!(protocol =3D virXMLPropString(node, "protocol"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -8982,9 +8922,6 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, ret =3D 0; =20 cleanup: - VIR_FREE(tlsCfg); - VIR_FREE(haveTLS); - VIR_FREE(protocol); return ret; } =20 @@ -9139,11 +9076,11 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr c= txt, { xmlNodePtr save_ctxt =3D ctxt->node; xmlNodePtr source; - char *type =3D NULL; - char *format =3D NULL; - char *idx =3D NULL; int ret =3D -1; VIR_AUTOUNREF(virStorageSourcePtr) backingStore =3D NULL; + VIR_AUTOFREE(char *) type =3D NULL; + VIR_AUTOFREE(char *) format =3D NULL; + VIR_AUTOFREE(char *) idx =3D NULL; =20 if (!(ctxt->node =3D virXPathNode("./backingStore", ctxt))) { ret =3D 0; @@ -9204,9 +9141,6 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctx= t, ret =3D 0; =20 cleanup: - VIR_FREE(type); - VIR_FREE(format); - VIR_FREE(idx); ctxt->node =3D save_ctxt; return ret; } @@ -9302,11 +9236,11 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, virDomainXMLOptionPtr xmlopt) { xmlNodePtr mirrorNode; - char *mirrorFormat =3D NULL; - char *mirrorType =3D NULL; - char *ready =3D NULL; - char *blockJob =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) mirrorFormat =3D NULL; + VIR_AUTOFREE(char *) mirrorType =3D NULL; + VIR_AUTOFREE(char *) ready =3D NULL; + VIR_AUTOFREE(char *) blockJob =3D NULL; =20 if (!(def->mirror =3D virStorageSourceNew())) goto cleanup; @@ -9379,10 +9313,6 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, ret =3D 0; =20 cleanup: - VIR_FREE(ready); - VIR_FREE(blockJob); - VIR_FREE(mirrorType); - VIR_FREE(mirrorFormat); return ret; } =20 @@ -9391,7 +9321,7 @@ static int virDomainDiskDefGeometryParse(virDomainDiskDefPtr def, xmlNodePtr cur) { - char *tmp; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 if ((tmp =3D virXMLPropString(cur, "cyls"))) { if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.cylinders) < 0) { @@ -9428,13 +9358,11 @@ virDomainDiskDefGeometryParse(virDomainDiskDefPtr d= ef, tmp); goto error; } - VIR_FREE(tmp); } =20 return 0; =20 error: - VIR_FREE(tmp); return -1; } =20 @@ -9579,8 +9507,8 @@ static int virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def, xmlNodePtr cur) { - char *tmp =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 def->driverName =3D virXMLPropString(cur, "name"); =20 @@ -9689,13 +9617,10 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr = def, tmp); goto cleanup; } - VIR_FREE(tmp); =20 ret =3D 0; =20 cleanup: - VIR_FREE(tmp); - return ret; } =20 @@ -9744,26 +9669,26 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlo= pt, virDomainDiskDefPtr def; xmlNodePtr cur; xmlNodePtr save_ctxt =3D ctxt->node; - char *tmp =3D NULL; - char *snapshot =3D NULL; - char *rawio =3D NULL; - char *sgio =3D NULL; bool source =3D false; - char *target =3D NULL; - char *bus =3D NULL; - char *devaddr =3D NULL; virStorageEncryptionPtr encryption =3D NULL; - char *serial =3D NULL; - char *startupPolicy =3D NULL; - char *tray =3D NULL; - char *removable =3D NULL; - char *logical_block_size =3D NULL; - char *physical_block_size =3D NULL; - char *wwn =3D NULL; - char *vendor =3D NULL; - char *product =3D NULL; - char *domain_name =3D NULL; VIR_AUTOPTR(virStorageAuthDef) authdef =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; + VIR_AUTOFREE(char *) snapshot =3D NULL; + VIR_AUTOFREE(char *) rawio =3D NULL; + VIR_AUTOFREE(char *) sgio =3D NULL; + VIR_AUTOFREE(char *) target =3D NULL; + VIR_AUTOFREE(char *) bus =3D NULL; + VIR_AUTOFREE(char *) devaddr =3D NULL; + VIR_AUTOFREE(char *) serial =3D NULL; + VIR_AUTOFREE(char *) startupPolicy =3D NULL; + VIR_AUTOFREE(char *) tray =3D NULL; + VIR_AUTOFREE(char *) removable =3D NULL; + VIR_AUTOFREE(char *) logical_block_size =3D NULL; + VIR_AUTOFREE(char *) physical_block_size =3D NULL; + VIR_AUTOFREE(char *) wwn =3D NULL; + VIR_AUTOFREE(char *) vendor =3D NULL; + VIR_AUTOFREE(char *) product =3D NULL; + VIR_AUTOFREE(char *) domain_name =3D NULL; =20 if (!(def =3D virDomainDiskDefNew(xmlopt))) return NULL; @@ -10151,25 +10076,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, goto error; =20 cleanup: - VIR_FREE(tmp); - VIR_FREE(bus); - VIR_FREE(snapshot); - VIR_FREE(rawio); - VIR_FREE(sgio); - VIR_FREE(target); - VIR_FREE(tray); - VIR_FREE(removable); - VIR_FREE(devaddr); - VIR_FREE(serial); virStorageEncryptionFree(encryption); - VIR_FREE(startupPolicy); - VIR_FREE(logical_block_size); - VIR_FREE(physical_block_size); - VIR_FREE(wwn); - VIR_FREE(vendor); - VIR_FREE(product); - VIR_FREE(domain_name); - ctxt->node =3D save_ctxt; return def; =20 @@ -10210,11 +10117,11 @@ virDomainParseScaledValue(const char *xpath, unsigned long long max, bool required) { - char *xpath_full =3D NULL; - char *unit =3D NULL; - char *bytes_str =3D NULL; int ret =3D -1; unsigned long long bytes; + VIR_AUTOFREE(char *) xpath_full =3D NULL; + VIR_AUTOFREE(char *) unit =3D NULL; + VIR_AUTOFREE(char *) bytes_str =3D NULL; =20 *val =3D 0; if (virAsprintf(&xpath_full, "string(%s)", xpath) < 0) @@ -10253,9 +10160,6 @@ virDomainParseScaledValue(const char *xpath, *val =3D bytes; ret =3D 1; cleanup: - VIR_FREE(bytes_str); - VIR_FREE(xpath_full); - VIR_FREE(unit); return ret; } =20 @@ -10456,27 +10360,27 @@ virDomainControllerDefParseXML(virDomainXMLOption= Ptr xmlopt, virDomainControllerDefPtr def =3D NULL; int type =3D 0; xmlNodePtr cur =3D NULL; - char *typeStr =3D NULL; - char *idx =3D NULL; - char *model =3D NULL; - char *queues =3D NULL; - char *cmd_per_lun =3D NULL; - char *max_sectors =3D NULL; bool processedModel =3D false; - char *modelName =3D NULL; bool processedTarget =3D false; - char *chassisNr =3D NULL; - char *chassis =3D NULL; - char *port =3D NULL; - char *busNr =3D NULL; - char *targetIndex =3D NULL; int numaNode =3D -1; - char *ioeventfd =3D NULL; - char *portsStr =3D NULL; int ports =3D -1; - char *iothread =3D NULL; xmlNodePtr saved =3D ctxt->node; int rc; + VIR_AUTOFREE(char *) typeStr =3D NULL; + VIR_AUTOFREE(char *) idx =3D NULL; + VIR_AUTOFREE(char *) model =3D NULL; + VIR_AUTOFREE(char *) queues =3D NULL; + VIR_AUTOFREE(char *) cmd_per_lun =3D NULL; + VIR_AUTOFREE(char *) max_sectors =3D NULL; + VIR_AUTOFREE(char *) modelName =3D NULL; + VIR_AUTOFREE(char *) chassisNr =3D NULL; + VIR_AUTOFREE(char *) chassis =3D NULL; + VIR_AUTOFREE(char *) port =3D NULL; + VIR_AUTOFREE(char *) busNr =3D NULL; + VIR_AUTOFREE(char *) targetIndex =3D NULL; + VIR_AUTOFREE(char *) ioeventfd =3D NULL; + VIR_AUTOFREE(char *) portsStr =3D NULL; + VIR_AUTOFREE(char *) iothread =3D NULL; =20 ctxt->node =3D node; =20 @@ -10615,20 +10519,18 @@ virDomainControllerDefParseXML(virDomainXMLOption= Ptr xmlopt, =20 switch (def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: { - def->opts.vioserial.ports =3D ports; + VIR_AUTOFREE(char *) vectors =3D virXMLPropString(node, "vectors"); =20 - char *vectors =3D virXMLPropString(node, "vectors"); + def->opts.vioserial.ports =3D ports; if (vectors) { int r =3D virStrToLong_i(vectors, NULL, 10, &def->opts.vioserial.vectors); if (r !=3D 0 || def->opts.vioserial.vectors < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid vectors: %s"), vectors); - VIR_FREE(vectors); goto error; } } - VIR_FREE(vectors); break; } case VIR_DOMAIN_CONTROLLER_TYPE_USB: { @@ -10791,22 +10693,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, =20 cleanup: ctxt->node =3D saved; - VIR_FREE(typeStr); - VIR_FREE(idx); - VIR_FREE(model); - VIR_FREE(queues); - VIR_FREE(cmd_per_lun); - VIR_FREE(max_sectors); - VIR_FREE(modelName); - VIR_FREE(chassisNr); - VIR_FREE(chassis); - VIR_FREE(port); - VIR_FREE(busNr); - VIR_FREE(targetIndex); - VIR_FREE(ioeventfd); - VIR_FREE(portsStr); - VIR_FREE(iothread); - return def; =20 error: @@ -10835,15 +10721,15 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlo= pt, { virDomainFSDefPtr def; xmlNodePtr cur, save_node =3D ctxt->node; - char *type =3D NULL; - char *fsdriver =3D NULL; - char *source =3D NULL; - char *target =3D NULL; - char *format =3D NULL; - char *accessmode =3D NULL; - char *wrpolicy =3D NULL; - char *usage =3D NULL; - char *units =3D NULL; + VIR_AUTOFREE(char *) type =3D NULL; + VIR_AUTOFREE(char *) fsdriver =3D NULL; + VIR_AUTOFREE(char *) source =3D NULL; + VIR_AUTOFREE(char *) target =3D NULL; + VIR_AUTOFREE(char *) format =3D NULL; + VIR_AUTOFREE(char *) accessmode =3D NULL; + VIR_AUTOFREE(char *) wrpolicy =3D NULL; + VIR_AUTOFREE(char *) usage =3D NULL; + VIR_AUTOFREE(char *) units =3D NULL; =20 ctxt->node =3D node; =20 @@ -10989,16 +10875,6 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlop= t, =20 cleanup: ctxt->node =3D save_node; - VIR_FREE(type); - VIR_FREE(fsdriver); - VIR_FREE(target); - VIR_FREE(source); - VIR_FREE(accessmode); - VIR_FREE(wrpolicy); - VIR_FREE(usage); - VIR_FREE(units); - VIR_FREE(format); - return def; =20 error: @@ -11020,11 +10896,11 @@ virDomainActualNetDefParseXML(xmlNodePtr node, xmlNodePtr bandwidth_node =3D NULL; xmlNodePtr vlanNode; xmlNodePtr virtPortNode; - char *type =3D NULL; - char *mode =3D NULL; - char *addrtype =3D NULL; - char *trustGuestRxFilters =3D NULL; - char *macTableManager =3D NULL; + VIR_AUTOFREE(char *) type =3D NULL; + VIR_AUTOFREE(char *) mode =3D NULL; + VIR_AUTOFREE(char *) addrtype =3D NULL; + VIR_AUTOFREE(char *) trustGuestRxFilters =3D NULL; + VIR_AUTOFREE(char *) macTableManager =3D NULL; =20 if (VIR_ALLOC(actual) < 0) return -1; @@ -11123,16 +10999,16 @@ virDomainActualNetDefParseXML(xmlNodePtr node, goto error; } } else if (actual->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - char *class_id =3D virXPathString("string(./class/@id)", ctxt); + VIR_AUTOFREE(char *) class_id =3D NULL; + + class_id =3D virXPathString("string(./class/@id)", ctxt); if (class_id && virStrToLong_ui(class_id, NULL, 10, &actual->class_id) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse class id '%s'"), class_id); - VIR_FREE(class_id); goto error; } - VIR_FREE(class_id); } if (actual->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || actual->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { @@ -11174,11 +11050,6 @@ virDomainActualNetDefParseXML(xmlNodePtr node, VIR_STEAL_PTR(*def, actual); ret =3D 0; error: - VIR_FREE(type); - VIR_FREE(mode); - VIR_FREE(addrtype); - VIR_FREE(trustGuestRxFilters); - VIR_FREE(macTableManager); virDomainActualNetDefFree(actual); =20 ctxt->node =3D save_ctxt; @@ -11221,9 +11092,9 @@ virDomainChrSourceReconnectDefParseXML(virDomainChr= SourceReconnectDefPtr def, { int ret =3D -1; int tmpVal; - char *tmp =3D NULL; xmlNodePtr saveNode =3D ctxt->node; xmlNodePtr cur; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 ctxt->node =3D node; =20 @@ -11247,7 +11118,6 @@ virDomainChrSourceReconnectDefParseXML(virDomainChr= SourceReconnectDefPtr def, tmp); goto cleanup; } - VIR_FREE(tmp); } else { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing timeout for chardev with " @@ -11260,7 +11130,6 @@ virDomainChrSourceReconnectDefParseXML(virDomainChr= SourceReconnectDefPtr def, ret =3D 0; cleanup: ctxt->node =3D saveNode; - VIR_FREE(tmp); return ret; } =20 @@ -11280,46 +11149,46 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xml= opt, virDomainHostdevDefPtr hostdev; xmlNodePtr cur; xmlNodePtr tmpNode; - char *macaddr =3D NULL; - char *type =3D NULL; - char *network =3D NULL; - char *portgroup =3D NULL; - char *bridge =3D NULL; - char *dev =3D NULL; - char *ifname =3D NULL; - char *ifname_guest =3D NULL; - char *ifname_guest_actual =3D NULL; - char *script =3D NULL; - char *address =3D NULL; - char *port =3D NULL; - char *localaddr =3D NULL; - char *localport =3D NULL; - char *model =3D NULL; - char *backend =3D NULL; - char *txmode =3D NULL; - char *ioeventfd =3D NULL; - char *event_idx =3D NULL; - char *queues =3D NULL; - char *rx_queue_size =3D NULL; - char *tx_queue_size =3D NULL; - char *str =3D NULL; - char *filter =3D NULL; - char *internal =3D NULL; - char *devaddr =3D NULL; - char *mode =3D NULL; - char *linkstate =3D NULL; - char *addrtype =3D NULL; - char *domain_name =3D NULL; - char *vhostuser_mode =3D NULL; - char *vhostuser_path =3D NULL; - char *vhostuser_type =3D NULL; - char *trustGuestRxFilters =3D NULL; - char *vhost_path =3D NULL; virHashTablePtr filterparams =3D NULL; virDomainActualNetDefPtr actual =3D NULL; xmlNodePtr oldnode =3D ctxt->node; virDomainChrSourceReconnectDef reconnect =3D {0}; int rv, val; + VIR_AUTOFREE(char *) macaddr =3D NULL; + VIR_AUTOFREE(char *) type =3D NULL; + VIR_AUTOFREE(char *) network =3D NULL; + VIR_AUTOFREE(char *) portgroup =3D NULL; + VIR_AUTOFREE(char *) bridge =3D NULL; + VIR_AUTOFREE(char *) dev =3D NULL; + VIR_AUTOFREE(char *) ifname =3D NULL; + VIR_AUTOFREE(char *) ifname_guest =3D NULL; + VIR_AUTOFREE(char *) ifname_guest_actual =3D NULL; + VIR_AUTOFREE(char *) script =3D NULL; + VIR_AUTOFREE(char *) address =3D NULL; + VIR_AUTOFREE(char *) port =3D NULL; + VIR_AUTOFREE(char *) localaddr =3D NULL; + VIR_AUTOFREE(char *) localport =3D NULL; + VIR_AUTOFREE(char *) model =3D NULL; + VIR_AUTOFREE(char *) backend =3D NULL; + VIR_AUTOFREE(char *) txmode =3D NULL; + VIR_AUTOFREE(char *) ioeventfd =3D NULL; + VIR_AUTOFREE(char *) event_idx =3D NULL; + VIR_AUTOFREE(char *) queues =3D NULL; + VIR_AUTOFREE(char *) rx_queue_size =3D NULL; + VIR_AUTOFREE(char *) tx_queue_size =3D NULL; + VIR_AUTOFREE(char *) str =3D NULL; + VIR_AUTOFREE(char *) filter =3D NULL; + VIR_AUTOFREE(char *) internal =3D NULL; + VIR_AUTOFREE(char *) devaddr =3D NULL; + VIR_AUTOFREE(char *) mode =3D NULL; + VIR_AUTOFREE(char *) linkstate =3D NULL; + VIR_AUTOFREE(char *) addrtype =3D NULL; + VIR_AUTOFREE(char *) domain_name =3D NULL; + VIR_AUTOFREE(char *) vhostuser_mode =3D NULL; + VIR_AUTOFREE(char *) vhostuser_path =3D NULL; + VIR_AUTOFREE(char *) vhostuser_type =3D NULL; + VIR_AUTOFREE(char *) trustGuestRxFilters =3D NULL; + VIR_AUTOFREE(char *) vhost_path =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -12067,44 +11936,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, =20 cleanup: ctxt->node =3D oldnode; - VIR_FREE(macaddr); - VIR_FREE(network); - VIR_FREE(portgroup); - VIR_FREE(address); - VIR_FREE(port); - VIR_FREE(vhostuser_type); - VIR_FREE(vhostuser_path); - VIR_FREE(vhostuser_mode); - VIR_FREE(ifname); - VIR_FREE(ifname_guest); - VIR_FREE(ifname_guest_actual); - VIR_FREE(dev); virDomainActualNetDefFree(actual); - VIR_FREE(script); - VIR_FREE(bridge); - VIR_FREE(model); - VIR_FREE(backend); - VIR_FREE(txmode); - VIR_FREE(ioeventfd); - VIR_FREE(event_idx); - VIR_FREE(queues); - VIR_FREE(rx_queue_size); - VIR_FREE(tx_queue_size); - VIR_FREE(str); - VIR_FREE(filter); - VIR_FREE(type); - VIR_FREE(internal); - VIR_FREE(devaddr); - VIR_FREE(mode); - VIR_FREE(linkstate); - VIR_FREE(addrtype); - VIR_FREE(domain_name); - VIR_FREE(trustGuestRxFilters); - VIR_FREE(vhost_path); - VIR_FREE(localaddr); - VIR_FREE(localport); virHashFree(filterparams); - return def; =20 error: @@ -12204,11 +12037,11 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr = def, int ret =3D -1; xmlNodePtr child; unsigned int port; - char *targetType =3D virXMLPropString(cur, "type"); - char *targetModel =3D NULL; - char *addrStr =3D NULL; - char *portStr =3D NULL; - char *stateStr =3D NULL; + VIR_AUTOFREE(char *) targetType =3D virXMLPropString(cur, "type"); + VIR_AUTOFREE(char *) targetModel =3D NULL; + VIR_AUTOFREE(char *) addrStr =3D NULL; + VIR_AUTOFREE(char *) portStr =3D NULL; + VIR_AUTOFREE(char *) stateStr =3D NULL; =20 if ((def->targetType =3D virDomainChrTargetTypeFromString(def->deviceType, @@ -12324,12 +12157,6 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr d= ef, =20 ret =3D 0; error: - VIR_FREE(targetType); - VIR_FREE(targetModel); - VIR_FREE(addrStr); - VIR_FREE(portStr); - VIR_FREE(stateStr); - return ret; } =20 @@ -12349,8 +12176,8 @@ typedef enum { static int virDomainChrSourceDefParseMode(xmlNodePtr source) { - char *mode =3D virXMLPropString(source, "mode"); int ret =3D -1; + VIR_AUTOFREE(char *) mode =3D virXMLPropString(source, "mode"); =20 if (!mode || STREQ(mode, "connect")) { ret =3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT; @@ -12361,7 +12188,6 @@ virDomainChrSourceDefParseMode(xmlNodePtr source) _("Unknown source mode '%s'"), mode); } =20 - VIR_FREE(mode); return ret; } =20 @@ -12373,8 +12199,8 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef= Ptr def, unsigned int flags) { int mode; - char *tmp =3D NULL; int tmpVal; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 if ((mode =3D virDomainChrSourceDefParseMode(source)) < 0) goto error; @@ -12402,7 +12228,6 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef= Ptr def, goto error; } def->data.tcp.tlsFromConfig =3D !!tmpVal; - VIR_FREE(tmp); } =20 if (virDomainChrSourceReconnectDefParseXML(&def->data.tcp.reconnect, @@ -12414,7 +12239,6 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef= Ptr def, return 0; =20 error: - VIR_FREE(tmp); return -1; } =20 @@ -12469,7 +12293,7 @@ static int virDomainChrSourceDefParseFile(virDomainChrSourceDefPtr def, xmlNodePtr source) { - char *append =3D NULL; + VIR_AUTOFREE(char *) append =3D NULL; =20 def->data.file.path =3D virXMLPropString(source, "path"); =20 @@ -12478,11 +12302,9 @@ virDomainChrSourceDefParseFile(virDomainChrSourceD= efPtr def, virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid append attribute value '%s'"), append); - VIR_FREE(append); return -1; } =20 - VIR_FREE(append); return 0; } =20 @@ -12491,7 +12313,7 @@ static int virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def, xmlNodePtr protocol) { - char *prot =3D NULL; + VIR_AUTOFREE(char *) prot =3D NULL; =20 if (def->type !=3D VIR_DOMAIN_CHR_TYPE_TCP) return 0; @@ -12501,11 +12323,9 @@ virDomainChrSourceDefParseProtocol(virDomainChrSou= rceDefPtr def, virDomainChrTcpProtocolTypeFromString(prot)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown protocol '%s'"), prot); - VIR_FREE(prot); return -1; } =20 - VIR_FREE(prot); return 0; } =20 @@ -12514,7 +12334,7 @@ static int virDomainChrSourceDefParseLog(virDomainChrSourceDefPtr def, xmlNodePtr log) { - char *append =3D NULL; + VIR_AUTOFREE(char *) append =3D NULL; =20 def->logfile =3D virXMLPropString(log, "file"); =20 @@ -12523,11 +12343,9 @@ virDomainChrSourceDefParseLog(virDomainChrSourceDe= fPtr def, virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid append attribute value '%s'"), append); - VIR_FREE(append); return -1; } =20 - VIR_FREE(append); return 0; } =20 @@ -12775,10 +12593,10 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xml= opt, unsigned int flags) { xmlNodePtr cur; - char *type =3D NULL; const char *nodeName; virDomainChrDefPtr def; bool seenTarget =3D false; + VIR_AUTOFREE(char *) type =3D NULL; =20 if (!(def =3D virDomainChrDefNew(xmlopt))) return NULL; @@ -12845,8 +12663,6 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlop= t, } =20 cleanup: - VIR_FREE(type); - return def; =20 error: @@ -12862,10 +12678,10 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionP= tr xmlopt, unsigned int flags) { xmlNodePtr cur; - char *mode =3D NULL; - char *type =3D NULL; virDomainSmartcardDefPtr def; size_t i; + VIR_AUTOFREE(char *) mode =3D NULL; + VIR_AUTOFREE(char *) type =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -12977,9 +12793,6 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr= xmlopt, } =20 cleanup: - VIR_FREE(mode); - VIR_FREE(type); - return def; =20 error: @@ -13010,14 +12823,14 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xml= opt, xmlXPathContextPtr ctxt, unsigned int flags) { - char *path =3D NULL; - char *model =3D NULL; - char *backend =3D NULL; - char *version =3D NULL; virDomainTPMDefPtr def; xmlNodePtr save =3D ctxt->node; - xmlNodePtr *backends =3D NULL; int nbackends; + VIR_AUTOFREE(char *) path =3D NULL; + VIR_AUTOFREE(char *) model =3D NULL; + VIR_AUTOFREE(char *) backend =3D NULL; + VIR_AUTOFREE(char *) version =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) backends =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -13090,11 +12903,6 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlo= pt, goto error; =20 cleanup: - VIR_FREE(path); - VIR_FREE(model); - VIR_FREE(backend); - VIR_FREE(backends); - VIR_FREE(version); ctxt->node =3D save; return def; =20 @@ -13110,7 +12918,7 @@ virDomainPanicDefParseXML(virDomainXMLOptionPtr xml= opt, unsigned int flags) { virDomainPanicDefPtr panic; - char *model =3D NULL; + VIR_AUTOFREE(char *) model =3D NULL; =20 if (VIR_ALLOC(panic) < 0) return NULL; @@ -13128,7 +12936,6 @@ virDomainPanicDefParseXML(virDomainXMLOptionPtr xml= opt, } =20 cleanup: - VIR_FREE(model); return panic; =20 error: @@ -13147,9 +12954,9 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xml= opt, { xmlNodePtr save =3D ctxt->node; virDomainInputDefPtr def; - char *evdev =3D NULL; - char *type =3D NULL; - char *bus =3D NULL; + VIR_AUTOFREE(char *) evdev =3D NULL; + VIR_AUTOFREE(char *) type =3D NULL; + VIR_AUTOFREE(char *) bus =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -13277,10 +13084,6 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xm= lopt, goto error; =20 cleanup: - VIR_FREE(evdev); - VIR_FREE(type); - VIR_FREE(bus); - ctxt->node =3D save; return def; =20 @@ -13298,7 +13101,7 @@ virDomainHubDefParseXML(virDomainXMLOptionPtr xmlop= t, unsigned int flags) { virDomainHubDefPtr def; - char *type =3D NULL; + VIR_AUTOFREE(char *) type =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -13321,8 +13124,6 @@ virDomainHubDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; =20 cleanup: - VIR_FREE(type); - return def; =20 error: @@ -13337,16 +13138,15 @@ static virDomainTimerDefPtr virDomainTimerDefParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt) { - char *name =3D NULL; - char *present =3D NULL; - char *tickpolicy =3D NULL; - char *track =3D NULL; - char *mode =3D NULL; - virDomainTimerDefPtr def; xmlNodePtr oldnode =3D ctxt->node; xmlNodePtr catchup; int ret; + VIR_AUTOFREE(char *) name =3D NULL; + VIR_AUTOFREE(char *) present =3D NULL; + VIR_AUTOFREE(char *) tickpolicy =3D NULL; + VIR_AUTOFREE(char *) track =3D NULL; + VIR_AUTOFREE(char *) mode =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -13449,11 +13249,6 @@ virDomainTimerDefParseXML(xmlNodePtr node, } =20 cleanup: - VIR_FREE(name); - VIR_FREE(present); - VIR_FREE(tickpolicy); - VIR_FREE(track); - VIR_FREE(mode); ctxt->node =3D oldnode; =20 return def; @@ -13469,8 +13264,8 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, virDomainGraphicsAuthDefPtr def, int type) { - char *validTo =3D NULL; - char *connected =3D virXMLPropString(node, "connected"); + VIR_AUTOFREE(char *) validTo =3D NULL; + VIR_AUTOFREE(char *) connected =3D virXMLPropString(node, "connected"); =20 def->passwd =3D virXMLPropString(node, "passwd"); =20 @@ -13498,11 +13293,9 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse password validity time '%s', ex= pect YYYY-MM-DDTHH:MM:SS"), validTo); - VIR_FREE(validTo); VIR_FREE(def->passwd); return -1; } - VIR_FREE(validTo); =20 tm.tm_year -=3D 1900; /* Human epoch starts at 0 BC, not 1900BC */ tm.tm_mon--; /* Humans start months at 1, computers at 0 */ @@ -13517,10 +13310,8 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown connected value %s"), connected); - VIR_FREE(connected); return -1; } - VIR_FREE(connected); =20 /* VNC supports connected=3D'keep' only */ if (type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC && @@ -13558,16 +13349,16 @@ virDomainGraphicsListenDefParseXML(virDomainGraph= icsListenDefPtr def, unsigned int flags) { int ret =3D -1; - char *type =3D virXMLPropString(node, "type"); - char *address =3D virXMLPropString(node, "address"); - char *network =3D virXMLPropString(node, "network"); - char *socketPath =3D virXMLPropString(node, "socket"); - char *fromConfig =3D virXMLPropString(node, "fromConfig"); - char *autoGenerated =3D virXMLPropString(node, "autoGenerated"); - char *addressCompat =3D NULL; - char *socketCompat =3D NULL; const char *graphicsType =3D virDomainGraphicsTypeToString(graphics->t= ype); int tmp, typeVal; + VIR_AUTOFREE(char *) type =3D virXMLPropString(node, "type"); + VIR_AUTOFREE(char *) address =3D virXMLPropString(node, "address"); + VIR_AUTOFREE(char *) network =3D virXMLPropString(node, "network"); + VIR_AUTOFREE(char *) socketPath =3D virXMLPropString(node, "socket"); + VIR_AUTOFREE(char *) fromConfig =3D virXMLPropString(node, "fromConfig= "); + VIR_AUTOFREE(char *) autoGenerated =3D virXMLPropString(node, "autoGen= erated"); + VIR_AUTOFREE(char *) addressCompat =3D NULL; + VIR_AUTOFREE(char *) socketCompat =3D NULL; =20 if (parent) { addressCompat =3D virXMLPropString(parent, "listen"); @@ -13692,14 +13483,6 @@ virDomainGraphicsListenDefParseXML(virDomainGraphi= csListenDefPtr def, error: if (ret < 0) virDomainGraphicsListenDefClear(def); - VIR_FREE(type); - VIR_FREE(address); - VIR_FREE(network); - VIR_FREE(socketPath); - VIR_FREE(fromConfig); - VIR_FREE(autoGenerated); - VIR_FREE(addressCompat); - VIR_FREE(socketCompat); return ret; } =20 @@ -13710,12 +13493,12 @@ virDomainGraphicsListensParseXML(virDomainGraphic= sDefPtr def, xmlXPathContextPtr ctxt, unsigned int flags) { - xmlNodePtr *listenNodes =3D NULL; xmlNodePtr save =3D ctxt->node; virDomainGraphicsListenDef newListen =3D {0}; - char *socketPath =3D NULL; int nListens; int ret =3D -1; + VIR_AUTOFREE(xmlNodePtr *) listenNodes =3D NULL; + VIR_AUTOFREE(char *) socketPath =3D NULL; =20 ctxt->node =3D node; =20 @@ -13739,7 +13522,6 @@ virDomainGraphicsListensParseXML(virDomainGraphicsD= efPtr def, =20 def->nListens++; } - VIR_FREE(listenNodes); } =20 /* If no element was found in XML for backward compatibility @@ -13782,8 +13564,6 @@ virDomainGraphicsListensParseXML(virDomainGraphicsD= efPtr def, ret =3D 0; cleanup: virDomainGraphicsListenDefClear(&newListen); - VIR_FREE(listenNodes); - VIR_FREE(socketPath); ctxt->node =3D save; return ret; } @@ -13795,12 +13575,12 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphics= DefPtr def, xmlXPathContextPtr ctxt, unsigned int flags) { - char *port =3D virXMLPropString(node, "port"); - char *websocket =3D virXMLPropString(node, "websocket"); - char *websocketGenerated =3D virXMLPropString(node, "websocketGenerate= d"); - char *sharePolicy =3D virXMLPropString(node, "sharePolicy"); - char *autoport =3D virXMLPropString(node, "autoport"); int ret =3D -1; + VIR_AUTOFREE(char *) port =3D virXMLPropString(node, "port"); + VIR_AUTOFREE(char *) websocket =3D virXMLPropString(node, "websocket"); + VIR_AUTOFREE(char *) websocketGenerated =3D virXMLPropString(node, "we= bsocketGenerated"); + VIR_AUTOFREE(char *) sharePolicy =3D virXMLPropString(node, "sharePoli= cy"); + VIR_AUTOFREE(char *) autoport =3D virXMLPropString(node, "autoport"); =20 if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) goto cleanup; @@ -13867,11 +13647,6 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsD= efPtr def, =20 ret =3D 0; cleanup: - VIR_FREE(port); - VIR_FREE(autoport); - VIR_FREE(websocket); - VIR_FREE(websocketGenerated); - VIR_FREE(sharePolicy); return ret; } =20 @@ -13882,11 +13657,11 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphics= DefPtr def, xmlXPathContextPtr ctxt) { xmlNodePtr save =3D ctxt->node; - char *enable =3D NULL; int enableVal; xmlNodePtr glNode; - char *fullscreen =3D virXMLPropString(node, "fullscreen"); int ret =3D -1; + VIR_AUTOFREE(char *) fullscreen =3D virXMLPropString(node, "fullscreen= "); + VIR_AUTOFREE(char *) enable =3D NULL; =20 ctxt->node =3D node; =20 @@ -13927,8 +13702,6 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDe= fPtr def, =20 ret =3D 0; cleanup: - VIR_FREE(fullscreen); - VIR_FREE(enable); ctxt->node =3D save; return ret; } @@ -13940,11 +13713,11 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphics= DefPtr def, xmlXPathContextPtr ctxt, unsigned int flags) { - char *port =3D virXMLPropString(node, "port"); - char *autoport =3D virXMLPropString(node, "autoport"); - char *replaceUser =3D virXMLPropString(node, "replaceUser"); - char *multiUser =3D virXMLPropString(node, "multiUser"); int ret =3D -1; + VIR_AUTOFREE(char *) port =3D virXMLPropString(node, "port"); + VIR_AUTOFREE(char *) autoport =3D virXMLPropString(node, "autoport"); + VIR_AUTOFREE(char *) replaceUser =3D virXMLPropString(node, "replaceUs= er"); + VIR_AUTOFREE(char *) multiUser =3D virXMLPropString(node, "multiUser"); =20 if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) goto error; @@ -13978,10 +13751,6 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsD= efPtr def, =20 ret =3D 0; error: - VIR_FREE(port); - VIR_FREE(autoport); - VIR_FREE(replaceUser); - VIR_FREE(multiUser); return ret; } =20 @@ -13990,8 +13759,8 @@ static int virDomainGraphicsDefParseXMLDesktop(virDomainGraphicsDefPtr def, xmlNodePtr node) { - char *fullscreen =3D virXMLPropString(node, "fullscreen"); int ret =3D -1; + VIR_AUTOFREE(char *) fullscreen =3D virXMLPropString(node, "fullscreen= "); =20 if (fullscreen !=3D NULL) { if (STREQ(fullscreen, "yes")) { @@ -14011,7 +13780,6 @@ virDomainGraphicsDefParseXMLDesktop(virDomainGraphi= csDefPtr def, =20 ret =3D 0; cleanup: - VIR_FREE(fullscreen); return ret; } =20 @@ -14023,12 +13791,12 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, unsigned int flags) { xmlNodePtr cur; - char *port =3D virXMLPropString(node, "port"); - char *tlsPort =3D virXMLPropString(node, "tlsPort"); - char *autoport =3D virXMLPropString(node, "autoport"); - char *defaultMode =3D virXMLPropString(node, "defaultMode"); int defaultModeVal; int ret =3D -1; + VIR_AUTOFREE(char *) port =3D virXMLPropString(node, "port"); + VIR_AUTOFREE(char *) tlsPort =3D virXMLPropString(node, "tlsPort"); + VIR_AUTOFREE(char *) autoport =3D virXMLPropString(node, "autoport"); + VIR_AUTOFREE(char *) defaultMode =3D virXMLPropString(node, "defaultMo= de"); =20 if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) goto error; @@ -14088,16 +13856,16 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { if (virXMLNodeNameEqual(cur, "channel")) { - char *name, *mode; int nameval, modeval; + VIR_AUTOFREE(char *) name =3D NULL; + VIR_AUTOFREE(char *) mode =3D NULL; + name =3D virXMLPropString(cur, "name"); mode =3D virXMLPropString(cur, "mode"); =20 if (!name || !mode) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("spice channel missing name/mode")); - VIR_FREE(name); - VIR_FREE(mode); goto error; } =20 @@ -14105,25 +13873,19 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice channel name %s"), name); - VIR_FREE(name); - VIR_FREE(mode); goto error; } if ((modeval =3D virDomainGraphicsSpiceChannelModeTypeFrom= String(mode)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice channel mode %s"), mode); - VIR_FREE(name); - VIR_FREE(mode); goto error; } - VIR_FREE(name); - VIR_FREE(mode); =20 def->data.spice.channels[nameval] =3D modeval; } else if (virXMLNodeNameEqual(cur, "image")) { - char *compression =3D virXMLPropString(cur, "compression"); int compressionVal; + VIR_AUTOFREE(char *) compression =3D virXMLPropString(cur,= "compression"); =20 if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -14136,15 +13898,13 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice image compression %s"), compression); - VIR_FREE(compression); goto error; } - VIR_FREE(compression); =20 def->data.spice.image =3D compressionVal; } else if (virXMLNodeNameEqual(cur, "jpeg")) { - char *compression =3D virXMLPropString(cur, "compression"); int compressionVal; + VIR_AUTOFREE(char *) compression =3D virXMLPropString(cur,= "compression"); =20 if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -14157,15 +13917,13 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice jpeg compression %s"), compression); - VIR_FREE(compression); goto error; } - VIR_FREE(compression); =20 def->data.spice.jpeg =3D compressionVal; } else if (virXMLNodeNameEqual(cur, "zlib")) { - char *compression =3D virXMLPropString(cur, "compression"); int compressionVal; + VIR_AUTOFREE(char *) compression =3D virXMLPropString(cur,= "compression"); =20 if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -14178,15 +13936,13 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice zlib compression %s"), compression); - VIR_FREE(compression); goto error; } - VIR_FREE(compression); =20 def->data.spice.zlib =3D compressionVal; } else if (virXMLNodeNameEqual(cur, "playback")) { - char *compression =3D virXMLPropString(cur, "compression"); int compressionVal; + VIR_AUTOFREE(char *) compression =3D virXMLPropString(cur,= "compression"); =20 if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -14198,16 +13954,14 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, virTristateSwitchTypeFromString(compression)) <=3D 0)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unknown spice playback compression")= ); - VIR_FREE(compression); goto error; =20 } - VIR_FREE(compression); =20 def->data.spice.playback =3D compressionVal; } else if (virXMLNodeNameEqual(cur, "streaming")) { - char *mode =3D virXMLPropString(cur, "mode"); int modeVal; + VIR_AUTOFREE(char *) mode =3D virXMLPropString(cur, "mode"= ); =20 if (!mode) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -14218,16 +13972,14 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, virDomainGraphicsSpiceStreamingModeTypeFromString(mod= e)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unknown spice streaming mode")); - VIR_FREE(mode); goto error; =20 } - VIR_FREE(mode); =20 def->data.spice.streaming =3D modeVal; } else if (virXMLNodeNameEqual(cur, "clipboard")) { - char *copypaste =3D virXMLPropString(cur, "copypaste"); int copypasteVal; + VIR_AUTOFREE(char *) copypaste =3D virXMLPropString(cur, "= copypaste"); =20 if (!copypaste) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -14239,15 +13991,13 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, virTristateBoolTypeFromString(copypaste)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown copypaste value '%s'"), copy= paste); - VIR_FREE(copypaste); goto error; } - VIR_FREE(copypaste); =20 def->data.spice.copypaste =3D copypasteVal; } else if (virXMLNodeNameEqual(cur, "filetransfer")) { - char *enable =3D virXMLPropString(cur, "enable"); int enableVal; + VIR_AUTOFREE(char *) enable =3D virXMLPropString(cur, "ena= ble"); =20 if (!enable) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -14259,21 +14009,18 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, virTristateBoolTypeFromString(enable)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown enable value '%s'"), enable); - VIR_FREE(enable); goto error; } - VIR_FREE(enable); =20 def->data.spice.filetransfer =3D enableVal; } else if (virXMLNodeNameEqual(cur, "gl")) { - char *enable =3D virXMLPropString(cur, "enable"); - char *rendernode =3D virXMLPropString(cur, "rendernode"); int enableVal; + VIR_AUTOFREE(char *) enable =3D virXMLPropString(cur, "ena= ble"); + VIR_AUTOFREE(char *) rendernode =3D virXMLPropString(cur, = "rendernode"); =20 if (!enable) { virReportError(VIR_ERR_XML_ERROR, "%s", _("spice gl element missing enable")); - VIR_FREE(rendernode); goto error; } =20 @@ -14281,18 +14028,15 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, virTristateBoolTypeFromString(enable)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown enable value '%s'"), enable); - VIR_FREE(enable); - VIR_FREE(rendernode); goto error; } - VIR_FREE(enable); =20 def->data.spice.gl =3D enableVal; VIR_STEAL_PTR(def->data.spice.rendernode, rendernode); =20 } else if (virXMLNodeNameEqual(cur, "mouse")) { - char *mode =3D virXMLPropString(cur, "mode"); int modeVal; + VIR_AUTOFREE(char *) mode =3D virXMLPropString(cur, "mode"= ); =20 if (!mode) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -14304,10 +14048,8 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphic= sDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown mouse mode value '%s'"), mode); - VIR_FREE(mode); goto error; } - VIR_FREE(mode); =20 def->data.spice.mousemode =3D modeVal; } @@ -14317,10 +14059,6 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphic= sDefPtr def, =20 ret =3D 0; error: - VIR_FREE(port); - VIR_FREE(tlsPort); - VIR_FREE(autoport); - VIR_FREE(defaultMode); return ret; } =20 @@ -14369,8 +14107,8 @@ virDomainGraphicsDefParseXML(virDomainXMLOptionPtr = xmlopt, unsigned int flags) { virDomainGraphicsDefPtr def; - char *type =3D NULL; int typeVal; + VIR_AUTOFREE(char *) type =3D NULL; =20 if (!(def =3D virDomainGraphicsDefNew(xmlopt))) return NULL; @@ -14419,8 +14157,6 @@ virDomainGraphicsDefParseXML(virDomainXMLOptionPtr = xmlopt, } =20 cleanup: - VIR_FREE(type); - return def; =20 error: @@ -14433,8 +14169,8 @@ virDomainGraphicsDefParseXML(virDomainXMLOptionPtr = xmlopt, static virDomainSoundCodecDefPtr virDomainSoundCodecDefParseXML(xmlNodePtr node) { - char *type; virDomainSoundCodecDefPtr def; + VIR_AUTOFREE(char *) type =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -14447,8 +14183,6 @@ virDomainSoundCodecDefParseXML(xmlNodePtr node) } =20 cleanup: - VIR_FREE(type); - return def; =20 error: @@ -14464,9 +14198,9 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xml= opt, xmlXPathContextPtr ctxt, unsigned int flags) { - char *model; virDomainSoundDefPtr def; xmlNodePtr save =3D ctxt->node; + VIR_AUTOFREE(char *) model =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -14483,7 +14217,7 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xml= opt, if (def->model =3D=3D VIR_DOMAIN_SOUND_MODEL_ICH6 || def->model =3D=3D VIR_DOMAIN_SOUND_MODEL_ICH9) { int ncodecs; - xmlNodePtr *codecNodes =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) codecNodes =3D NULL; =20 /* parse the subelements for sound models that support it = */ ncodecs =3D virXPathNodeSet("./codec", ctxt, &codecNodes); @@ -14493,22 +14227,17 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr x= mlopt, if (ncodecs > 0) { size_t i; =20 - if (VIR_ALLOC_N(def->codecs, ncodecs) < 0) { - VIR_FREE(codecNodes); + if (VIR_ALLOC_N(def->codecs, ncodecs) < 0) goto error; - } =20 for (i =3D 0; i < ncodecs; i++) { virDomainSoundCodecDefPtr codec =3D virDomainSoundCodecDef= ParseXML(codecNodes[i]); - if (codec =3D=3D NULL) { - VIR_FREE(codecNodes); + if (codec =3D=3D NULL) goto error; - } =20 codec->cad =3D def->ncodecs; /* that will do for now */ def->codecs[def->ncodecs++] =3D codec; } - VIR_FREE(codecNodes); } } =20 @@ -14516,8 +14245,6 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xml= opt, goto error; =20 cleanup: - VIR_FREE(model); - ctxt->node =3D save; return def; =20 @@ -14533,9 +14260,9 @@ virDomainWatchdogDefParseXML(virDomainXMLOptionPtr = xmlopt, xmlNodePtr node, unsigned int flags) { - char *model =3D NULL; - char *action =3D NULL; virDomainWatchdogDefPtr def; + VIR_AUTOFREE(char *) model =3D NULL; + VIR_AUTOFREE(char *) action =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -14569,9 +14296,6 @@ virDomainWatchdogDefParseXML(virDomainXMLOptionPtr = xmlopt, goto error; =20 cleanup: - VIR_FREE(action); - VIR_FREE(model); - return def; =20 error: @@ -14587,13 +14311,13 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xml= opt, xmlXPathContextPtr ctxt, unsigned int flags) { - char *model =3D NULL; - char *backend =3D NULL; - char *type =3D NULL; virDomainRNGDefPtr def; xmlNodePtr save =3D ctxt->node; - xmlNodePtr *backends =3D NULL; int nbackends; + VIR_AUTOFREE(xmlNodePtr *) backends =3D NULL; + VIR_AUTOFREE(char *) model =3D NULL; + VIR_AUTOFREE(char *) backend =3D NULL; + VIR_AUTOFREE(char *) type =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -14685,10 +14409,6 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlo= pt, goto error; =20 cleanup: - VIR_FREE(model); - VIR_FREE(backend); - VIR_FREE(type); - VIR_FREE(backends); ctxt->node =3D save; return def; =20 @@ -14705,11 +14425,11 @@ virDomainMemballoonDefParseXML(virDomainXMLOption= Ptr xmlopt, xmlXPathContextPtr ctxt, unsigned int flags) { - char *model; - char *deflate =3D NULL; virDomainMemballoonDefPtr def; xmlNodePtr save =3D ctxt->node; unsigned int period =3D 0; + VIR_AUTOFREE(char *) model =3D NULL; + VIR_AUTOFREE(char *) deflate =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -14756,9 +14476,6 @@ virDomainMemballoonDefParseXML(virDomainXMLOptionPt= r xmlopt, goto error; =20 cleanup: - VIR_FREE(model); - VIR_FREE(deflate); - ctxt->node =3D save; return def; =20 @@ -14794,13 +14511,12 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr x= mlopt, xmlXPathContextPtr ctxt, unsigned int flags) { - char *tmp =3D NULL; virDomainShmemDefPtr def =3D NULL; virDomainShmemDefPtr ret =3D NULL; xmlNodePtr msi =3D NULL; xmlNodePtr save =3D ctxt->node; xmlNodePtr server =3D NULL; - + VIR_AUTOFREE(char *) tmp =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -14864,7 +14580,6 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr xml= opt, } def->msi.ioeventfd =3D val; } - VIR_FREE(tmp); } =20 /* msi option is only relevant with a server */ @@ -14881,7 +14596,6 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr xml= opt, VIR_STEAL_PTR(ret, def); cleanup: ctxt->node =3D save; - VIR_FREE(tmp); virDomainShmemDefFree(def); return ret; } @@ -14953,7 +14667,7 @@ virSysinfoSystemParseXML(xmlNodePtr node, { int ret =3D -1; virSysinfoSystemDefPtr def; - char *tmpUUID =3D NULL; + VIR_AUTOFREE(char *) tmpUUID =3D NULL; =20 if (!virXMLNodeNameEqual(node, "system")) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -15014,7 +14728,6 @@ virSysinfoSystemParseXML(xmlNodePtr node, ret =3D 0; cleanup: virSysinfoSystemDefFree(def); - VIR_FREE(tmpUUID); return ret; } =20 @@ -15024,10 +14737,11 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ct= xt, size_t *nbaseBoard) { int ret =3D -1; - virSysinfoBaseBoardDefPtr boards =3D NULL; size_t i, nboards =3D 0; - xmlNodePtr *nodes =3D NULL, oldnode =3D ctxt->node; + xmlNodePtr oldnode =3D ctxt->node; int n; + VIR_AUTOFREE(virSysinfoBaseBoardDefPtr) boards =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 if ((n =3D virXPathNodeSet("./baseBoard", ctxt, &nodes)) < 0) return ret; @@ -15065,8 +14779,6 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt, *nbaseBoard =3D nboards; ret =3D 0; cleanup: - VIR_FREE(boards); - VIR_FREE(nodes); ctxt->node =3D oldnode; return ret; } @@ -15078,9 +14790,9 @@ virSysinfoOEMStringsParseXML(xmlXPathContextPtr ctx= t, { int ret =3D -1; virSysinfoOEMStringsDefPtr def; - xmlNodePtr *strings =3D NULL; int nstrings; size_t i; + VIR_AUTOFREE(xmlNodePtr *) strings =3D NULL; =20 nstrings =3D virXPathNodeSet("./entry", ctxt, &strings); if (nstrings < 0) @@ -15101,7 +14813,6 @@ virSysinfoOEMStringsParseXML(xmlXPathContextPtr ctx= t, VIR_STEAL_PTR(*oem, def); ret =3D 0; cleanup: - VIR_FREE(strings); virSysinfoOEMStringsDefFree(def); return ret; } @@ -15157,7 +14868,7 @@ virSysinfoParseXML(xmlNodePtr node, { virSysinfoDefPtr def; xmlNodePtr oldnode, tmpnode; - char *type; + VIR_AUTOFREE(char *) type =3D NULL; =20 if (!virXMLNodeNameEqual(node, "sysinfo")) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -15230,7 +14941,6 @@ virSysinfoParseXML(xmlNodePtr node, } =20 cleanup: - VIR_FREE(type); return def; =20 error: @@ -15324,9 +15034,9 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) { xmlNodePtr cur; virDomainVideoAccelDefPtr def; - char *accel2d =3D NULL; - char *accel3d =3D NULL; int val; + VIR_AUTOFREE(char *) accel2d =3D NULL; + VIR_AUTOFREE(char *) accel3d =3D NULL; =20 cur =3D node->children; while (cur !=3D NULL) { @@ -15365,8 +15075,6 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) } =20 cleanup: - VIR_FREE(accel2d); - VIR_FREE(accel3d); return def; } =20 @@ -15375,8 +15083,8 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node) { xmlNodePtr cur; virDomainVideoDriverDefPtr def; - char *vgaconf =3D NULL; int val; + VIR_AUTOFREE(char *) vgaconf =3D NULL; =20 cur =3D node->children; while (cur !=3D NULL) { @@ -15403,7 +15111,6 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node) def->vgaconf =3D val; =20 cleanup: - VIR_FREE(vgaconf); return def; } =20 @@ -15417,13 +15124,13 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr x= mlopt, virDomainVideoDefPtr def; xmlNodePtr cur; xmlNodePtr saved =3D ctxt->node; - char *type =3D NULL; - char *heads =3D NULL; - char *vram =3D NULL; - char *vram64 =3D NULL; - char *ram =3D NULL; - char *vgamem =3D NULL; - char *primary =3D NULL; + VIR_AUTOFREE(char *) type =3D NULL; + VIR_AUTOFREE(char *) heads =3D NULL; + VIR_AUTOFREE(char *) vram =3D NULL; + VIR_AUTOFREE(char *) vram64 =3D NULL; + VIR_AUTOFREE(char *) ram =3D NULL; + VIR_AUTOFREE(char *) vgamem =3D NULL; + VIR_AUTOFREE(char *) primary =3D NULL; =20 if (!(def =3D virDomainVideoDefNew())) return NULL; @@ -15530,14 +15237,6 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm= lopt, =20 cleanup: ctxt->node =3D saved; - - VIR_FREE(type); - VIR_FREE(ram); - VIR_FREE(vram); - VIR_FREE(vram64); - VIR_FREE(vgamem); - VIR_FREE(heads); - return def; =20 error: @@ -15554,8 +15253,8 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr x= mlopt, { virDomainHostdevDefPtr def; xmlNodePtr save =3D ctxt->node; - char *mode =3D virXMLPropString(node, "mode"); - char *type =3D virXMLPropString(node, "type"); + VIR_AUTOFREE(char *) mode =3D virXMLPropString(node, "mode"); + VIR_AUTOFREE(char *) type =3D virXMLPropString(node, "type"); =20 ctxt->node =3D node; =20 @@ -15614,8 +15313,6 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr x= mlopt, } =20 cleanup: - VIR_FREE(type); - VIR_FREE(mode); ctxt->node =3D save; return def; =20 @@ -15634,7 +15331,8 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr = xmlopt, { xmlNodePtr cur; virDomainRedirdevDefPtr def; - char *bus =3D NULL, *type =3D NULL; + VIR_AUTOFREE(char *) bus =3D NULL; + VIR_AUTOFREE(char *) type =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -15690,8 +15388,6 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr = xmlopt, =20 =20 cleanup: - VIR_FREE(bus); - VIR_FREE(type); return def; =20 error: @@ -15741,10 +15437,12 @@ virDomainRedirFilterUSBVersionHelper(const char *= version, static virDomainRedirFilterUSBDevDefPtr virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node) { - char *class; - char *vendor =3D NULL, *product =3D NULL; - char *version =3D NULL, *allow =3D NULL; virDomainRedirFilterUSBDevDefPtr def; + VIR_AUTOFREE(char *) class =3D NULL; + VIR_AUTOFREE(char *) vendor =3D NULL; + VIR_AUTOFREE(char *) product =3D NULL; + VIR_AUTOFREE(char *) version =3D NULL; + VIR_AUTOFREE(char *) allow =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -15816,11 +15514,6 @@ virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr n= ode) } =20 cleanup: - VIR_FREE(class); - VIR_FREE(vendor); - VIR_FREE(product); - VIR_FREE(version); - VIR_FREE(allow); return def; =20 error: @@ -15835,9 +15528,9 @@ virDomainRedirFilterDefParseXML(xmlNodePtr node, { int n; size_t i; - xmlNodePtr *nodes =3D NULL; xmlNodePtr save =3D ctxt->node; virDomainRedirFilterDefPtr def =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 if (VIR_ALLOC(def) < 0) goto error; @@ -15857,13 +15550,11 @@ virDomainRedirFilterDefParseXML(xmlNodePtr node, goto error; def->usbdevs[def->nusbdevs++] =3D usbdev; } - VIR_FREE(nodes); =20 ctxt->node =3D save; return def; =20 error: - VIR_FREE(nodes); virDomainRedirFilterDefFree(def); return NULL; } @@ -15876,7 +15567,8 @@ virDomainEventActionParseXML(xmlXPathContextPtr ctx= t, int defaultVal, virEventActionFromStringFunc convFunc) { - char *tmp =3D virXPathString(xpath, ctxt); + VIR_AUTOFREE(char *) tmp =3D virXPathString(xpath, ctxt); + if (tmp =3D=3D NULL) { *val =3D defaultVal; } else { @@ -15884,10 +15576,8 @@ virDomainEventActionParseXML(xmlXPathContextPtr ct= xt, if (*val < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown %s action: %s"), name, tmp); - VIR_FREE(tmp); return -1; } - VIR_FREE(tmp); } return 0; } @@ -15898,7 +15588,8 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, int *val) { int ret =3D -1; - char *tmp =3D virXPathString(xpath, ctxt); + VIR_AUTOFREE(char *) tmp =3D virXPathString(xpath, ctxt); + if (tmp) { *val =3D virTristateBoolTypeFromString(tmp); if (*val < 0) { @@ -15910,7 +15601,6 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, =20 ret =3D 0; cleanup: - VIR_FREE(tmp); return ret; } =20 @@ -15919,10 +15609,10 @@ static int virDomainPerfEventDefParseXML(virDomainPerfDefPtr perf, xmlNodePtr node) { - char *name =3D NULL; - char *enabled =3D NULL; int event; int ret =3D -1; + VIR_AUTOFREE(char *) name =3D NULL; + VIR_AUTOFREE(char *) enabled =3D NULL; =20 if (!(name =3D virXMLPropString(node, "name"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing perf event name= ")); @@ -15957,8 +15647,6 @@ virDomainPerfEventDefParseXML(virDomainPerfDefPtr p= erf, ret =3D 0; =20 cleanup: - VIR_FREE(name); - VIR_FREE(enabled); return ret; } =20 @@ -15968,8 +15656,8 @@ virDomainPerfDefParseXML(virDomainDefPtr def, { size_t i; int ret =3D -1; - xmlNodePtr *nodes =3D NULL; int n; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 if ((n =3D virXPathNodeSet("./perf/event", ctxt, &nodes)) < 0) return n; @@ -15982,7 +15670,6 @@ virDomainPerfDefParseXML(virDomainDefPtr def, ret =3D 0; =20 cleanup: - VIR_FREE(nodes); return ret; } =20 @@ -15992,9 +15679,9 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, virDomainMemoryDefPtr def) { int ret =3D -1; - char *nodemask =3D NULL; xmlNodePtr save =3D ctxt->node; ctxt->node =3D node; + VIR_AUTOFREE(char *) nodemask =3D NULL; =20 switch ((virDomainMemoryModel) def->model) { case VIR_DOMAIN_MEMORY_MODEL_DIMM: @@ -16039,7 +15726,6 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, ret =3D 0; =20 cleanup: - VIR_FREE(nodemask); ctxt->node =3D save; return ret; } @@ -16102,10 +15788,10 @@ static virDomainSEVDefPtr virDomainSEVDefParseXML(xmlNodePtr sevNode, xmlXPathContextPtr ctxt) { - char *type =3D NULL; xmlNodePtr save =3D ctxt->node; virDomainSEVDefPtr def; unsigned long policy; + VIR_AUTOFREE(char *) type =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -16155,7 +15841,6 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode, def->session =3D virXPathString("string(./session)", ctxt); =20 cleanup: - VIR_FREE(type); ctxt->node =3D save; return def; =20 @@ -16171,11 +15856,11 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr = xmlopt, xmlXPathContextPtr ctxt, unsigned int flags) { - char *tmp =3D NULL; xmlNodePtr save =3D ctxt->node; xmlNodePtr node; virDomainMemoryDefPtr def; int val; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -16215,7 +15900,6 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xm= lopt, =20 def->discard =3D val; } - VIR_FREE(tmp); =20 /* source */ if ((node =3D virXPathNode("./source", ctxt)) && @@ -16240,7 +15924,6 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xm= lopt, return def; =20 error: - VIR_FREE(tmp); virDomainMemoryDefFree(def); ctxt->node =3D save; return NULL; @@ -16251,11 +15934,12 @@ static virDomainIOMMUDefPtr virDomainIOMMUDefParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt) { - virDomainIOMMUDefPtr iommu =3D NULL, ret =3D NULL; + virDomainIOMMUDefPtr ret =3D NULL; xmlNodePtr save =3D ctxt->node; xmlNodePtr driver; - char *tmp =3D NULL; int val; + VIR_AUTOFREE(char *) tmp =3D NULL; + VIR_AUTOFREE(virDomainIOMMUDefPtr) iommu =3D NULL; =20 ctxt->node =3D node; =20 @@ -16316,8 +16000,6 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, =20 cleanup: ctxt->node =3D save; - VIR_FREE(iommu); - VIR_FREE(tmp); return ret; } =20 @@ -16328,11 +16010,12 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr x= mlopt, xmlXPathContextPtr ctxt, unsigned int flags) { - virDomainVsockDefPtr vsock =3D NULL, ret =3D NULL; + virDomainVsockDefPtr ret =3D NULL; xmlNodePtr save =3D ctxt->node; xmlNodePtr cid; - char *tmp =3D NULL; int val; + VIR_AUTOFREE(char *) tmp =3D NULL; + VIR_AUTOFREE(virDomainVsockDefPtr) vsock =3D NULL; =20 ctxt->node =3D node; =20 @@ -16381,8 +16064,6 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xml= opt, =20 cleanup: ctxt->node =3D save; - VIR_FREE(vsock); - VIR_FREE(tmp); return ret; } =20 @@ -17976,17 +17657,15 @@ virDomainDefGetDefaultEmulator(virDomainDefPtr de= f, virCapsPtr caps) { char *retemu; - virCapsDomainDataPtr capsdata; + VIR_AUTOFREE(virCapsDomainDataPtr) capsdata =3D NULL; =20 if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, def->os.type, def->os.arch, def->virtType, NULL, NULL))) return NULL; =20 - if (VIR_STRDUP(retemu, capsdata->emulator) < 0) { - VIR_FREE(capsdata); + if (VIR_STRDUP(retemu, capsdata->emulator) < 0) return NULL; - } - VIR_FREE(capsdata); + return retemu; } =20 @@ -17994,12 +17673,12 @@ static int virDomainDefParseBootXML(xmlXPathContextPtr ctxt, virDomainDefPtr def) { - xmlNodePtr *nodes =3D NULL; xmlNodePtr node; size_t i; int n; - char *tmp =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) tmp =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 /* analysis of the boot devices */ if ((n =3D virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0) @@ -18081,8 +17760,6 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, ret =3D 0; =20 cleanup: - VIR_FREE(tmp); - VIR_FREE(nodes); return ret; } =20 @@ -18163,7 +17840,7 @@ static virDomainIOThreadIDDefPtr virDomainIOThreadIDDefParseXML(xmlNodePtr node) { virDomainIOThreadIDDefPtr iothrid; - char *tmp =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 if (VIR_ALLOC(iothrid) < 0) return NULL; @@ -18181,7 +17858,6 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node) } =20 cleanup: - VIR_FREE(tmp); return iothrid; =20 error: @@ -18196,10 +17872,10 @@ virDomainDefParseIOThreads(virDomainDefPtr def, xmlXPathContextPtr ctxt) { size_t i; - char *tmp; int n =3D 0; unsigned int iothreads =3D 0; - xmlNodePtr *nodes =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 tmp =3D virXPathString("string(./iothreads[1])", ctxt); if (tmp && virStrToLong_uip(tmp, NULL, 10, &iothreads) < 0) { @@ -18207,7 +17883,6 @@ virDomainDefParseIOThreads(virDomainDefPtr def, _("invalid iothreads count '%s'"), tmp); goto error; } - VIR_FREE(tmp); =20 /* Extract any iothread id's defined */ if ((n =3D virXPathNodeSet("./iothreadids/iothread", ctxt, &nodes)) < = 0) @@ -18233,7 +17908,6 @@ virDomainDefParseIOThreads(virDomainDefPtr def, } def->iothreadids[def->niothreadids++] =3D iothrid; } - VIR_FREE(nodes); =20 if (virDomainIOThreadIDDefArrayInit(def, iothreads) < 0) goto error; @@ -18241,7 +17915,6 @@ virDomainDefParseIOThreads(virDomainDefPtr def, return 0; =20 error: - VIR_FREE(nodes); return -1; } =20 @@ -18257,8 +17930,8 @@ virDomainVcpuPinDefParseXML(virDomainDefPtr def, { virDomainVcpuDefPtr vcpu; unsigned int vcpuid; - char *tmp =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 if (!(tmp =3D virXMLPropString(node, "vcpu"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing vcpu id in vcpu= pin")); @@ -18302,7 +17975,6 @@ virDomainVcpuPinDefParseXML(virDomainDefPtr def, ret =3D 0; =20 cleanup: - VIR_FREE(tmp); return ret; } =20 @@ -18318,7 +17990,7 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, int ret =3D -1; virDomainIOThreadIDDefPtr iothrid; unsigned int iothreadid; - char *tmp =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; VIR_AUTOPTR(virBitmap) cpumask =3D NULL; =20 if (!(tmp =3D virXMLPropString(node, "iothread"))) { @@ -18374,7 +18046,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, ret =3D 0; =20 cleanup: - VIR_FREE(tmp); return ret; } =20 @@ -18387,7 +18058,7 @@ static virBitmapPtr virDomainEmulatorPinDefParseXML(xmlNodePtr node) { virBitmapPtr ret =3D NULL; - char *tmp =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; VIR_AUTOPTR(virBitmap) def =3D NULL; =20 if (!(tmp =3D virXMLPropString(node, "cpuset"))) { @@ -18408,7 +18079,6 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node) VIR_STEAL_PTR(ret, def); =20 cleanup: - VIR_FREE(tmp); return ret; } =20 @@ -18544,7 +18214,7 @@ virDomainHugepagesParseXML(xmlNodePtr node, { int ret =3D -1; xmlNodePtr oldnode =3D ctxt->node; - char *nodeset =3D NULL; + VIR_AUTOFREE(char *) nodeset =3D NULL; =20 ctxt->node =3D node; =20 @@ -18572,7 +18242,6 @@ virDomainHugepagesParseXML(xmlNodePtr node, =20 ret =3D 0; cleanup: - VIR_FREE(nodeset); ctxt->node =3D oldnode; return ret; } @@ -18649,9 +18318,9 @@ virDomainLoaderDefParseXML(xmlNodePtr node, virDomainLoaderDefPtr loader) { int ret =3D -1; - char *readonly_str =3D NULL; - char *secure_str =3D NULL; - char *type_str =3D NULL; + VIR_AUTOFREE(char *) readonly_str =3D NULL; + VIR_AUTOFREE(char *) secure_str =3D NULL; + VIR_AUTOFREE(char *) type_str =3D NULL; =20 readonly_str =3D virXMLPropString(node, "readonly"); secure_str =3D virXMLPropString(node, "secure"); @@ -18684,9 +18353,6 @@ virDomainLoaderDefParseXML(xmlNodePtr node, =20 ret =3D 0; cleanup: - VIR_FREE(readonly_str); - VIR_FREE(secure_str); - VIR_FREE(type_str); return ret; } =20 @@ -18698,8 +18364,8 @@ virDomainSchedulerParse(xmlNodePtr node, int *priority) { virBitmapPtr ret =3D NULL; - char *tmp =3D NULL; int pol =3D 0; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 if (!(tmp =3D virXMLPropString(node, name))) { virReportError(VIR_ERR_XML_ERROR, @@ -18748,13 +18414,11 @@ virDomainSchedulerParse(xmlNodePtr node, _("Invalid value for element priority")); goto error; } - VIR_FREE(tmp); } =20 return ret; =20 error: - VIR_FREE(tmp); virBitmapFree(ret); return NULL; } @@ -18837,13 +18501,13 @@ virDomainVcpuParse(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt) { int n; - xmlNodePtr *nodes =3D NULL; xmlNodePtr vcpuNode; size_t i; - char *tmp =3D NULL; unsigned int maxvcpus; unsigned int vcpus; int ret =3D -1; + VIR_AUTOFREE(char *) tmp =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 vcpus =3D maxvcpus =3D 1; =20 @@ -18977,9 +18641,6 @@ virDomainVcpuParse(virDomainDefPtr def, ret =3D 0; =20 cleanup: - VIR_FREE(nodes); - VIR_FREE(tmp); - return ret; } =20 @@ -18988,12 +18649,12 @@ static int virDomainDefParseBootOptions(virDomainDefPtr def, xmlXPathContextPtr ctxt) { - xmlNodePtr *nodes =3D NULL; - char *tmp =3D NULL; char *name =3D NULL; int ret =3D -1; size_t i; int n; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 /* * Booting options for different OS types.... @@ -19124,8 +18785,6 @@ virDomainDefParseBootOptions(virDomainDefPtr def, ret =3D 0; =20 error: - VIR_FREE(nodes); - VIR_FREE(tmp); return ret; } =20 @@ -19135,8 +18794,8 @@ virDomainResctrlParseVcpus(virDomainDefPtr def, xmlNodePtr node, virBitmapPtr *vcpus) { - char *vcpus_str =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) vcpus_str =3D NULL; =20 vcpus_str =3D virXMLPropString(node, "vcpus"); if (!vcpus_str) { @@ -19157,7 +18816,6 @@ virDomainResctrlParseVcpus(virDomainDefPtr def, =20 ret =3D 0; cleanup: - VIR_FREE(vcpus_str); return ret; } =20 @@ -19197,8 +18855,8 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr = ctxt, unsigned int cache; int type; unsigned long long size; - char *tmp =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 ctxt->node =3D node; =20 @@ -19243,7 +18901,6 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr = ctxt, tmp); goto cleanup; } - VIR_FREE(tmp); =20 if (virDomainParseScaledValue("./@size", "./@unit", ctxt, &size, 1024, @@ -19256,7 +18913,6 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr = ctxt, ret =3D 0; cleanup: ctxt->node =3D oldnode; - VIR_FREE(tmp); return ret; } =20 @@ -19329,14 +18985,14 @@ virDomainResctrlMonDefParse(virDomainDefPtr def, { virDomainResctrlMonDefPtr domresmon =3D NULL; xmlNodePtr oldnode =3D ctxt->node; - xmlNodePtr *nodes =3D NULL; unsigned int level =3D 0; - char *tmp =3D NULL; - char *id =3D NULL; size_t i =3D 0; int n =3D 0; int rv =3D -1; int ret =3D -1; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; + VIR_AUTOFREE(char *) id =3D NULL; =20 ctxt->node =3D node; =20 @@ -19424,9 +19080,6 @@ virDomainResctrlMonDefParse(virDomainDefPtr def, ret =3D 0; cleanup: ctxt->node =3D oldnode; - VIR_FREE(id); - VIR_FREE(tmp); - VIR_FREE(nodes); virDomainResctrlMonDefFree(domresmon); return ret; } @@ -19438,10 +19091,10 @@ virDomainResctrlNew(xmlNodePtr node, virBitmapPtr vcpus, unsigned int flags) { - char *vcpus_str =3D NULL; - char *alloc_id =3D NULL; virDomainResctrlDefPtr resctrl =3D NULL; virDomainResctrlDefPtr ret =3D NULL; + VIR_AUTOFREE(char *) vcpus_str =3D NULL; + VIR_AUTOFREE(char *) alloc_id =3D NULL; =20 /* We need to format it back because we need to be consistent in the n= aming * even when users specify some "sub-optimal" string there. */ @@ -19479,8 +19132,6 @@ virDomainResctrlNew(xmlNodePtr node, VIR_STEAL_PTR(ret, resctrl); cleanup: virDomainResctrlDefFree(resctrl); - VIR_FREE(alloc_id); - VIR_FREE(vcpus_str); return ret; } =20 @@ -19492,13 +19143,13 @@ virDomainCachetuneDefParse(virDomainDefPtr def, unsigned int flags) { xmlNodePtr oldnode =3D ctxt->node; - xmlNodePtr *nodes =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; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 ctxt->node =3D node; =20 @@ -19558,7 +19209,6 @@ virDomainCachetuneDefParse(virDomainDefPtr def, ctxt->node =3D oldnode; virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); - VIR_FREE(nodes); return ret; } =20 @@ -19570,10 +19220,10 @@ virDomainDefParseCaps(virDomainDefPtr def, unsigned int flags) { int ret =3D -1; - char *virttype =3D NULL; - char *arch =3D NULL; - char *ostype =3D NULL; - virCapsDomainDataPtr capsdata =3D NULL; + VIR_AUTOFREE(char *) virttype =3D NULL; + VIR_AUTOFREE(char *) arch =3D NULL; + VIR_AUTOFREE(char *) ostype =3D NULL; + VIR_AUTOFREE(virCapsDomainDataPtr) capsdata =3D NULL; =20 virttype =3D virXPathString("string(./@type)", ctxt); ostype =3D virXPathString("string(./os/type[1])", ctxt); @@ -19644,10 +19294,6 @@ virDomainDefParseCaps(virDomainDefPtr def, =20 ret =3D 0; cleanup: - VIR_FREE(virttype); - VIR_FREE(ostype); - VIR_FREE(arch); - VIR_FREE(capsdata); return ret; } =20 @@ -19660,8 +19306,8 @@ virDomainMemorytuneDefParseMemory(xmlXPathContextPt= r ctxt, xmlNodePtr oldnode =3D ctxt->node; unsigned int id; unsigned int bandwidth; - char *tmp =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 ctxt->node =3D node; =20 @@ -19691,14 +19337,12 @@ virDomainMemorytuneDefParseMemory(xmlXPathContext= Ptr ctxt, tmp); goto cleanup; } - VIR_FREE(tmp); if (virResctrlAllocSetMemoryBandwidth(alloc, id, bandwidth) < 0) goto cleanup; =20 ret =3D 0; cleanup: ctxt->node =3D oldnode; - VIR_FREE(tmp); return ret; } =20 @@ -19710,10 +19354,10 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, unsigned int flags) { xmlNodePtr oldnode =3D ctxt->node; - xmlNodePtr *nodes =3D NULL; virResctrlAllocPtr alloc =3D NULL; virDomainResctrlDefPtr resctrl =3D NULL; VIR_AUTOPTR(virBitmap) vcpus =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 ssize_t i =3D 0; int n; @@ -19772,7 +19416,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, ctxt->node =3D oldnode; virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); - VIR_FREE(nodes); return ret; } =20 @@ -19785,8 +19428,7 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainXMLOptionPtr xmlopt, unsigned int flags) { - xmlNodePtr *nodes =3D NULL, node =3D NULL; - char *tmp =3D NULL; + xmlNodePtr node =3D NULL; size_t i, j; int n, gic_version; long id =3D -1; @@ -19796,18 +19438,19 @@ virDomainDefParseXML(xmlDocPtr xml, bool usb_other =3D false; bool usb_master =3D false; char *netprefix =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) { - char *schema =3D virFileFindResource("domain.rng", - abs_topsrcdir "/docs/schemas", - PKGDATADIR "/schemas"); + VIR_AUTOFREE(char *) schema =3D NULL; + + schema =3D virFileFindResource("domain.rng", + abs_topsrcdir "/docs/schemas", + PKGDATADIR "/schemas"); if (!schema) return NULL; - if (virXMLValidateAgainstSchema(schema, xml) < 0) { - VIR_FREE(schema); + if (virXMLValidateAgainstSchema(schema, xml) < 0) return NULL; - } - VIR_FREE(schema); } =20 if (!(def =3D virDomainDefNew())) @@ -21433,7 +21076,6 @@ virDomainDefParseXML(xmlDocPtr xml, =20 def->idmap.ngidmap =3D n; } - VIR_FREE(nodes); =20 if ((def->idmap.uidmap && !def->idmap.gidmap) || (!def->idmap.uidmap && def->idmap.gidmap)) { @@ -21462,7 +21104,6 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } def->os.smbios_mode =3D mode; - VIR_FREE(tmp); } =20 if (virDomainKeyWrapDefParseXML(def, ctxt) < 0) @@ -21484,8 +21125,6 @@ virDomainDefParseXML(xmlDocPtr xml, return def; =20 error: - VIR_FREE(tmp); - VIR_FREE(nodes); virDomainDefFree(def); return NULL; } @@ -21498,17 +21137,17 @@ virDomainObjParseXML(xmlDocPtr xml, virDomainXMLOptionPtr xmlopt, unsigned int flags) { - char *tmp =3D NULL; long val; xmlNodePtr config; xmlNodePtr oldnode; virDomainObjPtr obj; - xmlNodePtr *nodes =3D NULL; size_t i; int n; int state; int reason =3D 0; void *parseOpaque =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 if (!(obj =3D virDomainObjNew(xmlopt))) return NULL; @@ -21534,7 +21173,6 @@ virDomainObjParseXML(xmlDocPtr xml, if ((state =3D virDomainStateTypeFromString(tmp)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid domain state '%s'"), tmp); - VIR_FREE(tmp); goto error; } VIR_FREE(tmp); @@ -21543,10 +21181,8 @@ virDomainObjParseXML(xmlDocPtr xml, if ((reason =3D virDomainStateReasonFromString(state, tmp)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid domain state reason '%s'"), tmp); - VIR_FREE(tmp); goto error; } - VIR_FREE(tmp); } =20 virDomainObjSetState(obj, state, reason); @@ -21574,7 +21210,6 @@ virDomainObjParseXML(xmlDocPtr xml, virDomainObjTaint(obj, flag); } } - VIR_FREE(nodes); =20 if (xmlopt->privateData.parse && xmlopt->privateData.parse(ctxt, obj, &xmlopt->config) < 0) @@ -21595,7 +21230,6 @@ virDomainObjParseXML(xmlDocPtr xml, =20 error: virObjectUnref(obj); - VIR_FREE(nodes); return NULL; } =20 @@ -23129,8 +22763,8 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr = src, { size_t i; virErrorPtr err; - char *strSrc; - char *strDst; + VIR_AUTOFREE(char *) strSrc =3D NULL; + VIR_AUTOFREE(char *) strDst =3D NULL; =20 if (src->virtType !=3D dst->virtType) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -23599,8 +23233,6 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr = src, strDst =3D virDomainDefFormat(dst, NULL, 0); VIR_DEBUG("XMLs that failed stability check were: src=3D\"%s\", dst=3D= \"%s\"", NULLSTR(strSrc), NULLSTR(strDst)); - VIR_FREE(strSrc); - VIR_FREE(strDst); =20 if (err) { virSetError(err); @@ -24060,7 +23692,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrB= uf, unsigned int flags) { size_t n; - char *path =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; =20 virBufferAsprintf(attrBuf, " protocol=3D'%s'", virStorageNetProtocolTypeToString(src->protocol)); @@ -24072,8 +23704,6 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrB= uf, =20 virBufferEscapeString(attrBuf, " name=3D'%s'", path ? path : src->path= ); =20 - VIR_FREE(path); - if (src->haveTLS !=3D VIR_TRISTATE_BOOL_ABSENT && !(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE && src->tlsFromConfig)) @@ -26508,8 +26138,8 @@ static int virDomainMemorySourceDefFormat(virBufferPtr buf, virDomainMemoryDefPtr def) { - char *bitmap =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) bitmap =3D NULL; =20 if (!def->pagesize && !def->sourceNodes && !def->nvdimmPath) return 0; @@ -26553,7 +26183,6 @@ virDomainMemorySourceDefFormat(virBufferPtr buf, ret =3D 0; =20 cleanup: - VIR_FREE(bitmap); return ret; } =20 @@ -27704,7 +27333,7 @@ virDomainResctrlMonDefFormatHelper(virDomainResctrl= MonDefPtr domresmon, virResctrlMonitorType tag, virBufferPtr buf) { - char *vcpus =3D NULL; + VIR_AUTOFREE(char *) vcpus =3D NULL; =20 if (domresmon->tag !=3D tag) return 0; @@ -27722,7 +27351,6 @@ virDomainResctrlMonDefFormatHelper(virDomainResctrl= MonDefPtr domresmon, =20 virBufferAsprintf(buf, "vcpus=3D'%s'/>\n", vcpus); =20 - VIR_FREE(vcpus); return 0; } =20 @@ -27733,9 +27361,9 @@ virDomainCachetuneDefFormat(virBufferPtr buf, unsigned int flags) { virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; - char *vcpus =3D NULL; size_t i =3D 0; int ret =3D -1; + VIR_AUTOFREE(char *) vcpus =3D NULL; =20 virBufferSetChildIndent(&childrenBuf, buf); if (virResctrlAllocForeachCache(resctrl->alloc, @@ -27779,7 +27407,6 @@ virDomainCachetuneDefFormat(virBufferPtr buf, ret =3D 0; cleanup: virBufferFreeAndReset(&childrenBuf); - VIR_FREE(vcpus); return ret; } =20 @@ -27804,8 +27431,8 @@ virDomainMemorytuneDefFormat(virBufferPtr buf, unsigned int flags) { virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; - char *vcpus =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) vcpus =3D NULL; =20 virBufferSetChildIndent(&childrenBuf, buf); if (virResctrlAllocForeachMemory(resctrl->alloc, @@ -27842,7 +27469,6 @@ virDomainMemorytuneDefFormat(virBufferPtr buf, ret =3D 0; cleanup: virBufferFreeAndReset(&childrenBuf); - VIR_FREE(vcpus); return ret; } =20 @@ -27977,8 +27603,8 @@ virDomainCpuDefFormat(virBufferPtr buf, { virDomainVcpuDefPtr vcpu; size_t i; - char *cpumask =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) cpumask =3D NULL; =20 virBufferAddLit(buf, "def->name)) = =3D=3D NULL) goto cleanup; @@ -29318,8 +28940,6 @@ virDomainDeleteConfig(const char *configDir, ret =3D 0; =20 cleanup: - VIR_FREE(configFile); - VIR_FREE(autostartLink); return ret; } =20 @@ -29585,7 +29205,7 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr dis= k, int ret =3D -1; size_t depth =3D 0; virStorageSourcePtr tmp; - char *brokenRaw =3D NULL; + VIR_AUTOFREE(char *) brokenRaw =3D NULL; =20 if (!ignoreOpenFailure) { if (virStorageFileChainGetBroken(disk->src, &brokenRaw) < 0) @@ -29613,7 +29233,6 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr dis= k, ret =3D 0; =20 cleanup: - VIR_FREE(brokenRaw); return ret; } =20 @@ -29629,11 +29248,11 @@ virDomainDefCopy(virDomainDefPtr src, void *parseOpaque, bool migratable) { - char *xml; virDomainDefPtr ret; unsigned int format_flags =3D VIR_DOMAIN_DEF_FORMAT_SECURE; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; + VIR_AUTOFREE(char *) xml =3D NULL; =20 if (migratable) format_flags |=3D VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_= FORMAT_MIGRATABLE; @@ -29644,7 +29263,6 @@ virDomainDefCopy(virDomainDefPtr src, =20 ret =3D virDomainDefParseString(xml, caps, xmlopt, parseOpaque, parse_= flags); =20 - VIR_FREE(xml); return ret; } =20 @@ -30072,9 +29690,9 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, virDomainDeviceDefPtr ret =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; int flags =3D VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_S= ECURE; - char *xmlStr =3D NULL; int rc =3D -1; char *netprefix; + VIR_AUTOFREE(char *) xmlStr =3D NULL; =20 switch ((virDomainDeviceType) src->type) { case VIR_DOMAIN_DEVICE_DISK: @@ -30161,7 +29779,6 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); =20 cleanup: - VIR_FREE(xmlStr); return ret; } =20 @@ -30492,8 +30109,8 @@ virDomainDefGetShortName(const virDomainDef *def) { wchar_t wshortname[VIR_DOMAIN_SHORT_NAME_MAX + 1] =3D {0}; size_t len =3D 0; - char *shortname =3D NULL; char *ret =3D NULL; + VIR_AUTOFREE(char *) shortname =3D NULL; =20 /* No need to do the whole conversion thing when there are no multibyte * characters. The same applies for illegal sequences as they can occ= ur @@ -30540,7 +30157,6 @@ virDomainDefGetShortName(const virDomainDef *def) =20 ignore_value(virAsprintf(&ret, "%d-%s", def->id, shortname)); cleanup: - VIR_FREE(shortname); return ret; } =20 @@ -30819,9 +30435,9 @@ virDomainNetResolveActualType(virDomainNetDefPtr if= ace) { virConnectPtr conn =3D NULL; virNetworkPtr net =3D NULL; - char *xml =3D NULL; virNetworkDefPtr def =3D NULL; int ret =3D -1; + VIR_AUTOFREE(char *) xml =3D NULL; =20 if (iface->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) return iface->type; @@ -30888,7 +30504,6 @@ virDomainNetResolveActualType(virDomainNetDefPtr if= ace) =20 cleanup: virNetworkDefFree(def); - VIR_FREE(xml); virObjectUnref(conn); virObjectUnref(net); return ret; @@ -31017,10 +30632,10 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef= Ptr def) virConnectPtr conn =3D NULL; virStoragePoolPtr pool =3D NULL; virStorageVolPtr vol =3D NULL; - char *poolxml =3D NULL; virStorageVolInfo info; int ret =3D -1; VIR_AUTOPTR(virStoragePoolDef) pooldef =3D NULL; + VIR_AUTOFREE(char *) poolxml =3D NULL; =20 if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME) return 0; @@ -31178,7 +30793,6 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPt= r def) virObjectUnref(conn); virObjectUnref(pool); virObjectUnref(vol); - VIR_FREE(poolxml); return ret; } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 11:26:13 2024 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 155068767483282.70191914668726; Wed, 20 Feb 2019 10:34:34 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C66DB882F2; Wed, 20 Feb 2019 18:34:32 +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 7BEC66014E; Wed, 20 Feb 2019 18:34:32 +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 1B50D181A010; Wed, 20 Feb 2019 18:34:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KIYB0s026243 for ; Wed, 20 Feb 2019 13:34:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0C3561001943; Wed, 20 Feb 2019 18:34:11 +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 5ACB31001DE2 for ; Wed, 20 Feb 2019 18:34:10 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 13:34:04 -0500 Message-Id: <20190220183404.31810-7-jferlan@redhat.com> In-Reply-To: <20190220183404.31810-1-jferlan@redhat.com> References: <20190220183404.31810-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 6/6] conf: Clean up some unnecessary goto paths 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Feb 2019 18:34:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Now that we're using VIR_AUTOFREE there's quite a bit of clean up possible for now unnecessary goto paths. Signed-off-by: John Ferlan Reviewed-by: Erik Skultety --- src/conf/domain_conf.c | 801 ++++++++++++++++------------------------- 1 file changed, 310 insertions(+), 491 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 98a35b0296..0a28ee3dd8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1101,32 +1101,31 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapD= efPtr keywrap, { int state_type; int name_type; - int ret =3D -1; VIR_AUTOFREE(char *) name =3D NULL; VIR_AUTOFREE(char *) state =3D NULL; =20 if (!(name =3D virXMLPropString(node, "name"))) { virReportError(VIR_ERR_CONF_SYNTAX, "%s", _("missing name for cipher")); - goto cleanup; + return -1; } =20 if ((name_type =3D virDomainKeyWrapCipherNameTypeFromString(name)) < 0= ) { virReportError(VIR_ERR_CONF_SYNTAX, _("%s is not a supported cipher name"), name); - goto cleanup; + return -1; } =20 if (!(state =3D virXMLPropString(node, "state"))) { virReportError(VIR_ERR_CONF_SYNTAX, _("missing state for cipher named %s"), name); - goto cleanup; + return -1; } =20 if ((state_type =3D virTristateSwitchTypeFromString(state)) < 0) { virReportError(VIR_ERR_CONF_SYNTAX, _("%s is not a supported cipher state"), state); - goto cleanup; + return -1; } =20 switch ((virDomainKeyWrapCipherName) name_type) { @@ -1137,7 +1136,7 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDef= Ptr keywrap, "one cipher node with name %s"), virDomainKeyWrapCipherNameTypeToString(name_typ= e)); =20 - goto cleanup; + return -1; } keywrap->aes =3D state_type; break; @@ -1149,7 +1148,7 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDef= Ptr keywrap, "one cipher node with name %s"), virDomainKeyWrapCipherNameTypeToString(name_typ= e)); =20 - goto cleanup; + return -1; } keywrap->dea =3D state_type; break; @@ -1158,10 +1157,7 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDe= fPtr keywrap, break; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int @@ -1264,7 +1260,6 @@ static int virDomainVirtioOptionsParseXML(xmlNodePtr driver, virDomainVirtioOptionsPtr *virtio) { - int ret =3D -1; int val; virDomainVirtioOptionsPtr res; VIR_AUTOFREE(char *) str =3D NULL; @@ -1281,7 +1276,7 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver, if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid iommu value")); - goto cleanup; + return -1; } res->iommu =3D val; } @@ -1291,15 +1286,12 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver, if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid ats value")); - goto cleanup; + return -1; } res->ats =3D val; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -5333,7 +5325,6 @@ virDomainDefCollectBootOrder(virDomainDefPtr def ATTR= IBUTE_UNUSED, void *data) { virHashTablePtr bootHash =3D data; - int ret =3D -1; VIR_AUTOFREE(char *) order =3D NULL; =20 if (info->bootIndex =3D=3D 0) @@ -5348,22 +5339,19 @@ virDomainDefCollectBootOrder(virDomainDefPtr def AT= TRIBUTE_UNUSED, return 0; } if (virAsprintf(&order, "%u", info->bootIndex) < 0) - goto cleanup; + return -1; =20 if (virHashLookup(bootHash, order)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("boot order '%s' used for more than one device"), order); - goto cleanup; + return -1; } =20 if (virHashAddEntry(bootHash, order, (void *) 1) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - return ret; + return 0; } =20 =20 @@ -6883,7 +6871,6 @@ static int virDomainDeviceUSBMasterParseXML(xmlNodePtr node, virDomainDeviceUSBMasterPtr master) { - int ret =3D -1; VIR_AUTOFREE(char *) startport =3D NULL; =20 memset(master, 0, sizeof(*master)); @@ -6894,27 +6881,23 @@ virDomainDeviceUSBMasterParseXML(xmlNodePtr node, virStrToLong_ui(startport, NULL, 10, &master->startport) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse 'startport' attribute")); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int virDomainDeviceBootParseXML(xmlNodePtr node, virDomainDeviceInfoPtr info) { - int ret =3D -1; VIR_AUTOFREE(char *) order =3D NULL; VIR_AUTOFREE(char *) loadparm =3D NULL; =20 if (!(order =3D virXMLPropString(node, "order"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing boot order attribute")); - goto cleanup; + return -1; } =20 if (virStrToLong_uip(order, NULL, 10, &info->bootIndex) < 0 || @@ -6922,7 +6905,7 @@ virDomainDeviceBootParseXML(xmlNodePtr node, virReportError(VIR_ERR_INTERNAL_ERROR, _("incorrect boot order '%s', expecting positive in= teger"), order); - goto cleanup; + return -1; } =20 loadparm =3D virXMLPropString(node, "loadparm"); @@ -6931,26 +6914,22 @@ virDomainDeviceBootParseXML(xmlNodePtr node, virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to convert loadparm '%s' to upper cas= e"), loadparm); - goto cleanup; + return -1; } =20 if (!virDomainDeviceLoadparmIsValid(info->loadparm)) { VIR_FREE(info->loadparm); - goto cleanup; + return -1; } } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int virDomainDeviceISAAddressParseXML(xmlNodePtr node, virDomainDeviceISAAddressPtr addr) { - int ret =3D -1; VIR_AUTOFREE(char *) iobase =3D NULL; VIR_AUTOFREE(char *) irq =3D NULL; =20 @@ -6963,19 +6942,17 @@ virDomainDeviceISAAddressParseXML(xmlNodePtr node, virStrToLong_uip(iobase, NULL, 16, &addr->iobase) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Cannot parse
'iobase' attribute")); - goto cleanup; + return -1; } =20 if (irq && virStrToLong_uip(irq, NULL, 16, &addr->irq) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Cannot parse
'irq' attribute")); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -6983,7 +6960,6 @@ static int virDomainDeviceDimmAddressParseXML(xmlNodePtr node, virDomainDeviceDimmAddressPtr addr) { - int ret =3D -1; VIR_AUTOFREE(char *) tmp =3D NULL; =20 if (!(tmp =3D virXMLPropString(node, "slot")) || @@ -6991,7 +6967,7 @@ virDomainDeviceDimmAddressParseXML(xmlNodePtr node, virReportError(VIR_ERR_XML_ERROR, _("invalid or missing dimm slot id '%s'"), NULLSTR(tmp)); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -6999,14 +6975,11 @@ virDomainDeviceDimmAddressParseXML(xmlNodePtr node, if (virStrToLong_ullp(tmp, NULL, 16, &addr->base) < 0) { virReportError(VIR_ERR_XML_ERROR, _("invalid dimm base address '%s'"), tmp); - goto cleanup; + return -1; } } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -7014,57 +6987,56 @@ static int virDomainDeviceAddressParseXML(xmlNodePtr address, virDomainDeviceInfoPtr info) { - int ret =3D -1; VIR_AUTOFREE(char *) type =3D virXMLPropString(address, "type"); =20 if (type) { if ((info->type =3D virDomainDeviceAddressTypeFromString(type)) <= =3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown address type '%s'"), type); - goto cleanup; + return -1; } } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No type specified for device address")); - goto cleanup; + return -1; } =20 switch ((virDomainDeviceAddressType) info->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: if (virPCIDeviceAddressParseXML(address, &info->addr.pci) < 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: if (virDomainDeviceDriveAddressParseXML(address, &info->addr.drive= ) < 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: if (virDomainDeviceVirtioSerialAddressParseXML (address, &info->addr.vioserial) < 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: if (virDomainDeviceCcidAddressParseXML(address, &info->addr.ccid) = < 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: if (virDomainDeviceUSBAddressParseXML(address, &info->addr.usb) < = 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: if (virDomainDeviceSpaprVioAddressParseXML(address, &info->addr.sp= aprvio) < 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: if (virDomainDeviceCCWAddressParseXML (address, &info->addr.ccw) < 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: @@ -7072,17 +7044,17 @@ virDomainDeviceAddressParseXML(xmlNodePtr address, =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: if (virDomainDeviceISAAddressParseXML(address, &info->addr.isa) < = 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: virReportError(VIR_ERR_XML_ERROR, "%s", _("virtio-s390 bus doesn't have an address")); - goto cleanup; + return -1; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: if (virDomainDeviceDimmAddressParseXML(address, &info->addr.dimm) = < 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: @@ -7090,9 +7062,7 @@ virDomainDeviceAddressParseXML(xmlNodePtr address, break; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -7534,7 +7504,6 @@ static int virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode, virDomainHostdevSubsysSCSIPtr sc= sisrc) { - int ret =3D -1; bool got_address =3D false, got_adapter =3D false; xmlNodePtr cur; virDomainHostdevSubsysSCSIHostPtr scsihostsrc =3D &scsisrc->u.host; @@ -7550,7 +7519,7 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr = sourcenode, virReportError(VIR_ERR_XML_ERROR, "%s", _("more than one source addresses is " "specified for scsi hostdev")); - goto cleanup; + return -1; } =20 if (!(bus =3D virXMLPropString(cur, "bus")) || @@ -7559,26 +7528,26 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePt= r sourcenode, virReportError(VIR_ERR_XML_ERROR, "%s", _("'bus', 'target', and 'unit' must be = specified " "for scsi hostdev source address")); - goto cleanup; + return -1; } =20 if (virStrToLong_uip(bus, NULL, 0, &scsihostsrc->bus) < 0)= { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse bus '%s'"), bus); - goto cleanup; + return -1; } =20 if (virStrToLong_uip(target, NULL, 0, &scsihostsrc->target) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse target '%s'"), target); - goto cleanup; + return -1; } =20 if (virStrToLong_ullp(unit, NULL, 0, &scsihostsrc->unit) <= 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse unit '%s'"), unit); - goto cleanup; + return -1; } =20 got_address =3D true; @@ -7587,12 +7556,12 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePt= r sourcenode, virReportError(VIR_ERR_XML_ERROR, "%s", _("more than one adapters is specified " "for scsi hostdev source")); - goto cleanup; + return -1; } if (!(scsihostsrc->adapter =3D virXMLPropString(cur, "name= "))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("'adapter' must be specified for scsi= hostdev source")); - goto cleanup; + return -1; } =20 got_adapter =3D true; @@ -7600,7 +7569,7 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr = sourcenode, virReportError(VIR_ERR_XML_ERROR, _("unsupported element '%s' of scsi hostdev= source"), cur->name); - goto cleanup; + return -1; } } cur =3D cur->next; @@ -7610,12 +7579,10 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePt= r sourcenode, virReportError(VIR_ERR_XML_ERROR, "%s", _("'adapter' and 'address' must be specified for sc= si " "hostdev source")); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -7694,7 +7661,6 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sour= cenode, virDomainHostdevSubsysSCSIPtr scsisr= c, xmlXPathContextPtr ctxt) { - int ret =3D -1; VIR_AUTOFREE(char *) protocol =3D NULL; =20 if ((protocol =3D virXMLPropString(sourcenode, "protocol"))) { @@ -7704,17 +7670,14 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr so= urcenode, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown SCSI subsystem protocol '%s'"), protocol); - goto cleanup; + return -1; } } =20 if (scsisrc->protocol =3D=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISC= SI) - ret =3D virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scs= isrc, ctxt); - else - ret =3D virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsi= src); + return virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scsi= src, ctxt); =20 - cleanup: - return ret; + return virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc); } =20 static int @@ -7722,14 +7685,13 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodeP= tr sourcenode, virDomainHostdevDefPtr def) { virDomainHostdevSubsysSCSIVHostPtr hostsrc =3D &def->source.subsys.u.s= csi_host; - int ret =3D -1; VIR_AUTOFREE(char *) protocol =3D NULL; VIR_AUTOFREE(char *) wwpn =3D NULL; =20 if (!(protocol =3D virXMLPropString(sourcenode, "protocol"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing scsi_host subsystem protocol")); - return ret; + return -1; } =20 if ((hostsrc->protocol =3D @@ -7737,7 +7699,7 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr= sourcenode, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown scsi_host subsystem protocol '%s'"), protocol); - goto cleanup; + return -1; } =20 switch ((virDomainHostdevSubsysSCSIHostProtocolType) hostsrc->protocol= ) { @@ -7745,13 +7707,13 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodeP= tr sourcenode, if (!(wwpn =3D virXMLPropString(sourcenode, "wwpn"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing vhost-scsi hostdev source wwpn")); - goto cleanup; + return -1; } =20 if (!STRPREFIX(wwpn, "naa.") || !virValidateWWN(wwpn + 4)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("malformed 'wwpn' va= lue")); - goto cleanup; + return -1; } VIR_STEAL_PTR(hostsrc->wwpn, wwpn); break; @@ -7760,20 +7722,17 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodeP= tr sourcenode, virReportError(VIR_ERR_XML_ERROR, _("Invalid hostdev protocol '%s'"), virDomainHostdevSubsysSCSIHostProtocolTypeToString(= hostsrc->protocol)); - goto cleanup; + return -1; break; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int virDomainHostdevSubsysMediatedDevDefParseXML(virDomainHostdevDefPtr def, xmlXPathContextPtr ctxt) { - int ret =3D -1; unsigned char uuid[VIR_UUID_BUFLEN] =3D {0}; xmlNodePtr node =3D NULL; virDomainHostdevSubsysMediatedDevPtr mdevsrc =3D &def->source.subsys.u= .mdev; @@ -7782,26 +7741,24 @@ virDomainHostdevSubsysMediatedDevDefParseXML(virDom= ainHostdevDefPtr def, if (!(node =3D virXPathNode("./source/address", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Missing
element")); - goto cleanup; + return -1; } =20 if (!(uuidxml =3D virXMLPropString(node, "uuid"))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Missing 'uuid' attribute for element
")= ); - goto cleanup; + return -1; } =20 if (virUUIDParse(uuidxml, uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse uuid attribute of element
= ")); - goto cleanup; + return -1; } =20 virUUIDFormat(uuid, mdevsrc->uuidstr); - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -7813,7 +7770,6 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, { xmlNodePtr sourcenode; int backend; - int ret =3D -1; virDomainHostdevSubsysPCIPtr pcisrc =3D &def->source.subsys.u.pci; virDomainHostdevSubsysSCSIPtr scsisrc =3D &def->source.subsys.u.scsi; virDomainHostdevSubsysMediatedDevPtr mdevsrc =3D &def->source.subsys.u= .mdev; @@ -7853,18 +7809,18 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown host device source address type '%s'= "), type); - goto cleanup; + return -1; } } else { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing source address type")); - goto cleanup; + return -1; } =20 if (!(sourcenode =3D virXPathNode("./source", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing element in hostdev device")); - goto cleanup; + return -1; } =20 if (def->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB && @@ -7872,20 +7828,20 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Setting startupPolicy is only allowed for USB" " devices")); - goto cleanup; + return -1; } =20 if (sgio) { if (def->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SC= SI) { virReportError(VIR_ERR_XML_ERROR, "%s", _("sgio is only supported for scsi host device"= )); - goto cleanup; + return -1; } =20 if ((scsisrc->sgio =3D virDomainDeviceSGIOTypeFromString(sgio)) <= =3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown sgio mode '%s'"), sgio); - goto cleanup; + return -1; } } =20 @@ -7893,14 +7849,14 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, if (def->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SC= SI) { virReportError(VIR_ERR_XML_ERROR, "%s", _("rawio is only supported for scsi host device= ")); - goto cleanup; + return -1; } =20 if ((scsisrc->rawio =3D virTristateBoolTypeFromString(rawio)) <=3D= 0) { virReportError(VIR_ERR_XML_ERROR, _("unknown hostdev rawio setting '%s'"), rawio); - goto cleanup; + return -1; } } =20 @@ -7909,21 +7865,21 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, virReportError(VIR_ERR_XML_ERROR, "%s", _("'model' attribute in is only suppo= rted " "when type=3D'mdev'")); - goto cleanup; + return -1; } } else { if (!model) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing 'model' attribute in mediated device= 's " " element")); - goto cleanup; + return -1; } =20 if ((mdevsrc->model =3D virMediatedDeviceModelTypeFromString(model= )) < 0) { virReportError(VIR_ERR_XML_ERROR, _("unknown hostdev model '%s'"), model); - goto cleanup; + return -1; } =20 if (display && @@ -7932,14 +7888,14 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, _("unknown value '%s' for attribute " "'display'"), display); - goto cleanup; + return -1; } } =20 switch (def->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, def, flags) <= 0) - goto cleanup; + return -1; =20 backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT; if ((backendStr =3D virXPathString("string(./driver/@name)", ctxt)= ) && @@ -7948,7 +7904,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown PCI device " "has been specified"), backendStr); - goto cleanup; + return -1; } pcisrc->backend =3D backend; =20 @@ -7956,33 +7912,31 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: if (virDomainHostdevSubsysUSBDefParseXML(sourcenode, def) < 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: if (virDomainHostdevSubsysSCSIDefParseXML(sourcenode, scsisrc, ctx= t) < 0) - goto cleanup; + return -1; break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: if (virDomainHostdevSubsysSCSIVHostDefParseXML(sourcenode, def) < = 0) - goto cleanup; + return -1; break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: if (virDomainHostdevSubsysMediatedDevDefParseXML(def, ctxt) < 0) - goto cleanup; + return -1; break; =20 default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("address type=3D'%s' not supported in hostdev int= erfaces"), virDomainHostdevSubsysTypeToString(def->source.subs= ys.type)); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static virNetDevIPAddrPtr @@ -8001,7 +7955,7 @@ virDomainNetIPParseXML(xmlNodePtr node) if (!(address =3D virXMLPropString(node, "address"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing required address in ")); - goto cleanup; + return NULL; } =20 familyStr =3D virXMLPropString(node, "family"); @@ -8013,13 +7967,13 @@ virDomainNetIPParseXML(xmlNodePtr node) family =3D virSocketAddrNumericFamily(address); =20 if (VIR_ALLOC(ip) < 0) - goto cleanup; + return NULL; =20 if (virSocketAddrParse(&ip->address, address, family) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Invalid address '%s' in "), address); - goto cleanup; + return NULL; } =20 prefixStr =3D virXMLPropString(node, "prefix"); @@ -8030,7 +7984,7 @@ virDomainNetIPParseXML(xmlNodePtr node) virReportError(VIR_ERR_XML_ERROR, _("Invalid prefix value '%s' in "), prefixStr); - goto cleanup; + return NULL; } ip->prefix =3D prefixValue; =20 @@ -8038,12 +7992,10 @@ virDomainNetIPParseXML(xmlNodePtr node) virSocketAddrParse(&ip->peer, peer, family) < 0) { virReportError(VIR_ERR_INVALID_ARG, _("Invalid peer '%s' in "), peer); - goto cleanup; + return NULL; } =20 VIR_STEAL_PTR(ret, ip); - - cleanup: return ret; } =20 @@ -8842,7 +8794,6 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, unsigned int flags) { int tlsCfgVal; - int ret =3D -1; VIR_AUTOFREE(char *) protocol =3D NULL; VIR_AUTOFREE(char *) haveTLS =3D NULL; VIR_AUTOFREE(char *) tlsCfg =3D NULL; @@ -8850,27 +8801,27 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, if (!(protocol =3D virXMLPropString(node, "protocol"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing network source protocol type")); - goto cleanup; + return -1; } =20 if ((src->protocol =3D virStorageNetProtocolTypeFromString(protocol)) = <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown protocol type '%s'"), protocol); - goto cleanup; + return -1; } =20 if (!(src->path =3D virXMLPropString(node, "name")) && src->protocol !=3D VIR_STORAGE_NET_PROTOCOL_NBD) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing name for disk source")); - goto cleanup; + return -1; } =20 if ((haveTLS =3D virXMLPropString(node, "tls")) && (src->haveTLS =3D virTristateBoolTypeFromString(haveTLS)) <=3D 0) { virReportError(VIR_ERR_XML_ERROR, _("unknown disk source 'tls' setting '%s'"), haveTLS); - goto cleanup; + return -1; } =20 if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && @@ -8879,7 +8830,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, virReportError(VIR_ERR_XML_ERROR, _("Invalid tlsFromConfig value: %s"), tlsCfg); - goto cleanup; + return -1; } src->tlsFromConfig =3D !!tlsCfgVal; } @@ -8895,13 +8846,13 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, virReportError(VIR_ERR_XML_ERROR, _("can't split path '%s' into pool name and ima= ge " "name"), src->path); - goto cleanup; + return -1; } =20 src->volume =3D src->path; =20 if (VIR_STRDUP(src->path, tmp + 1) < 0) - goto cleanup; + return -1; =20 tmp[0] =3D '\0'; } @@ -8913,16 +8864,13 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, src->configFile =3D virXPathString("string(./config/@file)", ctxt); =20 if (virDomainStorageNetworkParseHosts(node, &src->hosts, &src->nhosts)= < 0) - goto cleanup; + return -1; =20 virStorageSourceNetworkAssignDefaultPorts(src); =20 virStorageSourceInitiatorParseXML(ctxt, &src->initiator); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -9236,20 +9184,19 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, virDomainXMLOptionPtr xmlopt) { xmlNodePtr mirrorNode; - int ret =3D -1; VIR_AUTOFREE(char *) mirrorFormat =3D NULL; VIR_AUTOFREE(char *) mirrorType =3D NULL; VIR_AUTOFREE(char *) ready =3D NULL; VIR_AUTOFREE(char *) blockJob =3D NULL; =20 if (!(def->mirror =3D virStorageSourceNew())) - goto cleanup; + return -1; =20 if ((blockJob =3D virXMLPropString(cur, "job"))) { if ((def->mirrorJob =3D virDomainBlockJobTypeFromString(blockJob))= <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown mirror job type '%s'"), blockJob); - goto cleanup; + return -1; } } else { def->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_COPY; @@ -9260,7 +9207,7 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown mirror backing store type '%s'"), mirrorType); - goto cleanup; + return -1; } =20 mirrorFormat =3D virXPathString("string(./mirror/format/@type)", c= txt); @@ -9268,12 +9215,12 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, if (!(mirrorNode =3D virXPathNode("./mirror/source", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("mirror requires source element")); - goto cleanup; + return -1; } =20 if (virDomainDiskSourceParse(mirrorNode, ctxt, def->mirror, flags, xmlopt) < 0) - goto cleanup; + return -1; } else { /* For back-compat reasons, we handle a file name * encoded as attributes, even though we prefer @@ -9283,13 +9230,13 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, if (!def->mirror->path) { virReportError(VIR_ERR_XML_ERROR, "%s", _("mirror requires file name")); - goto cleanup; + return -1; } if (def->mirrorJob !=3D VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) { virReportError(VIR_ERR_XML_ERROR, "%s", _("mirror without type only supported " "by copy job")); - goto cleanup; + return -1; } mirrorFormat =3D virXMLPropString(cur, "format"); } @@ -9299,7 +9246,7 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, if (def->mirror->format <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown mirror format value '%s'"), mirrorFo= rmat); - goto cleanup; + return -1; } } =20 @@ -9307,13 +9254,10 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, (def->mirrorState =3D virDomainDiskMirrorStateTypeFromString(ready= )) < 0) { virReportError(VIR_ERR_XML_ERROR, _("unknown mirror ready state %s"), ready); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -9327,7 +9271,7 @@ virDomainDiskDefGeometryParse(virDomainDiskDefPtr def, if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.cylinders) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid geometry settings (cyls)")); - goto error; + return -1; } VIR_FREE(tmp); } @@ -9336,7 +9280,7 @@ virDomainDiskDefGeometryParse(virDomainDiskDefPtr def, if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.heads) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid geometry settings (heads)")); - goto error; + return -1; } VIR_FREE(tmp); } @@ -9345,7 +9289,7 @@ virDomainDiskDefGeometryParse(virDomainDiskDefPtr def, if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.sectors) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid geometry settings (secs)")); - goto error; + return -1; } VIR_FREE(tmp); } @@ -9356,14 +9300,11 @@ virDomainDiskDefGeometryParse(virDomainDiskDefPtr d= ef, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid translation value '%s'"), tmp); - goto error; + return -1; } } =20 return 0; - - error: - return -1; } =20 =20 @@ -9507,7 +9448,6 @@ static int virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def, xmlNodePtr cur) { - int ret =3D -1; VIR_AUTOFREE(char *) tmp =3D NULL; =20 def->driverName =3D virXMLPropString(cur, "name"); @@ -9516,7 +9456,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, (def->cachemode =3D virDomainDiskCacheTypeFromString(tmp)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk cache mode '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -9524,7 +9464,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, (def->error_policy =3D virDomainDiskErrorPolicyTypeFromString(tmp)= ) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk error policy '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -9533,7 +9473,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, (def->rerror_policy =3D=3D VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE)= )) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk read error policy '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -9541,7 +9481,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, (def->iomode =3D virDomainDiskIoTypeFromString(tmp)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk io mode '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -9549,7 +9489,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, (def->ioeventfd =3D virTristateSwitchTypeFromString(tmp)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk ioeventfd mode '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -9557,7 +9497,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, (def->event_idx =3D virTristateSwitchTypeFromString(tmp)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk event_idx mode '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -9565,7 +9505,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, (def->copy_on_read =3D virTristateSwitchTypeFromString(tmp)) <=3D = 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk copy_on_read mode '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -9573,7 +9513,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, (def->discard =3D virDomainDiskDiscardTypeFromString(tmp)) <=3D 0)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk discard mode '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -9583,7 +9523,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, virReportError(VIR_ERR_XML_ERROR, _("Invalid iothread attribute in disk driver elemen= t: %s"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -9595,7 +9535,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, if ((def->src->format =3D virStorageFileFormatTypeFromString(t= mp)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown driver format value '%s'"), tmp); - goto cleanup; + return -1; } } =20 @@ -9606,7 +9546,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr de= f, (def->detect_zeroes =3D virDomainDiskDetectZeroesTypeFromString(tm= p)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown driver detect_zeroes value '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -9615,13 +9555,10 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr = def, virReportError(VIR_ERR_XML_ERROR, _("'queues' attribute must be positive number: %s"), tmp); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -10117,7 +10054,6 @@ virDomainParseScaledValue(const char *xpath, unsigned long long max, bool required) { - int ret =3D -1; unsigned long long bytes; VIR_AUTOFREE(char *) xpath_full =3D NULL; VIR_AUTOFREE(char *) unit =3D NULL; @@ -10125,18 +10061,16 @@ virDomainParseScaledValue(const char *xpath, =20 *val =3D 0; if (virAsprintf(&xpath_full, "string(%s)", xpath) < 0) - goto cleanup; + return -1; =20 bytes_str =3D virXPathString(xpath_full, ctxt); if (!bytes_str) { - if (!required) { - ret =3D 0; - } else { - virReportError(VIR_ERR_XML_ERROR, - _("missing element or attribute '%s'"), - xpath); - } - goto cleanup; + if (!required) + return 0; + virReportError(VIR_ERR_XML_ERROR, + _("missing element or attribute '%s'"), + xpath); + return -1; } VIR_FREE(xpath_full); =20 @@ -10144,23 +10078,21 @@ virDomainParseScaledValue(const char *xpath, virReportError(VIR_ERR_XML_ERROR, _("Invalid value '%s' for element or attribute '%s'= "), bytes_str, xpath); - goto cleanup; + return -1; } =20 if ((units_xpath && virAsprintf(&xpath_full, "string(%s)", units_xpath) < 0) || (!units_xpath && virAsprintf(&xpath_full, "string(%s/@unit)", xpath) < 0)) - goto cleanup; + return -1; unit =3D virXPathString(xpath_full, ctxt); =20 if (virScaleInteger(&bytes, unit, scale, max) < 0) - goto cleanup; + return -1; =20 *val =3D bytes; - ret =3D 1; - cleanup: - return ret; + return 1; } =20 =20 @@ -12034,7 +11966,6 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr de= f, xmlNodePtr cur, unsigned int flags) { - int ret =3D -1; xmlNodePtr child; unsigned int port; VIR_AUTOFREE(char *) targetType =3D virXMLPropString(cur, "type"); @@ -12049,7 +11980,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr de= f, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown target type '%s' specified for character= device"), targetType); - goto error; + return -1; } =20 child =3D cur->children; @@ -12067,7 +11998,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr de= f, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown target model '%s' specified for characte= r device"), targetModel); - goto error; + return -1; } =20 switch (def->deviceType) { @@ -12078,37 +12009,37 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr = def, portStr =3D virXMLPropString(cur, "port"); =20 if (VIR_ALLOC(def->target.addr) < 0) - goto error; + return -1; =20 if (addrStr =3D=3D NULL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("guestfwd channel does not " "define a target address")); - goto error; + return -1; } =20 if (virSocketAddrParse(def->target.addr, addrStr, AF_UNSPEC) <= 0) - goto error; + return -1; =20 if (def->target.addr->data.stor.ss_family !=3D AF_INET) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("guestfwd channel only supports " "IPv4 addresses")); - goto error; + return -1; } =20 if (portStr =3D=3D NULL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("guestfwd channel does " "not define a target port")); - goto error; + return -1; } =20 if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Invalid port number: %s"), portStr); - goto error; + return -1; } =20 virSocketAddrSetPort(def->target.addr, port); @@ -12127,7 +12058,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr de= f, virReportError(VIR_ERR_XML_ERROR, _("invalid channel state value '%s'"), stateStr); - goto error; + return -1; } =20 def->state =3D tmp; @@ -12148,16 +12079,13 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr = def, virReportError(VIR_ERR_XML_ERROR, _("Invalid port number: %s"), portStr); - goto error; + return -1; } def->target.port =3D port; break; } =20 - - ret =3D 0; - error: - return ret; + return 0; } =20 typedef enum { @@ -12176,19 +12104,17 @@ typedef enum { static int virDomainChrSourceDefParseMode(xmlNodePtr source) { - int ret =3D -1; VIR_AUTOFREE(char *) mode =3D virXMLPropString(source, "mode"); =20 if (!mode || STREQ(mode, "connect")) { - ret =3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT; + return VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT; } else if (STREQ(mode, "bind")) { - ret =3D VIR_DOMAIN_CHR_SOURCE_MODE_BIND; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown source mode '%s'"), mode); + return VIR_DOMAIN_CHR_SOURCE_MODE_BIND; } =20 - return ret; + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown source mode '%s'"), mode); + return -1; } =20 =20 @@ -12203,7 +12129,7 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef= Ptr def, VIR_AUTOFREE(char *) tmp =3D NULL; =20 if ((mode =3D virDomainChrSourceDefParseMode(source)) < 0) - goto error; + return -1; =20 def->data.tcp.listen =3D mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_BIND; def->data.tcp.host =3D virXMLPropString(source, "host"); @@ -12214,7 +12140,7 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef= Ptr def, virReportError(VIR_ERR_XML_ERROR, _("unknown chardev 'tls' setting '%s'"), tmp); - goto error; + return -1; } VIR_FREE(tmp); } @@ -12225,7 +12151,7 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef= Ptr def, virReportError(VIR_ERR_XML_ERROR, _("Invalid tlsFromConfig value: %s"), tmp); - goto error; + return -1; } def->data.tcp.tlsFromConfig =3D !!tmpVal; } @@ -12233,13 +12159,10 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceD= efPtr def, if (virDomainChrSourceReconnectDefParseXML(&def->data.tcp.reconnect, source, ctxt) < 0) { - goto error; + return -1; } =20 return 0; - - error: - return -1; } =20 =20 @@ -13575,7 +13498,6 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDe= fPtr def, xmlXPathContextPtr ctxt, unsigned int flags) { - int ret =3D -1; VIR_AUTOFREE(char *) port =3D virXMLPropString(node, "port"); VIR_AUTOFREE(char *) websocket =3D virXMLPropString(node, "websocket"); VIR_AUTOFREE(char *) websocketGenerated =3D virXMLPropString(node, "we= bsocketGenerated"); @@ -13583,13 +13505,13 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphics= DefPtr def, VIR_AUTOFREE(char *) autoport =3D virXMLPropString(node, "autoport"); =20 if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) - goto cleanup; + return -1; =20 if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.vnc.port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse vnc port %s"), port); - goto cleanup; + return -1; } /* Legacy compat syntax, used -1 for auto-port */ if (def->data.vnc.port =3D=3D -1) { @@ -13618,7 +13540,7 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDe= fPtr def, &def->data.vnc.websocket) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse vnc WebSocket port %s"), websoc= ket); - goto cleanup; + return -1; } } =20 @@ -13633,7 +13555,7 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDe= fPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown vnc display sharing policy '%s'"), sharePolicy); - goto cleanup; + return -1; } else { def->data.vnc.sharePolicy =3D policy; } @@ -13643,11 +13565,9 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsD= efPtr def, =20 if (virDomainGraphicsAuthDefParseXML(node, &def->data.vnc.auth, def->type) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -13713,20 +13633,19 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphics= DefPtr def, xmlXPathContextPtr ctxt, unsigned int flags) { - int ret =3D -1; VIR_AUTOFREE(char *) port =3D virXMLPropString(node, "port"); VIR_AUTOFREE(char *) autoport =3D virXMLPropString(node, "autoport"); VIR_AUTOFREE(char *) replaceUser =3D virXMLPropString(node, "replaceUs= er"); VIR_AUTOFREE(char *) multiUser =3D virXMLPropString(node, "multiUser"); =20 if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) - goto error; + return -1; =20 if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.rdp.port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse rdp port %s"), port); - goto error; + return -1; } /* Legacy compat syntax, used -1 for auto-port */ if (def->data.rdp.port =3D=3D -1) @@ -13749,9 +13668,7 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDe= fPtr def, if (STREQ_NULLABLE(multiUser, "yes")) def->data.rdp.multiUser =3D true; =20 - ret =3D 0; - error: - return ret; + return 0; } =20 =20 @@ -13759,7 +13676,6 @@ static int virDomainGraphicsDefParseXMLDesktop(virDomainGraphicsDefPtr def, xmlNodePtr node) { - int ret =3D -1; VIR_AUTOFREE(char *) fullscreen =3D virXMLPropString(node, "fullscreen= "); =20 if (fullscreen !=3D NULL) { @@ -13770,7 +13686,7 @@ virDomainGraphicsDefParseXMLDesktop(virDomainGraphi= csDefPtr def, } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown fullscreen value '%s'"), fullscreen); - goto cleanup; + return -1; } } else { def->data.desktop.fullscreen =3D false; @@ -13778,9 +13694,7 @@ virDomainGraphicsDefParseXMLDesktop(virDomainGraphi= csDefPtr def, =20 def->data.desktop.display =3D virXMLPropString(node, "display"); =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -13792,20 +13706,19 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, { xmlNodePtr cur; int defaultModeVal; - int ret =3D -1; VIR_AUTOFREE(char *) port =3D virXMLPropString(node, "port"); VIR_AUTOFREE(char *) tlsPort =3D virXMLPropString(node, "tlsPort"); VIR_AUTOFREE(char *) autoport =3D virXMLPropString(node, "autoport"); VIR_AUTOFREE(char *) defaultMode =3D virXMLPropString(node, "defaultMo= de"); =20 if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) - goto error; + return -1; =20 if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.spice.port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse spice port %s"), port); - goto error; + return -1; } } else { def->data.spice.port =3D 0; @@ -13815,7 +13728,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, if (virStrToLong_i(tlsPort, NULL, 10, &def->data.spice.tlsPort) < = 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse spice tlsPort %s"), tlsPort); - goto error; + return -1; } } else { def->data.spice.tlsPort =3D 0; @@ -13831,7 +13744,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown default spice channel mode %s"), defaultMode); - goto error; + return -1; } def->data.spice.defaultMode =3D defaultModeVal; } @@ -13850,7 +13763,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, =20 if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth, def->type) < 0) - goto error; + return -1; =20 cur =3D node->children; while (cur !=3D NULL) { @@ -13866,20 +13779,20 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, if (!name || !mode) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("spice channel missing name/mode")); - goto error; + return -1; } =20 if ((nameval =3D virDomainGraphicsSpiceChannelNameTypeFrom= String(name)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice channel name %s"), name); - goto error; + return -1; } if ((modeval =3D virDomainGraphicsSpiceChannelModeTypeFrom= String(mode)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice channel mode %s"), mode); - goto error; + return -1; } =20 def->data.spice.channels[nameval] =3D modeval; @@ -13890,7 +13803,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("spice image missing compression")); - goto error; + return -1; } =20 if ((compressionVal =3D @@ -13898,7 +13811,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice image compression %s"), compression); - goto error; + return -1; } =20 def->data.spice.image =3D compressionVal; @@ -13909,7 +13822,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("spice jpeg missing compression")); - goto error; + return -1; } =20 if ((compressionVal =3D @@ -13917,7 +13830,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice jpeg compression %s"), compression); - goto error; + return -1; } =20 def->data.spice.jpeg =3D compressionVal; @@ -13928,7 +13841,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("spice zlib missing compression")); - goto error; + return -1; } =20 if ((compressionVal =3D @@ -13936,7 +13849,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice zlib compression %s"), compression); - goto error; + return -1; } =20 def->data.spice.zlib =3D compressionVal; @@ -13947,15 +13860,14 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("spice playback missing compression")= ); - goto error; + return -1; } =20 if ((compressionVal =3D virTristateSwitchTypeFromString(compression)) <=3D 0)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unknown spice playback compression")= ); - goto error; - + return -1; } =20 def->data.spice.playback =3D compressionVal; @@ -13966,14 +13878,13 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, if (!mode) { virReportError(VIR_ERR_XML_ERROR, "%s", _("spice streaming missing mode")); - goto error; + return -1; } if ((modeVal =3D virDomainGraphicsSpiceStreamingModeTypeFromString(mod= e)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unknown spice streaming mode")); - goto error; - + return -1; } =20 def->data.spice.streaming =3D modeVal; @@ -13984,14 +13895,14 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, if (!copypaste) { virReportError(VIR_ERR_XML_ERROR, "%s", _("spice clipboard missing copypaste")); - goto error; + return -1; } =20 if ((copypasteVal =3D virTristateBoolTypeFromString(copypaste)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown copypaste value '%s'"), copy= paste); - goto error; + return -1; } =20 def->data.spice.copypaste =3D copypasteVal; @@ -14002,14 +13913,14 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, if (!enable) { virReportError(VIR_ERR_XML_ERROR, "%s", _("spice filetransfer missing enable")); - goto error; + return -1; } =20 if ((enableVal =3D virTristateBoolTypeFromString(enable)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown enable value '%s'"), enable); - goto error; + return -1; } =20 def->data.spice.filetransfer =3D enableVal; @@ -14021,14 +13932,14 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, if (!enable) { virReportError(VIR_ERR_XML_ERROR, "%s", _("spice gl element missing enable")); - goto error; + return -1; } =20 if ((enableVal =3D virTristateBoolTypeFromString(enable)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown enable value '%s'"), enable); - goto error; + return -1; } =20 def->data.spice.gl =3D enableVal; @@ -14041,14 +13952,14 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphi= csDefPtr def, if (!mode) { virReportError(VIR_ERR_XML_ERROR, "%s", _("spice mouse missing mode")); - goto error; + return -1; } =20 if ((modeVal =3D virDomainGraphicsSpiceMouseModeTypeFromSt= ring(mode)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown mouse mode value '%s'"), mode); - goto error; + return -1; } =20 def->data.spice.mousemode =3D modeVal; @@ -14057,9 +13968,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, cur =3D cur->next; } =20 - ret =3D 0; - error: - return ret; + return 0; } =20 =20 @@ -15587,7 +15496,6 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, const char *xpath, int *val) { - int ret =3D -1; VIR_AUTOFREE(char *) tmp =3D virXPathString(xpath, ctxt); =20 if (tmp) { @@ -15595,13 +15503,11 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, if (*val < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown PM state value %s"), tmp); - goto cleanup; + return -1; } } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -15610,44 +15516,40 @@ virDomainPerfEventDefParseXML(virDomainPerfDefPtr= perf, xmlNodePtr node) { int event; - int ret =3D -1; VIR_AUTOFREE(char *) name =3D NULL; VIR_AUTOFREE(char *) enabled =3D NULL; =20 if (!(name =3D virXMLPropString(node, "name"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing perf event name= ")); - goto cleanup; + return -1; } =20 if ((event =3D virPerfEventTypeFromString(name)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("'unsupported perf event '%s'"), name); - goto cleanup; + return -1; } =20 if (perf->events[event] !=3D VIR_TRISTATE_BOOL_ABSENT) { virReportError(VIR_ERR_XML_ERROR, _("perf event '%s' was already specified"), name); - goto cleanup; + return -1; } =20 if (!(enabled =3D virXMLPropString(node, "enabled"))) { virReportError(VIR_ERR_XML_ERROR, _("missing state of perf event '%s'"), name); - goto cleanup; + return -1; } =20 if ((perf->events[event] =3D virTristateBoolTypeFromString(enabled)) <= 0) { virReportError(VIR_ERR_XML_ERROR, _("invalid state '%s' of perf event '%s'"), enabled, name); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int @@ -15655,7 +15557,6 @@ virDomainPerfDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt) { size_t i; - int ret =3D -1; int n; VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 @@ -15664,13 +15565,10 @@ virDomainPerfDefParseXML(virDomainDefPtr def, =20 for (i =3D 0; i < n; i++) { if (virDomainPerfEventDefParseXML(&def->perf, nodes[i]) < 0) - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int @@ -17676,13 +17574,12 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, xmlNodePtr node; size_t i; int n; - int ret =3D -1; VIR_AUTOFREE(char *) tmp =3D NULL; VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 /* analysis of the boot devices */ if ((n =3D virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0) - goto cleanup; + return -1; =20 for (i =3D 0; i < n && i < VIR_DOMAIN_BOOT_LAST; i++) { int val; @@ -17690,14 +17587,14 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, if (!dev) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing boot device")); - goto cleanup; + return -1; } if ((val =3D virDomainBootTypeFromString(dev)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown boot device '%s'"), dev); VIR_FREE(dev); - goto cleanup; + return -1; } VIR_FREE(dev); def->os.bootDevs[def->os.nBootDevs++] =3D val; @@ -17725,7 +17622,7 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("invalid value for boot menu timeout, " "must be in range [0,65535]")); - goto cleanup; + return -1; } def->os.bm_timeout_set =3D true; } @@ -17751,16 +17648,13 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("invalid value for rebootTimeout, " "must be in range [-1,65535]")); - goto cleanup; + return -1; } def->os.bios.rt_set =3D true; } } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -17881,41 +17775,35 @@ virDomainDefParseIOThreads(virDomainDefPtr def, if (tmp && virStrToLong_uip(tmp, NULL, 10, &iothreads) < 0) { virReportError(VIR_ERR_XML_ERROR, _("invalid iothreads count '%s'"), tmp); - goto error; + return -1; } =20 /* Extract any iothread id's defined */ if ((n =3D virXPathNodeSet("./iothreadids/iothread", ctxt, &nodes)) < = 0) - goto error; + return -1; =20 if (n > iothreads) iothreads =3D n; =20 if (n && VIR_ALLOC_N(def->iothreadids, n) < 0) - goto error; + return -1; =20 for (i =3D 0; i < n; i++) { virDomainIOThreadIDDefPtr iothrid =3D NULL; if (!(iothrid =3D virDomainIOThreadIDDefParseXML(nodes[i]))) - goto error; + return -1; =20 if (virDomainIOThreadIDFind(def, iothrid->iothread_id)) { virReportError(VIR_ERR_XML_ERROR, _("duplicate iothread id '%u' found"), iothrid->iothread_id); virDomainIOThreadIDDefFree(iothrid); - goto error; + return -1; } def->iothreadids[def->niothreadids++] =3D iothrid; } =20 - if (virDomainIOThreadIDDefArrayInit(def, iothreads) < 0) - goto error; - - return 0; - - error: - return -1; + return virDomainIOThreadIDDefArrayInit(def, iothreads); } =20 =20 @@ -17930,52 +17818,47 @@ virDomainVcpuPinDefParseXML(virDomainDefPtr def, { virDomainVcpuDefPtr vcpu; unsigned int vcpuid; - int ret =3D -1; VIR_AUTOFREE(char *) tmp =3D NULL; =20 if (!(tmp =3D virXMLPropString(node, "vcpu"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing vcpu id in vcpu= pin")); - goto cleanup; + return -1; } =20 if (virStrToLong_uip(tmp, NULL, 10, &vcpuid) < 0) { virReportError(VIR_ERR_XML_ERROR, _("invalid setting for vcpu '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 if (!(vcpu =3D virDomainDefGetVcpu(def, vcpuid))) { VIR_WARN("Ignoring vcpupin for missing vcpus"); - ret =3D 0; - goto cleanup; + return 0; } =20 if (!(tmp =3D virXMLPropString(node, "cpuset"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing cpuset for vcpupin")); - goto cleanup; + return -1; } =20 if (vcpu->cpumask) { virReportError(VIR_ERR_INTERNAL_ERROR, _("duplicate vcpupin for vcpu '%d'"), vcpuid); - goto cleanup; + return -1; } =20 if (virBitmapParse(tmp, &vcpu->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; + return -1; =20 if (virBitmapIsAllClear(vcpu->cpumask)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid value of 'cpuset': %s"), tmp); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -17987,7 +17870,6 @@ static int virDomainIOThreadPinDefParseXML(xmlNodePtr node, virDomainDefPtr def) { - int ret =3D -1; virDomainIOThreadIDDefPtr iothrid; unsigned int iothreadid; VIR_AUTOFREE(char *) tmp =3D NULL; @@ -17996,57 +17878,54 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, if (!(tmp =3D virXMLPropString(node, "iothread"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing iothread id in iothreadpin")); - goto cleanup; + return -1; } =20 if (virStrToLong_uip(tmp, NULL, 10, &iothreadid) < 0) { virReportError(VIR_ERR_XML_ERROR, _("invalid setting for iothread '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 if (iothreadid =3D=3D 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("zero is an invalid iothread id value")); - goto cleanup; + return -1; } =20 if (!(iothrid =3D virDomainIOThreadIDFind(def, iothreadid))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Cannot find 'iothread' : %u"), iothreadid); - goto cleanup; + return -1; } =20 if (!(tmp =3D virXMLPropString(node, "cpuset"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing cpuset for iothreadpin")); - goto cleanup; + return -1; } =20 if (virBitmapParse(tmp, &cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; + return -1; =20 if (virBitmapIsAllClear(cpumask)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid value of 'cpuset': %s"), tmp); - goto cleanup; + return -1; } =20 if (iothrid->cpumask) { virReportError(VIR_ERR_INTERNAL_ERROR, _("duplicate iothreadpin for same iothread '%u'"), iothreadid); - goto cleanup; + return -1; } =20 VIR_STEAL_PTR(iothrid->cpumask, cpumask); - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -18068,17 +17947,15 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node) } =20 if (virBitmapParse(tmp, &def, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; + return NULL; =20 if (virBitmapIsAllClear(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid value of 'cpuset': %s"), tmp); - goto cleanup; + return NULL; } =20 VIR_STEAL_PTR(ret, def); - - cleanup: return ret; } =20 @@ -18317,7 +18194,6 @@ static int virDomainLoaderDefParseXML(xmlNodePtr node, virDomainLoaderDefPtr loader) { - int ret =3D -1; VIR_AUTOFREE(char *) readonly_str =3D NULL; VIR_AUTOFREE(char *) secure_str =3D NULL; VIR_AUTOFREE(char *) type_str =3D NULL; @@ -18331,14 +18207,14 @@ virDomainLoaderDefParseXML(xmlNodePtr node, (loader->readonly =3D virTristateBoolTypeFromString(readonly_str))= <=3D 0) { virReportError(VIR_ERR_XML_DETAIL, _("unknown readonly value: %s"), readonly_str); - goto cleanup; + return -1; } =20 if (secure_str && (loader->secure =3D virTristateBoolTypeFromString(secure_str)) <= =3D 0) { virReportError(VIR_ERR_XML_DETAIL, _("unknown secure value: %s"), secure_str); - goto cleanup; + return -1; } =20 if (type_str) { @@ -18346,14 +18222,12 @@ virDomainLoaderDefParseXML(xmlNodePtr node, if ((type =3D virDomainLoaderTypeFromString(type_str)) < 0) { virReportError(VIR_ERR_XML_DETAIL, _("unknown type value: %s"), type_str); - goto cleanup; + return -1; } loader->type =3D type; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -18505,7 +18379,6 @@ virDomainVcpuParse(virDomainDefPtr def, size_t i; unsigned int maxvcpus; unsigned int vcpus; - int ret =3D -1; VIR_AUTOFREE(char *) tmp =3D NULL; VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 @@ -18516,7 +18389,7 @@ virDomainVcpuParse(virDomainDefPtr def, if (virStrToLong_ui(tmp, NULL, 10, &maxvcpus) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("maximum vcpus count must be an integer")= ); - goto cleanup; + return -1; } VIR_FREE(tmp); } @@ -18525,7 +18398,7 @@ virDomainVcpuParse(virDomainDefPtr def, if (virStrToLong_ui(tmp, NULL, 10, &vcpus) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("current vcpus count must be an integer")= ); - goto cleanup; + return -1; } VIR_FREE(tmp); } else { @@ -18539,7 +18412,7 @@ virDomainVcpuParse(virDomainDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported CPU placement mode '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); } else { @@ -18550,12 +18423,12 @@ virDomainVcpuParse(virDomainDefPtr def, tmp =3D virXMLPropString(vcpuNode, "cpuset"); if (tmp) { if (virBitmapParse(tmp, &def->cpumask, VIR_DOMAIN_CPUMASK_= LEN) < 0) - goto cleanup; + return -1; =20 if (virBitmapIsAllClear(def->cpumask)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid value of 'cpuset': %s"), tmp= ); - goto cleanup; + return -1; } =20 VIR_FREE(tmp); @@ -18564,10 +18437,10 @@ virDomainVcpuParse(virDomainDefPtr def, } =20 if (virDomainDefSetVcpusMax(def, maxvcpus, xmlopt) < 0) - goto cleanup; + return -1; =20 if ((n =3D virXPathNodeSet("./vcpus/vcpu", ctxt, &nodes)) < 0) - goto cleanup; + return -1; =20 if (n) { /* if individual vcpu states are provided take them as master */ @@ -18583,7 +18456,7 @@ virDomainVcpuParse(virDomainDefPtr def, virStrToLong_uip(tmp, NULL, 10, &id) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing or invalid vcpu id")); - goto cleanup; + return -1; } =20 VIR_FREE(tmp); @@ -18592,7 +18465,7 @@ virDomainVcpuParse(virDomainDefPtr def, virReportError(VIR_ERR_XML_ERROR, _("vcpu id '%u' is out of range of maximum " "vcpu count"), id); - goto cleanup; + return -1; } =20 vcpu =3D virDomainDefGetVcpu(def, id); @@ -18600,13 +18473,13 @@ virDomainVcpuParse(virDomainDefPtr def, if (!(tmp =3D virXMLPropString(nodes[i], "enabled"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing vcpu enabled state")); - goto cleanup; + return -1; } =20 if ((state =3D virTristateBoolTypeFromString(tmp)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("invalid vcpu 'enabled' value '%s'"), tmp= ); - goto cleanup; + return -1; } VIR_FREE(tmp); =20 @@ -18617,7 +18490,7 @@ virDomainVcpuParse(virDomainDefPtr def, if ((hotpluggable =3D virTristateBoolTypeFromString(tmp)) = < 0) { virReportError(VIR_ERR_XML_ERROR, _("invalid vcpu 'hotpluggable' value '%= s'"), tmp); - goto cleanup; + return -1; } vcpu->hotpluggable =3D hotpluggable; VIR_FREE(tmp); @@ -18627,7 +18500,7 @@ virDomainVcpuParse(virDomainDefPtr def, if (virStrToLong_uip(tmp, NULL, 10, &order) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid vcpu order")); - goto cleanup; + return -1; } vcpu->order =3D order; VIR_FREE(tmp); @@ -18635,13 +18508,10 @@ virDomainVcpuParse(virDomainDefPtr def, } } else { if (virDomainDefSetVcpus(def, vcpus) < 0) - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -18650,7 +18520,6 @@ virDomainDefParseBootOptions(virDomainDefPtr def, xmlXPathContextPtr ctxt) { char *name =3D NULL; - int ret =3D -1; size_t i; int n; VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; @@ -18673,34 +18542,34 @@ virDomainDefParseBootOptions(virDomainDefPtr def, def->os.initgroup =3D virXPathString("string(./os/initgroup[1])", = ctxt); =20 if ((n =3D virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) - goto error; + return -1; =20 if (VIR_ALLOC_N(def->os.initargv, n+1) < 0) - goto error; + return -1; for (i =3D 0; i < n; i++) { if (!nodes[i]->children || !nodes[i]->children->content) { virReportError(VIR_ERR_XML_ERROR, "%s", _("No data supplied for element")= ); - goto error; + return -1; } if (VIR_STRDUP(def->os.initargv[i], (const char*) nodes[i]->children->content) < 0) - goto error; + return -1; } def->os.initargv[n] =3D NULL; VIR_FREE(nodes); =20 if ((n =3D virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0) - goto error; + return -1; =20 if (VIR_ALLOC_N(def->os.initenv, n+1) < 0) - goto error; + return -1; for (i =3D 0; i < n; i++) { if (!(name =3D virXMLPropString(nodes[i], "name"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("No name supplied for element"= )); - goto error; + return -1; } =20 if (!nodes[i]->children || @@ -18708,16 +18577,16 @@ virDomainDefParseBootOptions(virDomainDefPtr def, virReportError(VIR_ERR_XML_ERROR, _("No value supplied for element"), name); - goto error; + return -1; } =20 if (VIR_ALLOC(def->os.initenv[i]) < 0) - goto error; + return -1; =20 def->os.initenv[i]->name =3D name; if (VIR_STRDUP(def->os.initenv[i]->value, (const char*) nodes[i]->children->content) < 0) - goto error; + return -1; } def->os.initenv[n] =3D NULL; VIR_FREE(nodes); @@ -18736,10 +18605,10 @@ virDomainDefParseBootOptions(virDomainDefPtr def, def->os.root =3D virXPathString("string(./os/root[1])", ctxt); if ((loader_node =3D virXPathNode("./os/loader[1]", ctxt))) { if (VIR_ALLOC(def->os.loader) < 0) - goto error; + return -1; =20 if (virDomainLoaderDefParseXML(loader_node, def->os.loader) < = 0) - goto error; + return -1; =20 def->os.loader->nvram =3D virXPathString("string(./os/nvram[1]= )", ctxt); def->os.loader->templt =3D virXPathString("string(./os/nvram[1= ]/@template)", ctxt); @@ -18748,12 +18617,12 @@ virDomainDefParseBootOptions(virDomainDefPtr def, =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { if ((n =3D virXPathNodeSet("./os/acpi/table", ctxt, &nodes)) < 0) - goto error; + return -1; =20 if (n > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Only one acpi table is supported")); - goto error; + return -1; } =20 if (n =3D=3D 1) { @@ -18762,30 +18631,26 @@ virDomainDefParseBootOptions(virDomainDefPtr def, if (!tmp) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing acpi table type")); - goto error; + return -1; } =20 if (STREQ_NULLABLE(tmp, "slic")) { VIR_FREE(tmp); tmp =3D virXMLNodeContentString(nodes[0]); def->os.slic_table =3D virFileSanitizePath(tmp); - VIR_FREE(tmp); } else { virReportError(VIR_ERR_XML_ERROR, _("Unknown acpi table type: %s"), tmp); - goto error; + return -1; } } =20 if (virDomainDefParseBootXML(ctxt, def) < 0) - goto error; + return -1; } =20 - ret =3D 0; - - error: - return ret; + return 0; } =20 =20 @@ -18794,29 +18659,26 @@ virDomainResctrlParseVcpus(virDomainDefPtr def, xmlNodePtr node, virBitmapPtr *vcpus) { - int ret =3D -1; VIR_AUTOFREE(char *) vcpus_str =3D NULL; =20 vcpus_str =3D virXMLPropString(node, "vcpus"); if (!vcpus_str) { virReportError(VIR_ERR_XML_ERROR, _("Missing %s attribute 'vcpus'"= ), node->name); - goto cleanup; + return -1; } if (virBitmapParse(vcpus_str, vcpus, VIR_DOMAIN_CPUMASK_LEN) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Invalid %s attribute 'vcpus' value '%s'"), node->name, vcpus_str); - goto cleanup; + return -1; } =20 /* We need to limit the bitmap to number of vCPUs. If there's nothing= left, * then we can just clean up and return 0 immediately */ virBitmapShrink(*vcpus, def->maxvcpus); =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -19219,7 +19081,6 @@ virDomainDefParseCaps(virDomainDefPtr def, virCapsPtr caps, unsigned int flags) { - int ret =3D -1; VIR_AUTOFREE(char *) virttype =3D NULL; VIR_AUTOFREE(char *) arch =3D NULL; VIR_AUTOFREE(char *) ostype =3D NULL; @@ -19237,12 +19098,12 @@ virDomainDefParseCaps(virDomainDefPtr def, if (!virttype) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain type attribute")); - goto cleanup; + return -1; } if ((def->virtType =3D virDomainVirtTypeFromString(virttype)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid domain type %s"), virttype); - goto cleanup; + return -1; } =20 if (!ostype) { @@ -19251,13 +19112,13 @@ virDomainDefParseCaps(virDomainDefPtr def, } else { virReportError(VIR_ERR_XML_ERROR, "%s", _("an os must be specified")); - goto cleanup; + return -1; } } else { if ((def->os.type =3D virDomainOSTypeFromString(ostype)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown OS type '%s'"), ostype); - goto cleanup; + return -1; } } =20 @@ -19274,7 +19135,7 @@ virDomainDefParseCaps(virDomainDefPtr def, if (arch && !(def->os.arch =3D virArchFromString(arch))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown architecture %s"), arch); - goto cleanup; + return -1; } =20 if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, def->os.type, @@ -19282,19 +19143,17 @@ virDomainDefParseCaps(virDomainDefPtr def, def->virtType, NULL, NULL))) { if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)) - goto cleanup; + return -1; virResetLastError(); } else { if (!def->os.arch) def->os.arch =3D capsdata->arch; if ((!def->os.machine && VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0)) - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -26138,7 +25997,6 @@ static int virDomainMemorySourceDefFormat(virBufferPtr buf, virDomainMemoryDefPtr def) { - int ret =3D -1; VIR_AUTOFREE(char *) bitmap =3D NULL; =20 if (!def->pagesize && !def->sourceNodes && !def->nvdimmPath) @@ -26151,7 +26009,7 @@ virDomainMemorySourceDefFormat(virBufferPtr buf, case VIR_DOMAIN_MEMORY_MODEL_DIMM: if (def->sourceNodes) { if (!(bitmap =3D virBitmapFormat(def->sourceNodes))) - goto cleanup; + return -1; =20 virBufferAsprintf(buf, "%s\n", bitmap); } @@ -26180,10 +26038,7 @@ virDomainMemorySourceDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -27603,7 +27458,6 @@ virDomainCpuDefFormat(virBufferPtr buf, { virDomainVcpuDefPtr vcpu; size_t i; - int ret =3D -1; VIR_AUTOFREE(char *) cpumask =3D NULL; =20 virBufferAddLit(buf, "cpumask && !virBitmapIsAllSet(def->cpumask)) { if ((cpumask =3D virBitmapFormat(def->cpumask)) =3D=3D NULL) - goto cleanup; + return -1; virBufferAsprintf(buf, " cpuset=3D'%s'", cpumask); } if (virDomainDefHasVcpusOffline(def)) @@ -27640,10 +27494,7 @@ virDomainCpuDefFormat(virBufferPtr buf, virBufferAddLit(buf, "\n"); } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -28839,29 +28690,25 @@ virDomainSaveXML(const char *configDir, const char *xml) { char uuidstr[VIR_UUID_STRING_BUFLEN]; - int ret =3D -1; VIR_AUTOFREE(char *) configFile =3D NULL; =20 if (!configDir) return 0; =20 if ((configFile =3D virDomainConfigFile(configDir, def->name)) =3D=3D = NULL) - goto cleanup; + return -1; =20 if (virFileMakePath(configDir) < 0) { virReportSystemError(errno, _("cannot create config directory '%s'"), configDir); - goto cleanup; + return -1; } =20 virUUIDFormat(def->uuid, uuidstr); - ret =3D virXMLSaveFile(configFile, - virXMLPickShellSafeComment(def->name, uuidstr), "= edit", - xml); - - cleanup: - return ret; + return virXMLSaveFile(configFile, + virXMLPickShellSafeComment(def->name, uuidstr),= "edit", + xml); } =20 int @@ -28869,18 +28716,12 @@ virDomainSaveConfig(const char *configDir, virCapsPtr caps, virDomainDefPtr def) { - int ret =3D -1; VIR_AUTOFREE(char *) xml =3D NULL; =20 if (!(xml =3D virDomainDefFormat(def, caps, VIR_DOMAIN_DEF_FORMAT_SECU= RE))) - goto cleanup; - - if (virDomainSaveXML(configDir, def, xml)) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return virDomainSaveXML(configDir, def, xml); } =20 int @@ -28895,18 +28736,12 @@ virDomainSaveStatus(virDomainXMLOptionPtr xmlopt, VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES | VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST); =20 - int ret =3D -1; VIR_AUTOFREE(char *) xml =3D NULL; =20 if (!(xml =3D virDomainObjFormat(xmlopt, obj, caps, flags))) - goto cleanup; - - if (virDomainSaveXML(statusDir, obj->def, xml)) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return virDomainSaveXML(statusDir, obj->def, xml); } =20 =20 @@ -28915,15 +28750,14 @@ virDomainDeleteConfig(const char *configDir, const char *autostartDir, virDomainObjPtr dom) { - int ret =3D -1; VIR_AUTOFREE(char *) configFile =3D NULL; VIR_AUTOFREE(char *) autostartLink =3D NULL; =20 if ((configFile =3D virDomainConfigFile(configDir, dom->def->name)) = =3D=3D NULL) - goto cleanup; + return -1; if ((autostartLink =3D virDomainConfigFile(autostartDir, dom->def->name)) =3D=3D NULL) - goto cleanup; + return -1; =20 /* Not fatal if this doesn't work */ unlink(autostartLink); @@ -28934,13 +28768,10 @@ virDomainDeleteConfig(const char *configDir, virReportSystemError(errno, _("cannot remove config %s"), configFile); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 char @@ -29202,20 +29033,19 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr d= isk, virDomainDiskDefPathIterator iter, void *opaque) { - int ret =3D -1; size_t depth =3D 0; virStorageSourcePtr tmp; VIR_AUTOFREE(char *) brokenRaw =3D NULL; =20 if (!ignoreOpenFailure) { if (virStorageFileChainGetBroken(disk->src, &brokenRaw) < 0) - goto cleanup; + return -1; =20 if (brokenRaw) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to visit backing chain file %s"), brokenRaw); - goto cleanup; + return -1; } } =20 @@ -29224,16 +29054,13 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr d= isk, if (virStorageSourceIsLocalStorage(tmp) && tmp->path) { if (iter(disk, tmp->path, depth, opaque) < 0) - goto cleanup; + return -1; } =20 depth++; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -29248,7 +29075,6 @@ virDomainDefCopy(virDomainDefPtr src, void *parseOpaque, bool migratable) { - virDomainDefPtr ret; unsigned int format_flags =3D VIR_DOMAIN_DEF_FORMAT_SECURE; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; @@ -29261,9 +29087,7 @@ virDomainDefCopy(virDomainDefPtr src, if (!(xml =3D virDomainDefFormat(src, caps, format_flags))) return NULL; =20 - ret =3D virDomainDefParseString(xml, caps, xmlopt, parseOpaque, parse_= flags); - - return ret; + return virDomainDefParseString(xml, caps, xmlopt, parseOpaque, parse_f= lags); } =20 virDomainDefPtr @@ -29687,7 +29511,6 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, virCapsPtr caps, virDomainXMLOptionPtr xmlopt) { - virDomainDeviceDefPtr ret =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; int flags =3D VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_S= ECURE; int rc =3D -1; @@ -29767,19 +29590,16 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, _("Copying definition of '%d' type " "is not implemented yet."), src->type); - goto cleanup; + return NULL; } =20 if (rc < 0) - goto cleanup; + return NULL; =20 xmlStr =3D virBufferContentAndReset(&buf); - ret =3D virDomainDeviceDefParse(xmlStr, def, caps, xmlopt, - VIR_DOMAIN_DEF_PARSE_INACTIVE | - VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); - - cleanup: - return ret; + return virDomainDeviceDefParse(xmlStr, def, caps, xmlopt, + VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); } =20 =20 @@ -30152,11 +29972,10 @@ virDomainDefGetShortName(const virDomainDef *def) virReportSystemError(errno, "%s", _("Cannot convert wide character string " "back to multi-byte domain name")); - goto cleanup; + return NULL; } =20 ignore_value(virAsprintf(&ret, "%d-%s", def->id, shortname)); - cleanup: return ret; } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list