From nobody Sun Feb 8 13:28:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1572960507; cv=none; d=zoho.com; s=zohoarc; b=Wx3YjnOv4G48Xzc6M3ViN7ysW0OF6WYHj3LyeumLry1A/DX+7Dc+RpedHelmP24HF/EPP/IpIg3vEBq7lkBxtGfYuaVEquwQQMDx8LAsNxwpcpS3TLJZCSMDS4ciQqHPS/p48VxupZ1VTwKv2p07HpcPY7O0c1Yj3kal9bWYbhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572960507; 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; bh=4I0sJG6LaK90R5PovKrcvnxP9Pgu6QRhgrLsoH6fobY=; b=JhAK5EaGfd86zhQ/rfhy5+oFWSzbW1HLWD6tp8JmjdU43hTVFglS7hd5t7kLFSlH/frZPptntm2UwUNfdyJLSbbBfdIWvzRTHNXfU34PfiKNrMZGnkZOnK8anvFIh81pbdX/F30AuOXQ9tE1UF29KiIby9rvHxzDXvpCMpB3Y08= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1572960507766452.71999542171307; Tue, 5 Nov 2019 05:28:27 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-352-O5xhf77POtWrXV8ZqNXTMQ-1; Tue, 05 Nov 2019 08:28:24 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73F53180496F; Tue, 5 Nov 2019 13:28:19 +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 47C9D600D5; Tue, 5 Nov 2019 13:28:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F256F1803C40; Tue, 5 Nov 2019 13:28:18 +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 xA5DRw70003902 for ; Tue, 5 Nov 2019 08:27:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 21E71600C6; Tue, 5 Nov 2019 13:27:58 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB559600C4 for ; Tue, 5 Nov 2019 13:27:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 893C5105B2A; Tue, 5 Nov 2019 14:27:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572960506; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4I0sJG6LaK90R5PovKrcvnxP9Pgu6QRhgrLsoH6fobY=; b=CAxLw7f/PevKRqWyDPYnsLFIgoh4jkT4hn1ubDdAOQ+CHfYv1w9BNRiFjMh3d/YKNacM41 m1d73glbY61pihZGxmGNdjr8ZI2SpQgL4VQZxgp1ZPKlNg00vw5+78u1sWG0s1SzAClqSl p3W4+ZQA3W5HFZWOWNS1qv/pAWq4pTg= From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Nov 2019 14:27:11 +0100 Message-Id: <03b523c95f28e1480f19aeceff9296e99323c28a.1572958254.git.jdenemar@redhat.com> 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 v3 13/52] qemu: Use g_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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: O5xhf77POtWrXV8ZqNXTMQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 2: - no change =20 Version 3: - g_autofree 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 af51a701b1..5136fe9202 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3461,15 +3461,10 @@ virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps, virDomainVirtType type) { virDomainCapsCPUModelsPtr cpus =3D NULL; - xmlNodePtr *nodes =3D NULL; - char *str =3D NULL; + g_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); @@ -3479,16 +3474,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; @@ -3497,19 +3490,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) { + g_autofree char * strUsable =3D NULL; + g_autofree char * name =3D NULL; + g_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; @@ -3520,38 +3518,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