From nobody Sun Feb 8 12:31:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1585316687; cv=none; d=zohomail.com; s=zohoarc; b=CfYFziXrnzBpULdTgnSGC6BgOjI19ArD3zFNJuW+glzWJ37GfZGOIsx0VmyZWKw3I4lNR1yf9Vf/v5Be8AM0Ukf/J1E+7UFdTE5qj0OcX8TIMXBUHJluOK9oa8tuox1T45ubeDisfsVNKejs3cBeUftlkZuAaOgDqoqrQIxUvgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585316687; 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=g9xE7GUnUYdrz+tpK3lcdC2q5v4WzTUvO2+4G5W1G1Y=; b=W42flCyGdOah841foTpHeeR/PKyojYmcHl8NXYx6X/LD2GNsSq+c/oAhQqdFlvcAOB/qE9WEDqYxAWDJudmSQTT1vw+D/t9rJdH13QkyftPcaP07cU0Bdx375mLOFfAfV9BzsbrP2ncU5HJPdYXGTZIi1zbcfxWzdrP9ZDAl/Ug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.74]) by mx.zohomail.com with SMTPS id 15853166878571014.2445283735942; Fri, 27 Mar 2020 06:44:47 -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-401-KyRP-jk6MbuDC2J_KAC17A-1; Fri, 27 Mar 2020 09:44:41 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8DF61005514; Fri, 27 Mar 2020 13:44:35 +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 A7F7119757; Fri, 27 Mar 2020 13:44:35 +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 608278A056; Fri, 27 Mar 2020 13:44:35 +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 02RDiMxm006320 for ; Fri, 27 Mar 2020 09:44:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55A9F19925; Fri, 27 Mar 2020 13:44:22 +0000 (UTC) Received: from rein.int.mamuti.net (unknown [10.40.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1F1D19756 for ; Fri, 27 Mar 2020 13:44:21 +0000 (UTC) Received: by rein.int.mamuti.net (Postfix, from userid 500) id EA19118D5AA; Fri, 27 Mar 2020 14:44:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585316683; 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=g9xE7GUnUYdrz+tpK3lcdC2q5v4WzTUvO2+4G5W1G1Y=; b=PfWOm8l3FMknqPLvG88c59rD581lAS4A0I8R8SRPGshhePTAFMG+QC+rLIqrJ3ZEsM84ba 3bSipgRN/5oMq61f2wYqHFljlqDJyk5p1wkvIB3fC1OTCBbPxZ6PcyXR561h7dYa7VBPb1 1WjXKHw1f1Ur8F32st1EyN3dWl0+Z/I= X-MC-Unique: KyRP-jk6MbuDC2J_KAC17A-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 15/39] cpu_x86: Use g_auto* in x86Compute Date: Fri, 27 Mar 2020 14:43:44 +0100 Message-Id: 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.84 on 10.5.11.23 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 | 64 ++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 40 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 6c3f9fc0be..6758fcc170 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1689,13 +1689,12 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) char *flagsStr =3D NULL; \ if (!(flagsStr =3D x86FeatureNames(map, ", ", (CPU_DEF)))) { \ virReportOOMError(); \ - goto error; \ + return VIR_CPU_COMPARE_ERROR; \ } \ if (message) \ *message =3D g_strdup_printf("%s: %s", _(MSG), flagsStr); \ VIR_DEBUG("%s: %s", MSG, flagsStr); \ VIR_FREE(flagsStr); \ - ret =3D VIR_CPU_COMPARE_INCOMPATIBLE; \ } while (0) =20 =20 @@ -1706,15 +1705,15 @@ x86Compute(virCPUDefPtr host, char **message) { virCPUx86MapPtr map =3D NULL; - virCPUx86ModelPtr host_model =3D NULL; - virCPUx86ModelPtr cpu_force =3D NULL; - virCPUx86ModelPtr cpu_require =3D NULL; - virCPUx86ModelPtr cpu_optional =3D NULL; - virCPUx86ModelPtr cpu_disable =3D NULL; - virCPUx86ModelPtr cpu_forbid =3D NULL; - virCPUx86ModelPtr diff =3D NULL; - virCPUx86ModelPtr guest_model =3D NULL; - virCPUDataPtr guestData =3D NULL; + g_autoptr(virCPUx86Model) host_model =3D NULL; + g_autoptr(virCPUx86Model) cpu_force =3D NULL; + g_autoptr(virCPUx86Model) cpu_require =3D NULL; + g_autoptr(virCPUx86Model) cpu_optional =3D NULL; + g_autoptr(virCPUx86Model) cpu_disable =3D NULL; + g_autoptr(virCPUx86Model) cpu_forbid =3D NULL; + g_autoptr(virCPUx86Model) diff =3D NULL; + g_autoptr(virCPUx86Model) guest_model =3D NULL; + g_autoptr(virCPUData) guestData =3D NULL; virCPUCompareResult ret; virCPUx86CompareResult result; virArch arch; @@ -1764,13 +1763,13 @@ x86Compute(virCPUDefPtr host, !(cpu_optional =3D x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_OPTIO= NAL)) || !(cpu_disable =3D x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_DISABL= E)) || !(cpu_forbid =3D x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_FORBID)= )) - goto error; + return VIR_CPU_COMPARE_ERROR; =20 x86DataIntersect(&cpu_forbid->data, &host_model->data); if (!x86DataIsEmpty(&cpu_forbid->data)) { virX86CpuIncompatible(N_("Host CPU provides forbidden features"), &cpu_forbid->data); - goto cleanup; + return VIR_CPU_COMPARE_INCOMPATIBLE; } =20 /* first remove features that were inherited from the CPU model and we= re @@ -1785,20 +1784,20 @@ x86Compute(virCPUDefPtr host, virX86CpuIncompatible(N_("Host CPU does not provide required " "features"), &cpu_require->data); - goto cleanup; + return VIR_CPU_COMPARE_INCOMPATIBLE; } =20 - ret =3D VIR_CPU_COMPARE_IDENTICAL; - if (!(diff =3D x86ModelCopy(host_model))) - goto error; + return VIR_CPU_COMPARE_ERROR; =20 x86DataSubtract(&diff->data, &cpu_optional->data); x86DataSubtract(&diff->data, &cpu_require->data); x86DataSubtract(&diff->data, &cpu_disable->data); x86DataSubtract(&diff->data, &cpu_force->data); =20 - if (!x86DataIsEmpty(&diff->data)) + if (x86DataIsEmpty(&diff->data)) + ret =3D VIR_CPU_COMPARE_IDENTICAL; + else ret =3D VIR_CPU_COMPARE_SUPERSET; =20 if (ret =3D=3D VIR_CPU_COMPARE_SUPERSET @@ -1807,54 +1806,39 @@ x86Compute(virCPUDefPtr host, virX86CpuIncompatible(N_("Host CPU does not strictly match guest C= PU: " "Extra features"), &diff->data); - goto cleanup; + return VIR_CPU_COMPARE_INCOMPATIBLE; } =20 if (guest) { if (!(guest_model =3D x86ModelCopy(host_model))) - goto error; + return VIR_CPU_COMPARE_ERROR; =20 if (cpu->vendor && host_model->vendor && virCPUx86DataAddItem(&guest_model->data, &host_model->vendor->data) < 0) - goto error; + return VIR_CPU_COMPARE_ERROR; =20 if (host_model->signatures && x86DataAddSignature(&guest_model->data, *host_model->signature= s) < 0) - goto error; + return VIR_CPU_COMPARE_ERROR; =20 if (cpu->type =3D=3D VIR_CPU_TYPE_GUEST && cpu->match =3D=3D VIR_CPU_MATCH_EXACT) x86DataSubtract(&guest_model->data, &diff->data); =20 if (x86DataAdd(&guest_model->data, &cpu_force->data)) - goto error; + return VIR_CPU_COMPARE_ERROR; =20 x86DataSubtract(&guest_model->data, &cpu_disable->data); =20 if (!(guestData =3D virCPUDataNew(arch))) - goto error; + return VIR_CPU_COMPARE_ERROR; x86DataCopy(&guestData->data.x86, &guest_model->data); =20 - *guest =3D guestData; + *guest =3D g_steal_pointer(&guestData); } =20 - cleanup: - x86ModelFree(host_model); - x86ModelFree(diff); - x86ModelFree(cpu_force); - x86ModelFree(cpu_require); - x86ModelFree(cpu_optional); - x86ModelFree(cpu_disable); - x86ModelFree(cpu_forbid); - x86ModelFree(guest_model); - return ret; - - error: - virCPUx86DataFree(guestData); - ret =3D VIR_CPU_COMPARE_ERROR; - goto cleanup; } #undef virX86CpuIncompatible =20 --=20 2.26.0