From nobody Sun Feb 8 19:35:47 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=1585316733; cv=none; d=zohomail.com; s=zohoarc; b=HyzjJk2Mz7xQJJy+jbmnoV3CMpGUBNwLG4wcv7GGRAfDzd87WmURdXc81jfUX612/ZXelP4PjBnxxUZMilI44OTvp6wfsySLh1hxUaXKGGrnsWGgLVX8reQGwsaEH2MG4XvWqWZLyAnVp89vtiEwvHvAL4wSCaHZVl2+mXpHKk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585316733; 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=LXYNSpujIw5NXRYmqfn0xKcYP4p65iT7PEVxio1GWd0=; b=SC7dlLzdPE+6NXtaAaT3fwS2T11oyMLs6b7BzDRyrpKsAm2oWaAr9L3YyEryiSESY9j+g1O7FD/PO8JDtefxaJeshPGTihniKXr8+KqM7KjiRrU1df8oRD4LVvOEkQsVP7mtRI7CSXLK9vrj0ogP4f52DJgg55qh1iYo3w5CZYM= 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 15853167337181016.5391192856924; Fri, 27 Mar 2020 06:45:33 -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-415-k2yyV4h5O_yaoR4t4jqSFw-1; Fri, 27 Mar 2020 09:45:30 -0400 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 96DFE149C6; Fri, 27 Mar 2020 13:45:24 +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 61CF59B922; Fri, 27 Mar 2020 13:45:24 +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 0212B18033B0; Fri, 27 Mar 2020 13:45:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02RDiNwP006396 for ; Fri, 27 Mar 2020 09:44:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id EAF1E60BF4; 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 BD0E960BF3 for ; Fri, 27 Mar 2020 13:44:23 +0000 (UTC) Received: by rein.int.mamuti.net (Postfix, from userid 500) id 131BC18D5B4; 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=1585316732; 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=LXYNSpujIw5NXRYmqfn0xKcYP4p65iT7PEVxio1GWd0=; b=gQ8KSrfgEOyBDNW8stHAvIf6BpM0MMym0JNIhrgN909a+8liCuqZYYBNEIBtgNziKLkPly oc+sZAcN0kZngVSjpeCrYPcHh+aLFPjpIpnbumICQvFfxBmGJmES7MJ4EQKtc+F1gcXev4 HuF8Ie1P7/OGsNMiQRXFsr6/i/9zrfc= X-MC-Unique: k2yyV4h5O_yaoR4t4jqSFw-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 25/39] cpu_x86: Use g_auto* in virCPUx86UpdateLive Date: Fri, 27 Mar 2020 14:43:54 +0100 Message-Id: <3f7c051ce1cad28d267925ac5adf41b021cfb0a5.1585316580.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.11 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 | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 8da8b3ada2..0be2cf517d 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2901,26 +2901,25 @@ virCPUx86UpdateLive(virCPUDefPtr cpu, { bool hostPassthrough =3D cpu->mode =3D=3D VIR_CPU_MODE_HOST_PASSTHROUG= H; virCPUx86MapPtr map; - virCPUx86ModelPtr model =3D NULL; - virCPUx86ModelPtr modelDisabled =3D NULL; - virCPUx86Data enabled =3D VIR_CPU_X86_DATA_INIT; - virCPUx86Data disabled =3D VIR_CPU_X86_DATA_INIT; - virBuffer bufAdded =3D VIR_BUFFER_INITIALIZER; - virBuffer bufRemoved =3D VIR_BUFFER_INITIALIZER; - char *added =3D NULL; - char *removed =3D NULL; + g_autoptr(virCPUx86Model) model =3D NULL; + g_autoptr(virCPUx86Model) modelDisabled =3D NULL; + g_auto(virCPUx86Data) enabled =3D VIR_CPU_X86_DATA_INIT; + g_auto(virCPUx86Data) disabled =3D VIR_CPU_X86_DATA_INIT; + g_auto(virBuffer) bufAdded =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) bufRemoved =3D VIR_BUFFER_INITIALIZER; + g_autofree char *added =3D NULL; + g_autofree char *removed =3D NULL; size_t i; - int ret =3D -1; =20 if (!(map =3D virCPUx86GetMap())) return -1; =20 if (!(model =3D x86ModelFromCPU(cpu, map, -1))) - goto cleanup; + return -1; =20 if (hostPassthrough && !(modelDisabled =3D x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_DISA= BLE))) - goto cleanup; + return -1; =20 if (dataEnabled) x86DataCopy(&enabled, &dataEnabled->data.x86); @@ -2945,7 +2944,7 @@ virCPUx86UpdateLive(virCPUDefPtr cpu, virBufferAsprintf(&bufAdded, "%s,", feature->name); else if (virCPUDefUpdateFeature(cpu, feature->name, VIR_CPU_FEATURE_REQUIRE) < 0) - goto cleanup; + return -1; } =20 if (x86DataIsSubset(&disabled, &feature->data) || @@ -2956,7 +2955,7 @@ virCPUx86UpdateLive(virCPUDefPtr cpu, virBufferAsprintf(&bufRemoved, "%s,", feature->name); else if (virCPUDefUpdateFeature(cpu, feature->name, VIR_CPU_FEATURE_DISABLE) < 0) - goto cleanup; + return -1; } } =20 @@ -2982,28 +2981,17 @@ virCPUx86UpdateLive(virCPUDefPtr cpu, _("guest CPU doesn't match specification: " "missing features: %s"), removed); - goto cleanup; + return -1; } =20 if (cpu->check =3D=3D VIR_CPU_CHECK_FULL && !x86DataIsEmpty(&disabled)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("guest CPU doesn't match specification")); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - x86ModelFree(model); - x86ModelFree(modelDisabled); - virCPUx86DataClear(&enabled); - virCPUx86DataClear(&disabled); - VIR_FREE(added); - VIR_FREE(removed); - virBufferFreeAndReset(&bufAdded); - virBufferFreeAndReset(&bufRemoved); - return ret; + return 0; } =20 =20 --=20 2.26.0