From nobody Sun Feb 8 12:31:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 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=1585316729; cv=none; d=zohomail.com; s=zohoarc; b=OE+GpvClExLmSM7tNa5Wf2/HRyYuiuGl+U8PDVS5pciTboW3LiOQ/oAzki+KjPrmnhJchrclSqOy3/z13CU5VsdTFDVI3ccG4kz+m5hX2v2MF8wUrOn7EovoaszHsBafnv9cuOQPXNRw7FVvKLzfCQO+z5kT1FgSQhZ77mnBphQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585316729; 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=YkGExBvJfQ5qhuc8WQ/OYdoglp4KPVXNqd1UZ24P5tI=; b=cHp6B9IkKzN0f6M7p19vUVCOMDn5KYbVP459HAAsy+SUQyX2orw1E5Rpgvm6w0lyUTb4Veeu34LSGIP4ZgnH+SkZ6fGYY0kmb0ykK5fzT7PFHHUF9y85oMYN9KqRQQ+puVUriOu8yjAiP6gsyCOmoWWxt2zPKm1IcpgTiBtpcWA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585316729365308.99380449446664; Fri, 27 Mar 2020 06:45:29 -0700 (PDT) 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-136-UfuPtLwiMf-RL3Ik5HE9yA-1; Fri, 27 Mar 2020 09:45:25 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3055C1088386; Fri, 27 Mar 2020 13:45: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 ED2CE5C28D; Fri, 27 Mar 2020 13:45:18 +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 8048D180338F; Fri, 27 Mar 2020 13:45:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02RDiNcS006395 for ; Fri, 27 Mar 2020 09:44:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id E619E3A0; Fri, 27 Mar 2020 13:44:23 +0000 (UTC) Received: from rein.int.mamuti.net (unknown [10.40.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F3B919925 for ; Fri, 27 Mar 2020 13:44:23 +0000 (UTC) Received: by rein.int.mamuti.net (Postfix, from userid 500) id 0AD7418D5B1; Fri, 27 Mar 2020 14:44:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585316728; 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=YkGExBvJfQ5qhuc8WQ/OYdoglp4KPVXNqd1UZ24P5tI=; b=CpAzOeuiFXkrk2c0Ja+C3w/6eEdRpG0DrIiUVQPpz+veauT5yUCn8eNx840XtC9d4jv8Cg gYPhfXNdyMEhZ+fsisYaSgOPVYUPKeMA34vE4KntZaGrpjuzZgmjNKsDVaAGG7wHQU5suB Nz7o8iXtpe++edwX0qoFVuYgUVsOMtI= X-MC-Unique: UfuPtLwiMf-RL3Ik5HE9yA-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 22/39] cpu_x86: Use g_auto* in virCPUx86Baseline Date: Fri, 27 Mar 2020 14:43:51 +0100 Message-Id: <91d382cfe9d70533dadfab404fb971689688849e.1585316580.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 --- src/cpu/cpu_x86.c | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 7bd19a1676..ccbae3dabd 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2701,21 +2701,20 @@ virCPUx86Baseline(virCPUDefPtr *cpus, bool migratable) { virCPUx86MapPtr map =3D NULL; - virCPUx86ModelPtr base_model =3D NULL; - virCPUDefPtr cpu =3D NULL; + g_autoptr(virCPUx86Model) base_model =3D NULL; + g_autoptr(virCPUDef) cpu =3D NULL; size_t i; virCPUx86VendorPtr vendor =3D NULL; - virCPUx86ModelPtr model =3D NULL; bool outputVendor =3D true; const char *modelName; bool matchingNames =3D true; - virCPUDataPtr featData =3D NULL; + g_autoptr(virCPUData) featData =3D NULL; =20 if (!(map =3D virCPUx86GetMap())) - goto error; + return NULL; =20 if (!(base_model =3D x86ModelFromCPU(cpus[0], map, -1))) - goto error; + return NULL; =20 cpu =3D virCPUDefNew(); =20 @@ -2727,11 +2726,12 @@ virCPUx86Baseline(virCPUDefPtr *cpus, } else if (!(vendor =3D x86VendorFind(map, cpus[0]->vendor))) { virReportError(VIR_ERR_OPERATION_FAILED, _("Unknown CPU vendor %s"), cpus[0]->vendor); - goto error; + return NULL; } =20 modelName =3D cpus[0]->model; for (i =3D 1; i < ncpus; i++) { + g_autoptr(virCPUx86Model) model =3D NULL; const char *vn =3D NULL; =20 if (matchingNames && cpus[i]->model) { @@ -2744,14 +2744,14 @@ virCPUx86Baseline(virCPUDefPtr *cpus, } =20 if (!(model =3D x86ModelFromCPU(cpus[i], map, -1))) - goto error; + return NULL; =20 if (cpus[i]->vendor && model->vendor && STRNEQ(cpus[i]->vendor, model->vendor->name)) { virReportError(VIR_ERR_OPERATION_FAILED, _("CPU vendor %s of model %s differs from vendo= r %s"), model->vendor->name, model->name, cpus[i]->vend= or); - goto error; + return NULL; } =20 if (cpus[i]->vendor) { @@ -2767,30 +2767,28 @@ virCPUx86Baseline(virCPUDefPtr *cpus, if (!(vendor =3D x86VendorFind(map, vn))) { virReportError(VIR_ERR_OPERATION_FAILED, _("Unknown CPU vendor %s"), vn); - goto error; + return NULL; } } else if (STRNEQ(vendor->name, vn)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("CPU vendors do not match")); - goto error; + return NULL; } } =20 x86DataIntersect(&base_model->data, &model->data); - x86ModelFree(model); - model =3D NULL; } =20 if (features) { virCPUx86FeaturePtr feat; =20 if (!(featData =3D virCPUDataNew(archs[0]))) - goto cleanup; + return NULL; =20 for (i =3D 0; features[i]; i++) { if ((feat =3D x86FeatureFind(map, features[i])) && x86DataAdd(&featData->data.x86, &feat->data) < 0) - goto cleanup; + return NULL; } =20 x86DataIntersect(&base_model->data, &featData->data.x86); @@ -2799,15 +2797,15 @@ virCPUx86Baseline(virCPUDefPtr *cpus, if (x86DataIsEmpty(&base_model->data)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("CPUs are incompatible")); - goto error; + return NULL; } =20 if (vendor && virCPUx86DataAddItem(&base_model->data, &vendor->data) < 0) - goto error; + return NULL; =20 if (x86Decode(cpu, &base_model->data, models, modelName, migratable) <= 0) - goto error; + return NULL; =20 if (STREQ_NULLABLE(cpu->model, modelName)) cpu->fallback =3D VIR_CPU_FALLBACK_FORBID; @@ -2815,17 +2813,7 @@ virCPUx86Baseline(virCPUDefPtr *cpus, if (!outputVendor) VIR_FREE(cpu->vendor); =20 - cleanup: - x86ModelFree(base_model); - virCPUx86DataFree(featData); - - return cpu; - - error: - x86ModelFree(model); - virCPUDefFree(cpu); - cpu =3D NULL; - goto cleanup; + return g_steal_pointer(&cpu); } =20 =20 --=20 2.26.0