From nobody Sun Feb 8 15:53:34 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=1585316689; cv=none; d=zohomail.com; s=zohoarc; b=easi5e8dva9gU3CSmJEeJKwdIT+cDf6gBCgvHhStSxj1S18iLzwgE07qjlue2bIQ8YLWxuTet9aUJeEURr8rR6su7Tps7KdDTaxO302wBQww+K3HCyRyf4FwZ07C/OgapNgUlsZFS29rs/Avsov5iqRiIr58cW7YJbbXs+d0nmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585316689; 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=ayWFIXYdjUOqSNClM2t8msdJdPR8CPdQdcZ/XY8TEjg=; b=cx/GSkaQJDxb5mqMMsuTTwxpdrv40DpLSAzkEqSB4vYe1C+juINz22FmmmnovliXAy9/la/bJKGlgfUVfZzvncfpkOZ7jxkdWVS4K0D89v6g5yQ8ppHEQ1IwnyQVr7i9vFgbV3A58pvCuhjwtlGEbWybXRhySnh2bNzRvqyaiPM= 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 1585316689238535.6790629134225; Fri, 27 Mar 2020 06:44:49 -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-466-ifzUlxdDN2uAzHa0M-2AlQ-1; Fri, 27 Mar 2020 09:44:45 -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 854B4149CA; Fri, 27 Mar 2020 13:44:39 +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 5532D19756; Fri, 27 Mar 2020 13:44:39 +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 0B24D180880B; Fri, 27 Mar 2020 13:44:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02RDiMdC006321 for ; Fri, 27 Mar 2020 09:44:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C8BA5C1D6; 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 2D08F5C1D4 for ; Fri, 27 Mar 2020 13:44:22 +0000 (UTC) Received: by rein.int.mamuti.net (Postfix, from userid 500) id F01F418D5AC; 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=1585316688; 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=ayWFIXYdjUOqSNClM2t8msdJdPR8CPdQdcZ/XY8TEjg=; b=HwEvJDLiI2+LpKyd8ddZW7CmTyeqZ4nbBUfbSrjrUd7zSGyrffU0EQ0/pu7wckDF62V26O qXTf1iVvPxntQMQtfiJ77QuLrEQJW2yojG0IBzvr4DuLBmhDtyolpy4EnozOz8R+6OLYbw VKax4vVY4TdC6pHvfX5wcRYht/l2W9w= X-MC-Unique: ifzUlxdDN2uAzHa0M-2AlQ-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 17/39] cpu_x86: Use g_auto* in x86Decode Date: Fri, 27 Mar 2020 14:43:46 +0100 Message-Id: <2dd6937284fd953fbd7a0686ae4cb86758857270.1585316580.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index e4e21fbed4..26d872622e 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2034,15 +2034,14 @@ x86Decode(virCPUDefPtr cpu, const char *preferred, bool migratable) { - int ret =3D -1; virCPUx86MapPtr map; virCPUx86ModelPtr candidate; virCPUDefPtr cpuCandidate; virCPUx86ModelPtr model =3D NULL; - virCPUDefPtr cpuModel =3D NULL; - virCPUx86Data data =3D VIR_CPU_X86_DATA_INIT; - virCPUx86Data copy =3D VIR_CPU_X86_DATA_INIT; - virCPUx86Data features =3D VIR_CPU_X86_DATA_INIT; + g_autoptr(virCPUDef) cpuModel =3D NULL; + g_auto(virCPUx86Data) data =3D VIR_CPU_X86_DATA_INIT; + g_auto(virCPUx86Data) copy =3D VIR_CPU_X86_DATA_INIT; + g_auto(virCPUx86Data) features =3D VIR_CPU_X86_DATA_INIT; virCPUx86VendorPtr vendor; virDomainCapsCPUModelPtr hvModel =3D NULL; g_autofree char *sigs =3D NULL; @@ -2056,7 +2055,7 @@ x86Decode(virCPUDefPtr cpu, x86DataCopy(&data, cpuData); =20 if (!(map =3D virCPUx86GetMap())) - goto cleanup; + return -1; =20 vendor =3D x86DataToVendor(&data, map); signature =3D x86DataToSignature(&data); @@ -2075,7 +2074,7 @@ x86Decode(virCPUDefPtr cpu, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("CPU model %s is not supported by hyp= ervisor"), preferred); - goto cleanup; + return -1; } else { VIR_WARN("Preferred CPU model %s not allowed by" " hypervisor; closest supported model will be" @@ -2098,7 +2097,7 @@ x86Decode(virCPUDefPtr cpu, } =20 if (!(cpuCandidate =3D x86DataToCPU(&data, candidate, map, hvModel= ))) - goto cleanup; + return -1; cpuCandidate->type =3D cpu->type; =20 if ((rc =3D x86DecodeUseCandidate(model, cpuModel, @@ -2117,7 +2116,7 @@ x86Decode(virCPUDefPtr cpu, if (!cpuModel) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot find suitable CPU model for given d= ata")); - goto cleanup; + return -1; } =20 /* Remove non-migratable features if requested @@ -2151,14 +2150,7 @@ x86Decode(virCPUDefPtr cpu, cpu->nfeatures_max =3D cpuModel->nfeatures_max; cpuModel->nfeatures_max =3D 0; =20 - ret =3D 0; - - cleanup: - virCPUDefFree(cpuModel); - virCPUx86DataClear(&data); - virCPUx86DataClear(©); - virCPUx86DataClear(&features); - return ret; + return 0; } =20 static int --=20 2.26.0