From nobody Sun Feb 8 12:18:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1599078424; cv=none; d=zohomail.com; s=zohoarc; b=d4S7cr0VLERp+xZwrVm3w2XLM7LJP5TROSpKKG3SQwVaWKXuk54ko6TbHipD/sMge7Z35f8EygpwbUvEiqOr2tq+J7OaL9/mhsTzqP25kp7q1DPn5i1PQmbfy9ER/GbiLUHwiawE3p7vo14D42NxYuOqgVcYWqWJH+hHqtokzuE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599078424; h=Content-Type:Content-Transfer-Encoding:Cc: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=M3YFHlSrZ9TelXjwJwmnFi9NYAiX+RjKjk+8SBl0IQc=; b=MBDfaUy6j3MCm/5XHw66oxjEOg+XIlcMw2yx7A3+clc13ItHt5tNTVYr6tdCXyzJxGZU2IakwgpibJ9wBlV2oMsaBQyrZpJakkK/gzw4S7UOy/sEy9bEr4M2+QME3jUI+5QmUV0KIW7/9MTOWQJJ8jvsPIHagPR5hY/dDEGvlEw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1599078424312225.44191932965566; Wed, 2 Sep 2020 13:27:04 -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-488-qM4vj-tuOVGzB7q2KrZmRg-1; Wed, 02 Sep 2020 16:26:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 241361091068; Wed, 2 Sep 2020 20:26:21 +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 039D77E315; Wed, 2 Sep 2020 20:26:21 +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 C2CE779DBC; Wed, 2 Sep 2020 20:26:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 082KQDsU002873 for ; Wed, 2 Sep 2020 16:26:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id E98EBF00D9; Wed, 2 Sep 2020 20:26:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5090EE85C for ; Wed, 2 Sep 2020 20:26:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB9DB811E7A for ; Wed, 2 Sep 2020 20:26:12 +0000 (UTC) Received: from mail-qv1-f66.google.com (mail-qv1-f66.google.com [209.85.219.66]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-FhRKmRdzPKGLBYZv1J9GzA-1; Wed, 02 Sep 2020 16:26:09 -0400 Received: by mail-qv1-f66.google.com with SMTP id di5so220464qvb.13 for ; Wed, 02 Sep 2020 13:26:09 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:d5bb:61e:5265:e62b:1233]) by smtp.gmail.com with ESMTPSA id b187sm547176qkd.107.2020.09.02.13.26.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2020 13:26:08 -0700 (PDT) X-MC-Unique: qM4vj-tuOVGzB7q2KrZmRg-1 X-MC-Unique: FhRKmRdzPKGLBYZv1J9GzA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M3YFHlSrZ9TelXjwJwmnFi9NYAiX+RjKjk+8SBl0IQc=; b=jKlEtuUrKRsul3jEwbDpMJhMCp1ov2jHrl65qtqrTkG85WEEwHHZZAP5U/fpj/qeh0 bFCg7TGo2Am3JSApW4T4OIAkx/xp6NhOtMKbd1GWI9jmX+YdMsB9dJBQV7ynJg7MaOUr PxYhjNGVFLCcfODux5+9e42BAzlKvZBKqP+4srCDrQbuWcyRVaFqmmbkj2djnTKJdFJX 5pg4S5wfLNNar+xAST/B4dxZvCI1i0GH1t1ChMYAanVj2kwLQeskRO6GwKT1J3sAinRA USPoDlNcdX0K1kFGMMuNqhHyQ14GpQ/LadckGluaSRlfTEn9+fJhJk6PxuutQwzQXcGh nl2A== X-Gm-Message-State: AOAM533wbsUWUtffbdZM1OE/Hgy0Fv4M+2VmVCBPRRNj8lfEkInWyqhl Hou0OYyvsB49bxMZ8uSZdcFFAf17zn1h5g== X-Google-Smtp-Source: ABdhPJzp52370XTjRuYT8KH4tlg53mNLo7SLgQPWeEUK9eqYRKJ+Hsjk4jO+SgRdXXXbrr6E+VcNnA== X-Received: by 2002:a05:6214:289:: with SMTP id l9mr8347749qvv.137.1599078369025; Wed, 02 Sep 2020 13:26:09 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 09/12] cpu_ppc64.c: use g_autopr() with virCPUppc64MapPtr Date: Wed, 2 Sep 2020 17:25:43 -0300 Message-Id: <20200902202546.483726-10-danielhb413@gmail.com> In-Reply-To: <20200902202546.483726-1-danielhb413@gmail.com> References: <20200902202546.483726-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use autocleanup with virCPUppc64MapPtr to simplify existing code. Remove labels when possible. Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_ppc64.c | 47 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index 607b5bc322..b7c4864200 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -390,19 +390,15 @@ ppc64ModelParse(xmlXPathContextPtr ctxt, static virCPUppc64MapPtr ppc64LoadMap(void) { - virCPUppc64MapPtr map; + g_autoptr(virCPUppc64Map) map =3D NULL; =20 if (VIR_ALLOC(map) < 0) - goto error; + return NULL; =20 if (cpuMapLoad("ppc64", ppc64VendorParse, NULL, ppc64ModelParse, map) = < 0) - goto error; - - return map; + return NULL; =20 - error: - ppc64MapFree(map); - return NULL; + return g_steal_pointer(&map); } =20 static virCPUDataPtr @@ -428,7 +424,7 @@ ppc64Compute(virCPUDefPtr host, virCPUDataPtr *guestData, char **message) { - virCPUppc64MapPtr map =3D NULL; + g_autoptr(virCPUppc64Map) map =3D NULL; g_autoptr(virCPUppc64Model) host_model =3D NULL; g_autoptr(virCPUppc64Model) guest_model =3D NULL; virCPUDefPtr cpu =3D NULL; @@ -542,7 +538,6 @@ ppc64Compute(virCPUDefPtr host, =20 cleanup: virCPUDefFree(cpu); - ppc64MapFree(map); return ret; } =20 @@ -585,8 +580,7 @@ ppc64DriverDecode(virCPUDefPtr cpu, const virCPUData *data, virDomainCapsCPUModelsPtr models) { - int ret =3D -1; - virCPUppc64MapPtr map; + g_autoptr(virCPUppc64Map) map =3D NULL; const virCPUppc64Model *model; =20 if (!data || !(map =3D ppc64LoadMap())) @@ -596,26 +590,21 @@ ppc64DriverDecode(virCPUDefPtr cpu, virReportError(VIR_ERR_OPERATION_FAILED, _("Cannot find CPU model with PVR 0x%08x"), data->data.ppc64.pvr[0].value); - goto cleanup; + return -1; } =20 if (!virCPUModelIsAllowed(model->name, models)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("CPU model %s is not supported by hypervisor"), model->name); - goto cleanup; + return -1; } =20 cpu->model =3D g_strdup(model->name); if (model->vendor) cpu->vendor =3D g_strdup(model->vendor->name); =20 - ret =3D 0; - - cleanup: - ppc64MapFree(map); - - return ret; + return 0; } =20 static void @@ -686,7 +675,7 @@ virCPUppc64Baseline(virCPUDefPtr *cpus, const char **features G_GNUC_UNUSED, bool migratable G_GNUC_UNUSED) { - virCPUppc64MapPtr map; + g_autoptr(virCPUppc64Map) map =3D NULL; const virCPUppc64Model *model; const virCPUppc64Vendor *vendor =3D NULL; virCPUDefPtr cpu =3D NULL; @@ -761,23 +750,19 @@ virCPUppc64Baseline(virCPUDefPtr *cpus, cpu->match =3D VIR_CPU_MATCH_EXACT; cpu->fallback =3D VIR_CPU_FALLBACK_FORBID; =20 - cleanup: - ppc64MapFree(map); - return cpu; =20 error: virCPUDefFree(cpu); cpu =3D NULL; - goto cleanup; + return NULL; } =20 static int virCPUppc64DriverGetModels(char ***models) { - virCPUppc64MapPtr map; + g_autoptr(virCPUppc64Map) map =3D NULL; size_t i; - int ret =3D -1; =20 if (!(map =3D ppc64LoadMap())) goto error; @@ -790,18 +775,14 @@ virCPUppc64DriverGetModels(char ***models) (*models)[i] =3D g_strdup(map->models[i]->name); } =20 - ret =3D map->nmodels; - - cleanup: - ppc64MapFree(map); - return ret; + return map->nmodels; =20 error: if (models) { g_strfreev(*models); *models =3D NULL; } - goto cleanup; + return -1; } =20 struct cpuArchDriver cpuDriverPPC64 =3D { --=20 2.26.2