From nobody Sun Feb 8 20:58:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570111708; cv=none; d=zoho.com; s=zohoarc; b=dYdFCBMxUe1No1dTCgCoquPbN+qJ9HEXwob34/8hidRGGnzhwFoObPB1EmgbYa18Sdl1bE0UEdotzCZakVhnxWia7m0P9lvzqR9NgB3FYnPh+Bf4Gyoan8Ynd4PBjy0APeg/sg1BkGXlbbqX0ZNSAFtplBJzKeujqn69io9i8FQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570111708; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=fhHRM6vdvJMWtunTJCYFpU5KcwWEM0SQjDt2uceaQvA=; b=UHEE4JB/8k54H5Nl+mZqvR49bNGBQytXsZX1vVgPmwcYyk8H+Fo6a8EyCdjkaC5SGV2O2mPIGMUaRhwoyjeWs00FEdqHxVvcBhwzVrHvsRrDM8FwZIWT0RywcoNGcurBSM9p5AptLxlwCmuf1uLuMy5UmIPimAsCTdzFIdbWkMY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15701117082741016.9461863653355; Thu, 3 Oct 2019 07:08:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5588A302C072; Thu, 3 Oct 2019 14:08:26 +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 2AAED5C22C; Thu, 3 Oct 2019 14:08:26 +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 D20D26B4B1; Thu, 3 Oct 2019 14:08:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x93E5nah021049 for ; Thu, 3 Oct 2019 10:05:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3607D6012C; Thu, 3 Oct 2019 14:05:49 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0BA156013A for ; Thu, 3 Oct 2019 14:05:49 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 6C6381005DE; Thu, 3 Oct 2019 16:05:43 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 3 Oct 2019 16:00:29 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/22] qemu: Use VIR_AUTOFREE in virQEMUCapsLoadCPUModels 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 03 Oct 2019 14:08:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 58 +++++++++++++++--------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 74920901b3..52a2594bf3 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3423,15 +3423,10 @@ virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps, virDomainVirtType type) { virDomainCapsCPUModelsPtr cpus =3D NULL; - xmlNodePtr *nodes =3D NULL; - char *str =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; size_t i; int n; - int ret =3D -1; xmlNodePtr node; - xmlNodePtr *blockerNodes =3D NULL; - char **blockers =3D NULL; - int nblockers; =20 if (type =3D=3D VIR_DOMAIN_VIRT_KVM) n =3D virXPathNodeSet("./cpu[@type=3D'kvm']", ctxt, &nodes); @@ -3441,16 +3436,14 @@ virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps, if (n < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse qemu capabilities cpus")); - goto cleanup; + return -1; } =20 - if (n =3D=3D 0) { - ret =3D 0; - goto cleanup; - } + if (n =3D=3D 0) + return 0; =20 if (!(cpus =3D virDomainCapsCPUModelsNew(n))) - goto cleanup; + return -1; =20 if (type =3D=3D VIR_DOMAIN_VIRT_KVM) qemuCaps->kvmCPUModels =3D cpus; @@ -3459,19 +3452,24 @@ virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps, =20 for (i =3D 0; i < n; i++) { int usable =3D VIR_DOMCAPS_CPU_USABLE_UNKNOWN; - - if ((str =3D virXMLPropString(nodes[i], "usable")) && - (usable =3D virDomainCapsCPUUsableTypeFromString(str)) < 0) { + VIR_AUTOFREE(char *) strUsable =3D NULL; + VIR_AUTOFREE(char *) name =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) blockerNodes =3D NULL; + VIR_AUTOSTRINGLIST blockers =3D NULL; + int nblockers; + + if ((strUsable =3D virXMLPropString(nodes[i], "usable")) && + (usable =3D virDomainCapsCPUUsableTypeFromString(strUsable)) <= 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown value '%s' in attribute 'usable'"), = str); - goto cleanup; + _("unknown value '%s' in attribute 'usable'"), + strUsable); + return -1; } - VIR_FREE(str); =20 - if (!(str =3D virXMLPropString(nodes[i], "name"))) { + if (!(name =3D virXMLPropString(nodes[i], "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing cpu name in QEMU capabilities cache"= )); - goto cleanup; + return -1; } =20 node =3D ctxt->node; @@ -3482,38 +3480,30 @@ virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps, if (nblockers < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse CPU blockers in QEMU capabil= ities")); - goto cleanup; + return -1; } =20 if (nblockers > 0) { size_t j; =20 if (VIR_ALLOC_N(blockers, nblockers + 1) < 0) - goto cleanup; + return -1; =20 for (j =3D 0; j < nblockers; j++) { if (!(blockers[j] =3D virXMLPropString(blockerNodes[j], "n= ame"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing blocker name in QEMU " "capabilities cache")); - goto cleanup; + return -1; } } - VIR_FREE(blockerNodes); } =20 - if (virDomainCapsCPUModelsAddSteal(cpus, &str, usable, &blockers) = < 0) - goto cleanup; + if (virDomainCapsCPUModelsAddSteal(cpus, &name, usable, &blockers)= < 0) + return -1; } =20 - ret =3D 0; - - cleanup: - VIR_FREE(nodes); - VIR_FREE(str); - VIR_FREE(blockerNodes); - virStringListFree(blockers); - return ret; + return 0; } =20 =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list