From nobody Sun Apr 28 17:47:47 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 1551457621558731.0330783250478; Fri, 1 Mar 2019 08:27:01 -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 CAE4F301509E; Fri, 1 Mar 2019 16:26:59 +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 9C6545EE11; Fri, 1 Mar 2019 16:26:59 +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 5AE86181A000; Fri, 1 Mar 2019 16:26:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GQvSI012390 for ; Fri, 1 Mar 2019 11:26:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 571F860A9A; Fri, 1 Mar 2019 16:26:57 +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 F2F8060DB4; Fri, 1 Mar 2019 16:26:56 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Mar 2019 11:26:43 -0500 Message-Id: <20190301162652.32533-2-jferlan@redhat.com> In-Reply-To: <20190301162652.32533-1-jferlan@redhat.com> References: <20190301162652.32533-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v3 01/10] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 01 Mar 2019 16:27:00 +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 Reviewed-by: J=C3=A1n Tomko --- 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 477deb777e..9b0dbe3c91 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18397,6 +18397,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"))) { @@ -18411,14 +18412,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 Sun Apr 28 17:47:47 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 1551457626417793.2279948824081; Fri, 1 Mar 2019 08:27:06 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7EAE3015550; Fri, 1 Mar 2019 16:27:04 +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 9F18E608CD; Fri, 1 Mar 2019 16:27:04 +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 2FE383FB10; Fri, 1 Mar 2019 16:27:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GQwRY012405 for ; Fri, 1 Mar 2019 11:26:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id D6F9060DB4; Fri, 1 Mar 2019 16:26:58 +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 7FC8860A9A; Fri, 1 Mar 2019 16:26:57 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Mar 2019 11:26:44 -0500 Message-Id: <20190301162652.32533-3-jferlan@redhat.com> In-Reply-To: <20190301162652.32533-1-jferlan@redhat.com> References: <20190301162652.32533-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v3 02/10] conf: Use VIR_AUTOPTR(virBitmap) in domain_conf X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 01 Mar 2019 16:27:05 +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 Reviewed-by: J=C3=A1n Tomko --- 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 9b0dbe3c91..fae0fa7dc0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1809,8 +1809,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; @@ -1837,7 +1837,6 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, i), map= len); } =20 - virBitmapFree(allcpumap); return i; } =20 @@ -2987,7 +2986,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 @@ -3028,7 +3027,6 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, retval =3D 0; =20 error: - virBitmapFree(thrmap); return retval; } =20 @@ -18326,9 +18324,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", @@ -18384,7 +18382,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, =20 cleanup: VIR_FREE(tmp); - virBitmapFree(cpumask); return ret; } =20 @@ -18396,9 +18393,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", @@ -18418,7 +18415,6 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node) VIR_STEAL_PTR(ret, def); =20 cleanup: - virBitmapFree(def); VIR_FREE(tmp); return ret; } @@ -18779,11 +18775,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; @@ -18806,7 +18802,6 @@ virDomainThreadSchedParseHelper(xmlNodePtr node, ret =3D 0; =20 cleanup: - virBitmapFree(map); return ret; } =20 @@ -19510,12 +19505,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 @@ -19575,7 +19570,6 @@ virDomainCachetuneDefParse(virDomainDefPtr def, ctxt->node =3D oldnode; virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); - virBitmapFree(vcpus); VIR_FREE(nodes); return ret; } @@ -19729,9 +19723,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; @@ -19790,7 +19784,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 Sun Apr 28 17:47:47 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 1551457621620695.0879446939192; Fri, 1 Mar 2019 08:27:01 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D61BF3088D88; Fri, 1 Mar 2019 16:26:59 +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 A6D7B60BE0; Fri, 1 Mar 2019 16:26:59 +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 461A0181A010; Fri, 1 Mar 2019 16:26:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GQwf5012400 for ; Fri, 1 Mar 2019 11:26:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6585F611B6; Fri, 1 Mar 2019 16:26:58 +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 0BFF860DB4; Fri, 1 Mar 2019 16:26:57 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Mar 2019 11:26:45 -0500 Message-Id: <20190301162652.32533-4-jferlan@redhat.com> In-Reply-To: <20190301162652.32533-1-jferlan@redhat.com> References: <20190301162652.32533-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v3 03/10] 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 01 Mar 2019 16:27:00 +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 Reviewed-by: J=C3=A1n Tomko --- 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 fae0fa7dc0..30d678c8d9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2982,7 +2982,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; @@ -2996,7 +2995,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 @@ -3008,26 +3007,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 @@ -18778,31 +18774,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 Sun Apr 28 17:47:47 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 1551457626427581.940124792207; Fri, 1 Mar 2019 08:27:06 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1A533088DAC; Fri, 1 Mar 2019 16:27:04 +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 AE4E360BE0; Fri, 1 Mar 2019 16:27:04 +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 6A4F13FB12; Fri, 1 Mar 2019 16:27:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GQwTB012410 for ; Fri, 1 Mar 2019 11:26:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id E640260A9A; Fri, 1 Mar 2019 16:26:58 +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 8E6E32B4BD; Fri, 1 Mar 2019 16:26:58 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Mar 2019 11:26:46 -0500 Message-Id: <20190301162652.32533-5-jferlan@redhat.com> In-Reply-To: <20190301162652.32533-1-jferlan@redhat.com> References: <20190301162652.32533-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v3 04/10] 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 01 Mar 2019 16:27:05 +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 Reviewed-by: J=C3=A1n Tomko --- 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 30d678c8d9..cbaa32e174 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7137,7 +7137,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; @@ -7223,7 +7222,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); @@ -13011,7 +13009,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; @@ -13092,7 +13089,6 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; =20 cleanup: - VIR_FREE(type); VIR_FREE(path); VIR_FREE(model); VIR_FREE(backend); @@ -18547,7 +18543,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 @@ -18575,7 +18571,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 Sun Apr 28 17:47:47 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 1551457629224681.9430653718762; Fri, 1 Mar 2019 08:27:09 -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 7E2013015091; Fri, 1 Mar 2019 16:27:07 +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 519CC1001DF4; Fri, 1 Mar 2019 16:27:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0F43D3FB15; Fri, 1 Mar 2019 16:27:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GQxVs012425 for ; Fri, 1 Mar 2019 11:26:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id B4D2460A9A; Fri, 1 Mar 2019 16:26:59 +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 1D27360DB4; Fri, 1 Mar 2019 16:26:59 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Mar 2019 11:26:47 -0500 Message-Id: <20190301162652.32533-6-jferlan@redhat.com> In-Reply-To: <20190301162652.32533-1-jferlan@redhat.com> References: <20190301162652.32533-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v3 05/10] 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.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.45]); Fri, 01 Mar 2019 16:27:07 +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 Reviewed-by: J=C3=A1n Tomko --- 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 cbaa32e174..c06c52271c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1105,11 +1105,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", @@ -1167,8 +1167,6 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDef= Ptr keywrap, ret =3D 0; =20 cleanup: - VIR_FREE(name); - VIR_FREE(state); return ret; } =20 @@ -1177,8 +1175,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; @@ -1200,7 +1198,6 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlX= PathContextPtr ctxt) cleanup: if (ret < 0) VIR_FREE(def->keywrap); - VIR_FREE(nodes); return ret; } =20 @@ -1273,10 +1270,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; @@ -1308,7 +1305,6 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver, ret =3D 0; =20 cleanup: - VIR_FREE(str); return ret; } =20 @@ -1350,8 +1346,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) { @@ -1416,7 +1412,6 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root, return 0; =20 error: - VIR_FREE(c); VIR_FREE(dev->path); return -1; } @@ -5337,8 +5332,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; @@ -5367,7 +5362,6 @@ virDomainDefCollectBootOrder(virDomainDefPtr def ATTR= IBUTE_UNUSED, ret =3D 0; =20 cleanup: - VIR_FREE(order); return ret; } =20 @@ -6888,8 +6882,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 @@ -6905,7 +6899,6 @@ virDomainDeviceUSBMasterParseXML(xmlNodePtr node, ret =3D 0; =20 cleanup: - VIR_FREE(startport); return ret; } =20 @@ -6913,9 +6906,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, @@ -6949,8 +6942,6 @@ virDomainDeviceBootParseXML(xmlNodePtr node, ret =3D 0; =20 cleanup: - VIR_FREE(order); - VIR_FREE(loadparm); return ret; } =20 @@ -6959,8 +6950,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 @@ -6983,8 +6974,6 @@ virDomainDeviceISAAddressParseXML(xmlNodePtr node, =20 ret =3D 0; cleanup: - VIR_FREE(iobase); - VIR_FREE(irq); return ret; } =20 @@ -6994,7 +6983,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) { @@ -7011,15 +7000,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 @@ -7029,7 +7014,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) { @@ -7106,7 +7091,6 @@ virDomainDeviceAddressParseXML(xmlNodePtr address, =20 ret =3D 0; cleanup: - VIR_FREE(type); return ret; } =20 @@ -7137,10 +7121,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 @@ -7222,9 +7206,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 @@ -7253,9 +7234,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 @@ -7264,16 +7245,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 @@ -7285,24 +7263,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; @@ -7311,27 +7287,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")); @@ -7344,10 +7317,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")); @@ -7441,14 +7412,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; @@ -7479,9 +7449,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; @@ -7535,8 +7505,6 @@ virDomainStorageNetworkParseHost(xmlNodePtr hostnode, =20 cleanup: virStorageNetHostDefClear(&host); - VIR_FREE(transport); - VIR_FREE(port); return ret; } =20 @@ -7568,8 +7536,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) { @@ -7644,9 +7614,6 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr = sourcenode, =20 ret =3D 0; cleanup: - VIR_FREE(bus); - VIR_FREE(target); - VIR_FREE(unit); return ret; } =20 @@ -7726,8 +7693,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 @@ -7746,7 +7713,6 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sour= cenode, ret =3D virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsi= src); =20 cleanup: - VIR_FREE(protocol); return ret; } =20 @@ -7754,10 +7720,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", @@ -7799,8 +7765,6 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr= sourcenode, =20 ret =3D 0; cleanup: - VIR_FREE(wwpn); - VIR_FREE(protocol); return ret; } =20 @@ -7810,9 +7774,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", @@ -7836,7 +7800,6 @@ virDomainHostdevSubsysMediatedDevDefParseXML(virDomai= nHostdevDefPtr def, virUUIDFormat(uuid, mdevsrc->uuidstr); ret =3D 0; cleanup: - VIR_FREE(uuidxml); return ret; } =20 @@ -7848,17 +7811,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 @@ -8018,12 +7981,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 @@ -8031,12 +7988,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", @@ -8084,11 +8043,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 @@ -8103,12 +8057,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; @@ -8133,9 +8087,7 @@ virDomainNetIPInfoParseXML(const char *source, cleanup: if (ret < 0) virNetDevIPInfoClear(def); - VIR_FREE(ip); virNetDevIPRouteFree(route); - VIR_FREE(nodes); return ret; } =20 @@ -8146,8 +8098,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; @@ -8163,10 +8115,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, @@ -8178,7 +8128,6 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node, ret->rx_max_coalesced_frames =3D tmp; =20 cleanup: - VIR_FREE(str); ctxt->node =3D save; return ret; =20 @@ -8553,8 +8502,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) @@ -8592,7 +8542,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 @@ -8647,7 +8596,6 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, virSecurityLabelDefFree(def->seclabels[i - 1]); VIR_FREE(def->seclabels); def->nseclabels =3D 0; - VIR_FREE(list); return -1; } =20 @@ -8662,8 +8610,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; @@ -8731,7 +8679,6 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLa= belDefPtr **seclabels_rtn, goto error; } } - VIR_FREE(list); =20 *nseclabels_rtn =3D nseclabels; *seclabels_rtn =3D seclabels; @@ -8742,7 +8689,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 @@ -8785,10 +8731,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; @@ -8833,11 +8779,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: @@ -8850,9 +8791,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 @@ -8889,7 +8830,6 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, =20 cleanup: virStorageSourcePoolDefFree(source); - VIR_FREE(mode); return ret; } =20 @@ -8900,11 +8840,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", @@ -8981,9 +8921,6 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, ret =3D 0; =20 cleanup: - VIR_FREE(tlsCfg); - VIR_FREE(haveTLS); - VIR_FREE(protocol); return ret; } =20 @@ -9138,11 +9075,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; @@ -9203,9 +9140,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; } @@ -9301,11 +9235,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; @@ -9378,10 +9312,6 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, ret =3D 0; =20 cleanup: - VIR_FREE(ready); - VIR_FREE(blockJob); - VIR_FREE(mirrorType); - VIR_FREE(mirrorFormat); return ret; } =20 @@ -9390,7 +9320,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) { @@ -9427,13 +9357,11 @@ virDomainDiskDefGeometryParse(virDomainDiskDefPtr d= ef, tmp); goto error; } - VIR_FREE(tmp); } =20 return 0; =20 error: - VIR_FREE(tmp); return -1; } =20 @@ -9578,8 +9506,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 @@ -9688,13 +9616,10 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr = def, tmp); goto cleanup; } - VIR_FREE(tmp); =20 ret =3D 0; =20 cleanup: - VIR_FREE(tmp); - return ret; } =20 @@ -9743,26 +9668,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; @@ -10150,25 +10075,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 @@ -10209,11 +10116,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) @@ -10252,9 +10159,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 @@ -10455,27 +10359,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 @@ -10614,20 +10518,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: { @@ -10790,22 +10692,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: @@ -10834,15 +10720,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 @@ -10988,16 +10874,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: @@ -11019,11 +10895,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; @@ -11122,16 +10998,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) { @@ -11173,11 +11049,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; @@ -11220,9 +11091,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 @@ -11246,7 +11117,6 @@ virDomainChrSourceReconnectDefParseXML(virDomainChr= SourceReconnectDefPtr def, tmp); goto cleanup; } - VIR_FREE(tmp); } else { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing timeout for chardev with " @@ -11259,7 +11129,6 @@ virDomainChrSourceReconnectDefParseXML(virDomainChr= SourceReconnectDefPtr def, ret =3D 0; cleanup: ctxt->node =3D saveNode; - VIR_FREE(tmp); return ret; } =20 @@ -11279,46 +11148,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; @@ -12066,44 +11935,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: @@ -12203,11 +12036,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, @@ -12323,12 +12156,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 @@ -12348,8 +12175,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; @@ -12360,7 +12187,6 @@ virDomainChrSourceDefParseMode(xmlNodePtr source) _("Unknown source mode '%s'"), mode); } =20 - VIR_FREE(mode); return ret; } =20 @@ -12372,8 +12198,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; @@ -12401,7 +12227,6 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef= Ptr def, goto error; } def->data.tcp.tlsFromConfig =3D !!tmpVal; - VIR_FREE(tmp); } =20 if (virDomainChrSourceReconnectDefParseXML(&def->data.tcp.reconnect, @@ -12413,7 +12238,6 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef= Ptr def, return 0; =20 error: - VIR_FREE(tmp); return -1; } =20 @@ -12468,7 +12292,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 @@ -12477,11 +12301,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 @@ -12490,7 +12312,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; @@ -12500,11 +12322,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 @@ -12513,7 +12333,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 @@ -12522,11 +12342,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 @@ -12774,10 +12592,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; @@ -12844,8 +12662,6 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlop= t, } =20 cleanup: - VIR_FREE(type); - return def; =20 error: @@ -12861,10 +12677,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; @@ -12976,9 +12792,6 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr= xmlopt, } =20 cleanup: - VIR_FREE(mode); - VIR_FREE(type); - return def; =20 error: @@ -13009,14 +12822,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; @@ -13089,11 +12902,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 @@ -13109,7 +12917,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; @@ -13127,7 +12935,6 @@ virDomainPanicDefParseXML(virDomainXMLOptionPtr xml= opt, } =20 cleanup: - VIR_FREE(model); return panic; =20 error: @@ -13146,9 +12953,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; @@ -13276,10 +13083,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 @@ -13297,7 +13100,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; @@ -13320,8 +13123,6 @@ virDomainHubDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; =20 cleanup: - VIR_FREE(type); - return def; =20 error: @@ -13336,16 +13137,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; @@ -13448,11 +13248,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; @@ -13468,8 +13263,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 @@ -13497,11 +13292,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 */ @@ -13516,10 +13309,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 && @@ -13557,16 +13348,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"); @@ -13691,14 +13482,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 @@ -13709,12 +13492,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 @@ -13738,7 +13521,6 @@ virDomainGraphicsListensParseXML(virDomainGraphicsD= efPtr def, =20 def->nListens++; } - VIR_FREE(listenNodes); } =20 /* If no element was found in XML for backward compatibility @@ -13781,8 +13563,6 @@ virDomainGraphicsListensParseXML(virDomainGraphicsD= efPtr def, ret =3D 0; cleanup: virDomainGraphicsListenDefClear(&newListen); - VIR_FREE(listenNodes); - VIR_FREE(socketPath); ctxt->node =3D save; return ret; } @@ -13794,12 +13574,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; @@ -13866,11 +13646,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 @@ -13881,11 +13656,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 @@ -13926,8 +13701,6 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDe= fPtr def, =20 ret =3D 0; cleanup: - VIR_FREE(fullscreen); - VIR_FREE(enable); ctxt->node =3D save; return ret; } @@ -13939,11 +13712,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; @@ -13977,10 +13750,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 @@ -13989,8 +13758,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")) { @@ -14010,7 +13779,6 @@ virDomainGraphicsDefParseXMLDesktop(virDomainGraphi= csDefPtr def, =20 ret =3D 0; cleanup: - VIR_FREE(fullscreen); return ret; } =20 @@ -14022,12 +13790,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; @@ -14087,16 +13855,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 @@ -14104,25 +13872,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", @@ -14135,15 +13897,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", @@ -14156,15 +13916,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", @@ -14177,15 +13935,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", @@ -14197,16 +13953,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", @@ -14217,16 +13971,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", @@ -14238,15 +13990,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", @@ -14258,21 +14008,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 @@ -14280,18 +14027,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", @@ -14303,10 +14047,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; } @@ -14316,10 +14058,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 @@ -14368,8 +14106,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; @@ -14418,8 +14156,6 @@ virDomainGraphicsDefParseXML(virDomainXMLOptionPtr = xmlopt, } =20 cleanup: - VIR_FREE(type); - return def; =20 error: @@ -14432,8 +14168,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; @@ -14446,8 +14182,6 @@ virDomainSoundCodecDefParseXML(xmlNodePtr node) } =20 cleanup: - VIR_FREE(type); - return def; =20 error: @@ -14463,9 +14197,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; @@ -14482,7 +14216,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); @@ -14492,22 +14226,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 @@ -14515,8 +14244,6 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xml= opt, goto error; =20 cleanup: - VIR_FREE(model); - ctxt->node =3D save; return def; =20 @@ -14532,9 +14259,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; @@ -14568,9 +14295,6 @@ virDomainWatchdogDefParseXML(virDomainXMLOptionPtr = xmlopt, goto error; =20 cleanup: - VIR_FREE(action); - VIR_FREE(model); - return def; =20 error: @@ -14586,13 +14310,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; @@ -14684,10 +14408,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 @@ -14704,11 +14424,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; @@ -14755,9 +14475,6 @@ virDomainMemballoonDefParseXML(virDomainXMLOptionPt= r xmlopt, goto error; =20 cleanup: - VIR_FREE(model); - VIR_FREE(deflate); - ctxt->node =3D save; return def; =20 @@ -14793,13 +14510,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; @@ -14863,7 +14579,6 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr xml= opt, } def->msi.ioeventfd =3D val; } - VIR_FREE(tmp); } =20 /* msi option is only relevant with a server */ @@ -14880,7 +14595,6 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr xml= opt, VIR_STEAL_PTR(ret, def); cleanup: ctxt->node =3D save; - VIR_FREE(tmp); virDomainShmemDefFree(def); return ret; } @@ -14952,7 +14666,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", @@ -15013,7 +14727,6 @@ virSysinfoSystemParseXML(xmlNodePtr node, ret =3D 0; cleanup: virSysinfoSystemDefFree(def); - VIR_FREE(tmpUUID); return ret; } =20 @@ -15023,10 +14736,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; @@ -15064,8 +14778,6 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt, *nbaseBoard =3D nboards; ret =3D 0; cleanup: - VIR_FREE(boards); - VIR_FREE(nodes); ctxt->node =3D oldnode; return ret; } @@ -15077,9 +14789,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) @@ -15100,7 +14812,6 @@ virSysinfoOEMStringsParseXML(xmlXPathContextPtr ctx= t, VIR_STEAL_PTR(*oem, def); ret =3D 0; cleanup: - VIR_FREE(strings); virSysinfoOEMStringsDefFree(def); return ret; } @@ -15156,7 +14867,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", @@ -15229,7 +14940,6 @@ virSysinfoParseXML(xmlNodePtr node, } =20 cleanup: - VIR_FREE(type); return def; =20 error: @@ -15323,9 +15033,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) { @@ -15364,8 +15074,6 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) } =20 cleanup: - VIR_FREE(accel2d); - VIR_FREE(accel3d); return def; } =20 @@ -15374,8 +15082,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) { @@ -15402,7 +15110,6 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node) def->vgaconf =3D val; =20 cleanup: - VIR_FREE(vgaconf); return def; } =20 @@ -15416,13 +15123,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; @@ -15529,14 +15236,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: @@ -15553,8 +15252,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 @@ -15613,8 +15312,6 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr x= mlopt, } =20 cleanup: - VIR_FREE(type); - VIR_FREE(mode); ctxt->node =3D save; return def; =20 @@ -15633,7 +15330,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; @@ -15689,8 +15387,6 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr = xmlopt, =20 =20 cleanup: - VIR_FREE(bus); - VIR_FREE(type); return def; =20 error: @@ -15740,10 +15436,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; @@ -15815,11 +15513,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: @@ -15834,9 +15527,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; @@ -15856,13 +15549,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; } @@ -15875,7 +15566,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 { @@ -15883,10 +15575,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; } @@ -15897,7 +15587,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) { @@ -15909,7 +15600,6 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, =20 ret =3D 0; cleanup: - VIR_FREE(tmp); return ret; } =20 @@ -15918,10 +15608,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= ")); @@ -15956,8 +15646,6 @@ virDomainPerfEventDefParseXML(virDomainPerfDefPtr p= erf, ret =3D 0; =20 cleanup: - VIR_FREE(name); - VIR_FREE(enabled); return ret; } =20 @@ -15967,8 +15655,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; @@ -15981,7 +15669,6 @@ virDomainPerfDefParseXML(virDomainDefPtr def, ret =3D 0; =20 cleanup: - VIR_FREE(nodes); return ret; } =20 @@ -15991,9 +15678,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: @@ -16038,7 +15725,6 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, ret =3D 0; =20 cleanup: - VIR_FREE(nodemask); ctxt->node =3D save; return ret; } @@ -16101,10 +15787,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; @@ -16154,7 +15840,6 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode, def->session =3D virXPathString("string(./session)", ctxt); =20 cleanup: - VIR_FREE(type); ctxt->node =3D save; return def; =20 @@ -16170,11 +15855,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; @@ -16214,7 +15899,6 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xm= lopt, =20 def->discard =3D val; } - VIR_FREE(tmp); =20 /* source */ if ((node =3D virXPathNode("./source", ctxt)) && @@ -16239,7 +15923,6 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xm= lopt, return def; =20 error: - VIR_FREE(tmp); virDomainMemoryDefFree(def); ctxt->node =3D save; return NULL; @@ -16250,11 +15933,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 @@ -16315,8 +15999,6 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, =20 cleanup: ctxt->node =3D save; - VIR_FREE(iommu); - VIR_FREE(tmp); return ret; } =20 @@ -16327,11 +16009,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 @@ -16380,8 +16063,6 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xml= opt, =20 cleanup: ctxt->node =3D save; - VIR_FREE(vsock); - VIR_FREE(tmp); return ret; } =20 @@ -17975,17 +17656,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 @@ -17993,12 +17672,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) @@ -18080,8 +17759,6 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, ret =3D 0; =20 cleanup: - VIR_FREE(tmp); - VIR_FREE(nodes); return ret; } =20 @@ -18162,7 +17839,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; @@ -18180,7 +17857,6 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node) } =20 cleanup: - VIR_FREE(tmp); return iothrid; =20 error: @@ -18195,10 +17871,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) { @@ -18206,7 +17882,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) @@ -18232,7 +17907,6 @@ virDomainDefParseIOThreads(virDomainDefPtr def, } def->iothreadids[def->niothreadids++] =3D iothrid; } - VIR_FREE(nodes); =20 if (virDomainIOThreadIDDefArrayInit(def, iothreads) < 0) goto error; @@ -18240,7 +17914,6 @@ virDomainDefParseIOThreads(virDomainDefPtr def, return 0; =20 error: - VIR_FREE(nodes); return -1; } =20 @@ -18256,8 +17929,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")); @@ -18301,7 +17974,6 @@ virDomainVcpuPinDefParseXML(virDomainDefPtr def, ret =3D 0; =20 cleanup: - VIR_FREE(tmp); return ret; } =20 @@ -18317,7 +17989,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"))) { @@ -18373,7 +18045,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, ret =3D 0; =20 cleanup: - VIR_FREE(tmp); return ret; } =20 @@ -18386,7 +18057,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"))) { @@ -18407,7 +18078,6 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node) VIR_STEAL_PTR(ret, def); =20 cleanup: - VIR_FREE(tmp); return ret; } =20 @@ -18543,7 +18213,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 @@ -18571,7 +18241,6 @@ virDomainHugepagesParseXML(xmlNodePtr node, =20 ret =3D 0; cleanup: - VIR_FREE(nodeset); ctxt->node =3D oldnode; return ret; } @@ -18648,9 +18317,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"); @@ -18683,9 +18352,6 @@ virDomainLoaderDefParseXML(xmlNodePtr node, =20 ret =3D 0; cleanup: - VIR_FREE(readonly_str); - VIR_FREE(secure_str); - VIR_FREE(type_str); return ret; } =20 @@ -18697,8 +18363,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, @@ -18747,13 +18413,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; } @@ -18836,13 +18500,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 @@ -18976,9 +18640,6 @@ virDomainVcpuParse(virDomainDefPtr def, ret =3D 0; =20 cleanup: - VIR_FREE(nodes); - VIR_FREE(tmp); - return ret; } =20 @@ -18987,12 +18648,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.... @@ -19123,8 +18784,6 @@ virDomainDefParseBootOptions(virDomainDefPtr def, ret =3D 0; =20 error: - VIR_FREE(nodes); - VIR_FREE(tmp); return ret; } =20 @@ -19134,8 +18793,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) { @@ -19156,7 +18815,6 @@ virDomainResctrlParseVcpus(virDomainDefPtr def, =20 ret =3D 0; cleanup: - VIR_FREE(vcpus_str); return ret; } =20 @@ -19196,8 +18854,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 @@ -19242,7 +18900,6 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr = ctxt, tmp); goto cleanup; } - VIR_FREE(tmp); =20 if (virDomainParseScaledValue("./@size", "./@unit", ctxt, &size, 1024, @@ -19255,7 +18912,6 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr = ctxt, ret =3D 0; cleanup: ctxt->node =3D oldnode; - VIR_FREE(tmp); return ret; } =20 @@ -19328,14 +18984,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 @@ -19423,9 +19079,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; } @@ -19437,10 +19090,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. */ @@ -19478,8 +19131,6 @@ virDomainResctrlNew(xmlNodePtr node, VIR_STEAL_PTR(ret, resctrl); cleanup: virDomainResctrlDefFree(resctrl); - VIR_FREE(alloc_id); - VIR_FREE(vcpus_str); return ret; } =20 @@ -19491,13 +19142,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 @@ -19557,7 +19208,6 @@ virDomainCachetuneDefParse(virDomainDefPtr def, ctxt->node =3D oldnode; virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); - VIR_FREE(nodes); return ret; } =20 @@ -19569,10 +19219,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); @@ -19643,10 +19293,6 @@ virDomainDefParseCaps(virDomainDefPtr def, =20 ret =3D 0; cleanup: - VIR_FREE(virttype); - VIR_FREE(ostype); - VIR_FREE(arch); - VIR_FREE(capsdata); return ret; } =20 @@ -19659,8 +19305,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 @@ -19690,14 +19336,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 @@ -19709,10 +19353,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; @@ -19771,7 +19415,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, ctxt->node =3D oldnode; virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); - VIR_FREE(nodes); return ret; } =20 @@ -19784,8 +19427,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; @@ -19795,18 +19437,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())) @@ -21453,7 +21096,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)) { @@ -21482,7 +21124,6 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } def->os.smbios_mode =3D mode; - VIR_FREE(tmp); } =20 if (virDomainKeyWrapDefParseXML(def, ctxt) < 0) @@ -21504,8 +21145,6 @@ virDomainDefParseXML(xmlDocPtr xml, return def; =20 error: - VIR_FREE(tmp); - VIR_FREE(nodes); virDomainDefFree(def); return NULL; } @@ -21518,17 +21157,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; @@ -21554,7 +21193,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); @@ -21563,10 +21201,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); @@ -21594,7 +21230,6 @@ virDomainObjParseXML(xmlDocPtr xml, virDomainObjTaint(obj, flag); } } - VIR_FREE(nodes); =20 if (xmlopt->privateData.parse && xmlopt->privateData.parse(ctxt, obj, &xmlopt->config) < 0) @@ -21615,7 +21250,6 @@ virDomainObjParseXML(xmlDocPtr xml, =20 error: virObjectUnref(obj); - VIR_FREE(nodes); return NULL; } =20 @@ -23152,8 +22786,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, @@ -23622,8 +23256,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); @@ -24083,7 +23715,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)); @@ -24095,8 +23727,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)) @@ -26531,8 +26161,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; @@ -26576,7 +26206,6 @@ virDomainMemorySourceDefFormat(virBufferPtr buf, ret =3D 0; =20 cleanup: - VIR_FREE(bitmap); return ret; } =20 @@ -27727,7 +27356,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; @@ -27745,7 +27374,6 @@ virDomainResctrlMonDefFormatHelper(virDomainResctrl= MonDefPtr domresmon, =20 virBufferAsprintf(buf, "vcpus=3D'%s'/>\n", vcpus); =20 - VIR_FREE(vcpus); return 0; } =20 @@ -27756,9 +27384,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, @@ -27802,7 +27430,6 @@ virDomainCachetuneDefFormat(virBufferPtr buf, ret =3D 0; cleanup: virBufferFreeAndReset(&childrenBuf); - VIR_FREE(vcpus); return ret; } =20 @@ -27827,8 +27454,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, @@ -27865,7 +27492,6 @@ virDomainMemorytuneDefFormat(virBufferPtr buf, ret =3D 0; cleanup: virBufferFreeAndReset(&childrenBuf); - VIR_FREE(vcpus); return ret; } =20 @@ -28000,8 +27626,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; @@ -29349,8 +28971,6 @@ virDomainDeleteConfig(const char *configDir, ret =3D 0; =20 cleanup: - VIR_FREE(configFile); - VIR_FREE(autostartLink); return ret; } =20 @@ -29616,7 +29236,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) @@ -29644,7 +29264,6 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr dis= k, ret =3D 0; =20 cleanup: - VIR_FREE(brokenRaw); return ret; } =20 @@ -29660,11 +29279,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; @@ -29675,7 +29294,6 @@ virDomainDefCopy(virDomainDefPtr src, =20 ret =3D virDomainDefParseString(xml, caps, xmlopt, parseOpaque, parse_= flags); =20 - VIR_FREE(xml); return ret; } =20 @@ -30103,9 +29721,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: @@ -30192,7 +29810,6 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); =20 cleanup: - VIR_FREE(xmlStr); return ret; } =20 @@ -30523,8 +30140,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 @@ -30571,7 +30188,6 @@ virDomainDefGetShortName(const virDomainDef *def) =20 ignore_value(virAsprintf(&ret, "%d-%s", def->id, shortname)); cleanup: - VIR_FREE(shortname); return ret; } =20 @@ -30850,9 +30466,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; @@ -30919,7 +30535,6 @@ virDomainNetResolveActualType(virDomainNetDefPtr if= ace) =20 cleanup: virNetworkDefFree(def); - VIR_FREE(xml); virObjectUnref(conn); virObjectUnref(net); return ret; @@ -31048,10 +30663,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; @@ -31209,7 +30824,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 Sun Apr 28 17:47:47 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 1551457630710218.68880729539467; Fri, 1 Mar 2019 08:27:10 -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 AC99D1244EA; Fri, 1 Mar 2019 16:27:08 +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 858B61001DF4; Fri, 1 Mar 2019 16:27:08 +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 45451181A000; Fri, 1 Mar 2019 16:27:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GR0FK012430 for ; Fri, 1 Mar 2019 11:27:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 31F35608CD; Fri, 1 Mar 2019 16:27:00 +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 E3990648C3 for ; Fri, 1 Mar 2019 16:26:59 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Mar 2019 11:26:48 -0500 Message-Id: <20190301162652.32533-7-jferlan@redhat.com> In-Reply-To: <20190301162652.32533-1-jferlan@redhat.com> References: <20190301162652.32533-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 06/10] conf: Merge with previous 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.38]); Fri, 01 Mar 2019 16:27:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Seems I missed a few more VIR_AUTOFREE capable places. Once ACK'd I will merge with previous. Signed-off-by: John Ferlan Reviewed-by: Erik Skultety Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c06c52271c..da2175713d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22020,13 +22020,11 @@ virDomainChannelDefCheckABIStability(virDomainChr= DefPtr src, case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: if (memcmp(src->target.addr, dst->target.addr, sizeof(*src->target.addr)) !=3D 0) { - char *saddr =3D virSocketAddrFormatFull(src->target.addr, true= , ":"); - char *daddr =3D virSocketAddrFormatFull(dst->target.addr, true= , ":"); + VIR_AUTOFREE(char *) saddr =3D virSocketAddrFormatFull(src->ta= rget.addr, true, ":"); + VIR_AUTOFREE(char *) daddr =3D virSocketAddrFormatFull(dst->ta= rget.addr, true, ":"); virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Target channel addr %s does not match source= %s"), NULLSTR(daddr), NULLSTR(saddr)); - VIR_FREE(saddr); - VIR_FREE(daddr); return false; } break; @@ -25315,8 +25313,10 @@ virDomainNetDefFormat(virBufferPtr buf, virBufferEscapeString(buf, "\n", def->model); if (virDomainNetIsVirtioModel(def)) { - char *str =3D NULL, *gueststr =3D NULL, *hoststr =3D NULL; int rc =3D 0; + VIR_AUTOFREE(char *) str =3D NULL; + VIR_AUTOFREE(char *) gueststr =3D NULL; + VIR_AUTOFREE(char *) hoststr =3D NULL; =20 if (virDomainVirtioNetDriverFormat(&str, def) < 0 || virDomainVirtioNetGuestOptsFormat(&gueststr, def) < 0 || @@ -25339,9 +25339,6 @@ virDomainNetDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } - VIR_FREE(str); - VIR_FREE(hoststr); - VIR_FREE(gueststr); =20 if (rc < 0) return -1; @@ -25561,19 +25558,19 @@ virDomainChrTargetDefFormat(virBufferPtr buf, switch (def->targetType) { case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: { int port =3D virSocketAddrGetPort(def->target.addr); + VIR_AUTOFREE(char *) addr =3D NULL; if (port < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to format guestfwd port")); return -1; } =20 - char *addr =3D virSocketAddrFormat(def->target.addr); + addr =3D virSocketAddrFormat(def->target.addr); if (addr =3D=3D NULL) return -1; =20 virBufferAsprintf(buf, " address=3D'%s' port=3D'%d'", addr, port); - VIR_FREE(addr); break; } =20 @@ -27147,11 +27144,10 @@ virDomainHugepagesFormatBuf(virBufferPtr buf, hugepage->size); =20 if (hugepage->nodemask) { - char *nodeset =3D NULL; + VIR_AUTOFREE(char *) nodeset =3D NULL; if (!(nodeset =3D virBitmapFormat(hugepage->nodemask))) goto cleanup; virBufferAsprintf(buf, " nodeset=3D'%s'", nodeset); - VIR_FREE(nodeset); } =20 virBufferAddLit(buf, "/>\n"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 17:47:47 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 1551457630291294.8242068349314; Fri, 1 Mar 2019 08:27:10 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 94E3C3088DAE; Fri, 1 Mar 2019 16:27:08 +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 689DA2B4BD; Fri, 1 Mar 2019 16:27:08 +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 25D1C181A12C; Fri, 1 Mar 2019 16:27:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GR0vE012438 for ; Fri, 1 Mar 2019 11:27:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9D95360A9A; Fri, 1 Mar 2019 16:27:00 +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 5BA53608CD for ; Fri, 1 Mar 2019 16:27:00 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Mar 2019 11:26:49 -0500 Message-Id: <20190301162652.32533-8-jferlan@redhat.com> In-Reply-To: <20190301162652.32533-1-jferlan@redhat.com> References: <20190301162652.32533-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 07/10] conf: Use VIR_AUTOUNREF 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 01 Mar 2019 16:27:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Let's make use of the auto __cleanup capabilities for virObjectUnref consumers. Signed-off-by: John Ferlan Reviewed-by: Erik Skultety Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index da2175713d..c04517dbd0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1587,8 +1587,8 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def) static virDomainVcpuDefPtr virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt) { - virObjectPtr priv =3D NULL; virDomainVcpuDefPtr ret =3D NULL; + VIR_AUTOUNREF(virObjectPtr) priv =3D NULL; =20 if (xmlopt && xmlopt->privateData.vcpuNew && !(priv =3D xmlopt->privateData.vcpuNew())) @@ -1600,7 +1600,6 @@ virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt) VIR_STEAL_PTR(ret->privateData, priv); =20 cleanup: - virObjectUnref(priv); return ret; } =20 @@ -19142,13 +19141,13 @@ virDomainCachetuneDefParse(virDomainDefPtr def, unsigned int flags) { xmlNodePtr oldnode =3D ctxt->node; - 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; + VIR_AUTOUNREF(virResctrlAllocPtr) alloc =3D NULL; =20 ctxt->node =3D node; =20 @@ -19207,7 +19206,6 @@ virDomainCachetuneDefParse(virDomainDefPtr def, cleanup: ctxt->node =3D oldnode; virDomainResctrlDefFree(resctrl); - virObjectUnref(alloc); return ret; } =20 @@ -19353,10 +19351,10 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, unsigned int flags) { xmlNodePtr oldnode =3D ctxt->node; - virResctrlAllocPtr alloc =3D NULL; virDomainResctrlDefPtr resctrl =3D NULL; VIR_AUTOPTR(virBitmap) vcpus =3D NULL; VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; + VIR_AUTOUNREF(virResctrlAllocPtr) alloc =3D NULL; =20 ssize_t i =3D 0; int n; @@ -19414,7 +19412,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, cleanup: ctxt->node =3D oldnode; virDomainResctrlDefFree(resctrl); - virObjectUnref(alloc); return ret; } =20 @@ -30460,11 +30457,11 @@ virDomainNetBandwidthUpdate(virDomainNetDefPtr if= ace, int virDomainNetResolveActualType(virDomainNetDefPtr iface) { - virConnectPtr conn =3D NULL; - virNetworkPtr net =3D NULL; virNetworkDefPtr def =3D NULL; int ret =3D -1; VIR_AUTOFREE(char *) xml =3D NULL; + VIR_AUTOUNREF(virConnectPtr) conn =3D NULL; + VIR_AUTOUNREF(virNetworkPtr) net =3D NULL; =20 if (iface->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) return iface->type; @@ -30531,8 +30528,6 @@ virDomainNetResolveActualType(virDomainNetDefPtr if= ace) =20 cleanup: virNetworkDefFree(def); - virObjectUnref(conn); - virObjectUnref(net); return ret; } =20 @@ -30656,13 +30651,13 @@ virDomainDiskTranslateISCSIDirect(virDomainDiskDe= fPtr def, int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def) { - virConnectPtr conn =3D NULL; - virStoragePoolPtr pool =3D NULL; - virStorageVolPtr vol =3D NULL; virStorageVolInfo info; int ret =3D -1; VIR_AUTOPTR(virStoragePoolDef) pooldef =3D NULL; VIR_AUTOFREE(char *) poolxml =3D NULL; + VIR_AUTOUNREF(virConnectPtr) conn =3D NULL; + VIR_AUTOUNREF(virStoragePoolPtr) pool =3D NULL; + VIR_AUTOUNREF(virStorageVolPtr) vol =3D NULL; =20 if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME) return 0; @@ -30817,9 +30812,6 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPt= r def) =20 ret =3D 0; cleanup: - virObjectUnref(conn); - virObjectUnref(pool); - virObjectUnref(vol); 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 Sun Apr 28 17:47:47 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 1551457633256681.4609304110329; Fri, 1 Mar 2019 08:27:13 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57BE1FD3CC; Fri, 1 Mar 2019 16:27:11 +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 297F760A9A; Fri, 1 Mar 2019 16:27: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 D4F6C181A13E; Fri, 1 Mar 2019 16:27:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GR1B0012450 for ; Fri, 1 Mar 2019 11:27:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 43FBE2B4BD; Fri, 1 Mar 2019 16:27:01 +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 C856460A9A; Fri, 1 Mar 2019 16:27:00 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Mar 2019 11:26:50 -0500 Message-Id: <20190301162652.32533-9-jferlan@redhat.com> In-Reply-To: <20190301162652.32533-1-jferlan@redhat.com> References: <20190301162652.32533-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v3 08/10] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 01 Mar 2019 16:27:12 +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 Reviewed-by: J=C3=A1n Tomko --- 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 c04517dbd0..5495276e78 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1107,32 +1107,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) { @@ -1143,7 +1142,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; @@ -1155,7 +1154,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; @@ -1164,10 +1163,7 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDe= fPtr keywrap, break; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int @@ -1270,7 +1266,6 @@ static int virDomainVirtioOptionsParseXML(xmlNodePtr driver, virDomainVirtioOptionsPtr *virtio) { - int ret =3D -1; int val; virDomainVirtioOptionsPtr res; VIR_AUTOFREE(char *) str =3D NULL; @@ -1287,7 +1282,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; } @@ -1297,15 +1292,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 @@ -5331,7 +5323,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) @@ -5346,22 +5337,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 @@ -6881,7 +6869,6 @@ static int virDomainDeviceUSBMasterParseXML(xmlNodePtr node, virDomainDeviceUSBMasterPtr master) { - int ret =3D -1; VIR_AUTOFREE(char *) startport =3D NULL; =20 memset(master, 0, sizeof(*master)); @@ -6892,27 +6879,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 || @@ -6920,7 +6903,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"); @@ -6929,26 +6912,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 @@ -6961,19 +6940,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 @@ -6981,7 +6958,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")) || @@ -6989,7 +6965,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 @@ -6997,14 +6973,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 @@ -7012,57 +6985,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: @@ -7070,17 +7042,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: @@ -7088,9 +7060,7 @@ virDomainDeviceAddressParseXML(xmlNodePtr address, break; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -7532,7 +7502,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; @@ -7548,7 +7517,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")) || @@ -7557,26 +7526,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; @@ -7585,12 +7554,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; @@ -7598,7 +7567,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; @@ -7608,12 +7577,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 @@ -7692,7 +7659,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"))) { @@ -7702,17 +7668,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 @@ -7720,14 +7683,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 @@ -7735,7 +7697,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= ) { @@ -7743,13 +7705,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; @@ -7758,20 +7720,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; @@ -7780,26 +7739,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 @@ -7811,7 +7768,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; @@ -7851,18 +7807,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 && @@ -7870,20 +7826,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 @@ -7891,14 +7847,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 @@ -7907,21 +7863,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 && @@ -7930,14 +7886,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)= ) && @@ -7946,7 +7902,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 @@ -7954,33 +7910,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 @@ -7999,7 +7953,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"); @@ -8011,13 +7965,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"); @@ -8028,7 +7982,7 @@ virDomainNetIPParseXML(xmlNodePtr node) virReportError(VIR_ERR_XML_ERROR, _("Invalid prefix value '%s' in "), prefixStr); - goto cleanup; + return NULL; } ip->prefix =3D prefixValue; =20 @@ -8036,12 +7990,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 @@ -8840,7 +8792,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; @@ -8848,27 +8799,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) && @@ -8877,7 +8828,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, virReportError(VIR_ERR_XML_ERROR, _("Invalid tlsFromConfig value: %s"), tlsCfg); - goto cleanup; + return -1; } src->tlsFromConfig =3D !!tlsCfgVal; } @@ -8893,13 +8844,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'; } @@ -8911,16 +8862,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 @@ -9234,20 +9182,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; @@ -9258,7 +9205,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); @@ -9266,12 +9213,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 @@ -9281,13 +9228,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"); } @@ -9297,7 +9244,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 @@ -9305,13 +9252,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 @@ -9325,7 +9269,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); } @@ -9334,7 +9278,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); } @@ -9343,7 +9287,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); } @@ -9354,14 +9298,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 @@ -9505,7 +9446,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"); @@ -9514,7 +9454,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 @@ -9522,7 +9462,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 @@ -9531,7 +9471,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 @@ -9539,7 +9479,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 @@ -9547,7 +9487,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 @@ -9555,7 +9495,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 @@ -9563,7 +9503,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 @@ -9571,7 +9511,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 @@ -9581,7 +9521,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 @@ -9593,7 +9533,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 @@ -9604,7 +9544,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 @@ -9613,13 +9553,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 @@ -10115,7 +10052,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; @@ -10123,18 +10059,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 @@ -10142,23 +10076,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 @@ -12032,7 +11964,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"); @@ -12047,7 +11978,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; @@ -12065,7 +11996,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) { @@ -12076,37 +12007,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); @@ -12125,7 +12056,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; @@ -12146,16 +12077,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 { @@ -12174,19 +12102,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 @@ -12201,7 +12127,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"); @@ -12212,7 +12138,7 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef= Ptr def, virReportError(VIR_ERR_XML_ERROR, _("unknown chardev 'tls' setting '%s'"), tmp); - goto error; + return -1; } VIR_FREE(tmp); } @@ -12223,7 +12149,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; } @@ -12231,13 +12157,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 @@ -13573,7 +13496,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"); @@ -13581,13 +13503,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) { @@ -13616,7 +13538,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 @@ -13631,7 +13553,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; } @@ -13641,11 +13563,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 @@ -13711,20 +13631,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) @@ -13747,9 +13666,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 @@ -13757,7 +13674,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) { @@ -13768,7 +13684,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; @@ -13776,9 +13692,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 @@ -13790,20 +13704,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; @@ -13813,7 +13726,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; @@ -13829,7 +13742,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; } @@ -13848,7 +13761,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) { @@ -13864,20 +13777,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; @@ -13888,7 +13801,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 @@ -13896,7 +13809,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; @@ -13907,7 +13820,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 @@ -13915,7 +13828,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; @@ -13926,7 +13839,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 @@ -13934,7 +13847,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; @@ -13945,15 +13858,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; @@ -13964,14 +13876,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; @@ -13982,14 +13893,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; @@ -14000,14 +13911,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; @@ -14019,14 +13930,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; @@ -14039,14 +13950,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; @@ -14055,9 +13966,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, cur =3D cur->next; } =20 - ret =3D 0; - error: - return ret; + return 0; } =20 =20 @@ -15585,7 +15494,6 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, const char *xpath, int *val) { - int ret =3D -1; VIR_AUTOFREE(char *) tmp =3D virXPathString(xpath, ctxt); =20 if (tmp) { @@ -15593,13 +15501,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 @@ -15608,44 +15514,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 @@ -15653,7 +15555,6 @@ virDomainPerfDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt) { size_t i; - int ret =3D -1; int n; VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; =20 @@ -15662,13 +15563,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 @@ -17674,13 +17572,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; @@ -17688,14 +17585,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; @@ -17723,7 +17620,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; } @@ -17749,16 +17646,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 @@ -17879,41 +17773,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 @@ -17928,52 +17816,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 @@ -17985,7 +17868,6 @@ static int virDomainIOThreadPinDefParseXML(xmlNodePtr node, virDomainDefPtr def) { - int ret =3D -1; virDomainIOThreadIDDefPtr iothrid; unsigned int iothreadid; VIR_AUTOFREE(char *) tmp =3D NULL; @@ -17994,57 +17876,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 @@ -18066,17 +17945,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 @@ -18315,7 +18192,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; @@ -18329,14 +18205,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) { @@ -18344,14 +18220,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 @@ -18503,7 +18377,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 @@ -18514,7 +18387,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); } @@ -18523,7 +18396,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 { @@ -18537,7 +18410,7 @@ virDomainVcpuParse(virDomainDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported CPU placement mode '%s'"), tmp); - goto cleanup; + return -1; } VIR_FREE(tmp); } else { @@ -18548,12 +18421,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); @@ -18562,10 +18435,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 */ @@ -18581,7 +18454,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); @@ -18590,7 +18463,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); @@ -18598,13 +18471,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 @@ -18615,7 +18488,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); @@ -18625,7 +18498,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); @@ -18633,13 +18506,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 @@ -18648,7 +18518,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; @@ -18671,34 +18540,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 || @@ -18706,16 +18575,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); @@ -18734,10 +18603,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); @@ -18746,12 +18615,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) { @@ -18760,30 +18629,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 @@ -18792,29 +18657,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 @@ -19216,7 +19078,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; @@ -19234,12 +19095,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) { @@ -19248,13 +19109,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 @@ -19271,7 +19132,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, @@ -19279,19 +19140,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 @@ -26155,7 +26014,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) @@ -26168,7 +26026,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); } @@ -26197,10 +26055,7 @@ virDomainMemorySourceDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -27619,7 +27474,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)) @@ -27656,10 +27510,7 @@ virDomainCpuDefFormat(virBufferPtr buf, virBufferAddLit(buf, "\n"); } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -28863,29 +28714,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 @@ -28893,18 +28740,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 @@ -28919,18 +28760,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 @@ -28939,15 +28774,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); @@ -28958,13 +28792,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 @@ -29226,20 +29057,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 @@ -29248,16 +29078,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 @@ -29272,7 +29099,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; @@ -29285,9 +29111,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 @@ -29711,7 +29535,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; @@ -29791,19 +29614,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 @@ -30176,11 +29996,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 From nobody Sun Apr 28 17:47:47 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 1551457637039356.89595543843996; Fri, 1 Mar 2019 08:27:17 -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 3A005C085EC7; Fri, 1 Mar 2019 16:27:15 +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 041861001DF6; Fri, 1 Mar 2019 16:27:15 +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 B5D55181A265; Fri, 1 Mar 2019 16:27:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GR1ig012455 for ; Fri, 1 Mar 2019 11:27:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id AE336608CD; Fri, 1 Mar 2019 16:27:01 +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 6C672611B6 for ; Fri, 1 Mar 2019 16:27:01 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Mar 2019 11:26:51 -0500 Message-Id: <20190301162652.32533-10-jferlan@redhat.com> In-Reply-To: <20190301162652.32533-1-jferlan@redhat.com> References: <20190301162652.32533-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 09/10] conf: Merge with previous 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.32]); Fri, 01 Mar 2019 16:27:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" More path cleanup from code review from methods that I didn't touch as part of the original set of changes, but Erik called out. Plus now with the VIR_AUTOUNREF added that meant a couple more modules could be altered to clean up their return paths. I will merge with previous once ACK'd Signed-off-by: John Ferlan Reviewed-by: Erik Skultety Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 77 +++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 46 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5495276e78..be6e223e78 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1584,14 +1584,13 @@ virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt) =20 if (xmlopt && xmlopt->privateData.vcpuNew && !(priv =3D xmlopt->privateData.vcpuNew())) - goto cleanup; + return NULL; =20 if (VIR_ALLOC(ret) < 0) - goto cleanup; + return NULL; =20 VIR_STEAL_PTR(ret->privateData, priv); =20 - cleanup: return ret; } =20 @@ -26990,23 +26989,19 @@ static int virDomainHugepagesFormatBuf(virBufferPtr buf, virDomainHugePagePtr hugepage) { - int ret =3D -1; - virBufferAsprintf(buf, "size); =20 if (hugepage->nodemask) { VIR_AUTOFREE(char *) nodeset =3D NULL; if (!(nodeset =3D virBitmapFormat(hugepage->nodemask))) - goto cleanup; + return -1; virBufferAsprintf(buf, " nodeset=3D'%s'", nodeset); } =20 virBufferAddLit(buf, "/>\n"); =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static void @@ -29726,21 +29721,21 @@ virDomainObjGetMetadata(virDomainObjPtr vm, if (type >=3D VIR_DOMAIN_METADATA_LAST) { virReportError(VIR_ERR_INVALID_ARG, _("unknown metadata type '%d'"), type); - goto cleanup; + return NULL; } =20 if (!(def =3D virDomainObjGetOneDef(vm, flags))) - goto cleanup; + return NULL; =20 switch ((virDomainMetadataType) type) { case VIR_DOMAIN_METADATA_DESCRIPTION: if (VIR_STRDUP(ret, def->description) < 0) - goto cleanup; + return NULL; break; =20 case VIR_DOMAIN_METADATA_TITLE: if (VIR_STRDUP(ret, def->title) < 0) - goto cleanup; + return NULL; break; =20 case VIR_DOMAIN_METADATA_ELEMENT: @@ -29748,7 +29743,7 @@ virDomainObjGetMetadata(virDomainObjPtr vm, break; =20 if (virXMLExtractNamespaceXML(def->metadata, uri, &ret) < 0) - goto cleanup; + return NULL; break; =20 /* coverity[dead_error_begin] */ @@ -29760,7 +29755,6 @@ virDomainObjGetMetadata(virDomainObjPtr vm, virReportError(VIR_ERR_NO_DOMAIN_METADATA, "%s", _("Requested metadata element is not present")); =20 - cleanup: return ret; } =20 @@ -30414,22 +30408,16 @@ static int virDomainDiskTranslateSourcePoolAuth(virDomainDiskDefPtr def, virStoragePoolSourcePtr source) { - int ret =3D -1; - /* Only necessary when authentication set */ - if (!source->auth) { - ret =3D 0; - goto cleanup; - } + if (!source->auth) + return 0; + def->src->auth =3D virStorageAuthDefCopy(source->auth); if (!def->src->auth) - goto cleanup; + return -1; /* A doesn't use src->auth->authType =3D VIR_STORAGE_AUTH_TYPE_NONE; - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -30471,7 +30459,6 @@ int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def) { virStorageVolInfo info; - int ret =3D -1; VIR_AUTOPTR(virStoragePoolDef) pooldef =3D NULL; VIR_AUTOFREE(char *) poolxml =3D NULL; VIR_AUTOUNREF(virConnectPtr) conn =3D NULL; @@ -30488,27 +30475,27 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef= Ptr def) return -1; =20 if (!(pool =3D virStoragePoolLookupByName(conn, def->src->srcpool->poo= l))) - goto cleanup; + return -1; =20 if (virStoragePoolIsActive(pool) !=3D 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("storage pool '%s' containing volume '%s' " "is not active"), def->src->srcpool->pool, def->src->srcpool->volume); - goto cleanup; + return -1; } =20 if (!(vol =3D virStorageVolLookupByName(pool, def->src->srcpool->volum= e))) - goto cleanup; + return -1; =20 if (virStorageVolGetInfo(vol, &info) < 0) - goto cleanup; + return -1; =20 if (!(poolxml =3D virStoragePoolGetXMLDesc(pool, 0))) - goto cleanup; + return -1; =20 if (!(pooldef =3D virStoragePoolDefParseString(poolxml))) - goto cleanup; + return -1; =20 def->src->srcpool->pooltype =3D pooldef->type; def->src->srcpool->voltype =3D info.type; @@ -30517,7 +30504,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPt= r def) virReportError(VIR_ERR_XML_ERROR, "%s", _("disk source mode is only valid when " "storage pool is of iscsi type")); - goto cleanup; + return -1; } =20 VIR_FREE(def->src->path); @@ -30537,13 +30524,13 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef= Ptr def) case VIR_STORAGE_POOL_ZFS: case VIR_STORAGE_POOL_VSTORAGE: if (!(def->src->path =3D virStorageVolGetPath(vol))) - goto cleanup; + return -1; =20 if (def->startupPolicy && info.type !=3D VIR_STORAGE_VOL_FILE) { virReportError(VIR_ERR_XML_ERROR, "%s", _("'startupPolicy' is only valid for " "'file' type volume")); - goto cleanup; + return -1; } =20 =20 @@ -30571,7 +30558,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPt= r def) "for storage pool type '%s'"), virStorageVolTypeToString(info.type), virStoragePoolTypeToString(pooldef->type)); - goto cleanup; + return -1; } =20 break; @@ -30581,13 +30568,13 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef= Ptr def) virReportError(VIR_ERR_XML_ERROR, "%s", _("'startupPolicy' is only valid for " "'file' type volume")); - goto cleanup; + return -1; } =20 def->src->srcpool->mode =3D VIR_STORAGE_SOURCE_POOL_MODE_DIRECT; =20 if (virDomainDiskTranslateISCSIDirect(def, pooldef) < 0) - goto cleanup; + return -1; =20 break; =20 @@ -30596,7 +30583,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPt= r def) virReportError(VIR_ERR_XML_ERROR, "%s", _("'startupPolicy' is only valid for " "'file' type volume")); - goto cleanup; + return -1; } =20 switch (def->src->srcpool->mode) { @@ -30607,12 +30594,12 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef= Ptr def) case VIR_STORAGE_SOURCE_POOL_MODE_HOST: def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; if (!(def->src->path =3D virStorageVolGetPath(vol))) - goto cleanup; + return -1; break; =20 case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT: if (virDomainDiskTranslateISCSIDirect(def, pooldef) < 0) - goto cleanup; + return -1; break; } break; @@ -30626,12 +30613,10 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef= Ptr def) _("using '%s' pools for backing 'volume' disks " "isn't yet supported"), virStoragePoolTypeToString(pooldef->type)); - goto cleanup; + return -1; } =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 Sun Apr 28 17:47:47 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 1551457635062129.03514354331685; Fri, 1 Mar 2019 08:27:15 -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 252443088D31; Fri, 1 Mar 2019 16:27:13 +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 F31311001E62; Fri, 1 Mar 2019 16:27:12 +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 B798A3FAF5; Fri, 1 Mar 2019 16:27:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GR23K012460 for ; Fri, 1 Mar 2019 11:27:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3AE1B611BC; Fri, 1 Mar 2019 16:27:02 +0000 (UTC) Received: from libvirt-fedora-29.redhat.com (ovpn-117-20.phx2.redhat.com [10.3.117.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id D735B608CD; Fri, 1 Mar 2019 16:27:01 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Mar 2019 11:26:52 -0500 Message-Id: <20190301162652.32533-11-jferlan@redhat.com> In-Reply-To: <20190301162652.32533-1-jferlan@redhat.com> References: <20190301162652.32533-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v3 10/10] conf: Rework virDomainKeyWrapDefParseXML 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.47]); Fri, 01 Mar 2019 16:27:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rewrite the code to make usage of some VIR_AUTOFREE logic. Suggested-by: Erik Skultety Signed-off-by: John Ferlan Reviewed-by: Erik Skultety Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index be6e223e78..05c2c9f34e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1170,31 +1170,25 @@ static int virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt) { size_t i; - int ret =3D -1; int n; VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; + VIR_AUTOFREE(virDomainKeyWrapDefPtr) keywrap =3D NULL; =20 if ((n =3D virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0) return n; =20 - if (VIR_ALLOC(def->keywrap) < 0) - goto cleanup; + if (VIR_ALLOC(keywrap) < 0) + return -1; =20 for (i =3D 0; i < n; i++) { - if (virDomainKeyWrapCipherDefParseXML(def->keywrap, nodes[i]) < 0) - goto cleanup; + if (virDomainKeyWrapCipherDefParseXML(keywrap, nodes[i]) < 0) + return -1; } =20 - if (!def->keywrap->aes && - !def->keywrap->dea) - VIR_FREE(def->keywrap); + if (keywrap->aes || keywrap->dea) + VIR_STEAL_PTR(def->keywrap, keywrap); =20 - ret =3D 0; - - cleanup: - if (ret < 0) - VIR_FREE(def->keywrap); - 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