From nobody Sun Apr 28 18:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1599222777; cv=none; d=zohomail.com; s=zohoarc; b=OJRneMgiNqnDBa1JfMQ3+j22DBya+nl8YmQ155CdQWFJqz9Q4W0BqZ2juYewaSUvqJ548PAqO8AsspbCT86aMLUJ2Q52BeQjJRWwyvTjRrDOT70MTbohWuiQbuTkohJ/lgRKKzhtvpyENb3ylCAFeH07cXPZ98iVvNHPIcONuGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599222777; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=1mHSNqzi1bzIsjW0twi9DnQsgQEJHNN5sS5lZJ0ndls=; b=jojqNZm/LXjqUA0ikRu9yQjdY+L2OPh7HEegHge14odvOx1Hdp+PtfTdLf+8lTRvR1xd20DaWS8YBI4YO3iX75ZHEo0iFWbLsQkm5Zkr6DopGYIAiXiAXrvW1/dPP+7qBRU4j64jtNqWxpeyXK0eHfHsVOGtIjBNhAusRMDs5oY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1599222777581554.6601836977651; Fri, 4 Sep 2020 05:32:57 -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-185-y_XrONxbODeC-3rPMSl5Pg-1; Fri, 04 Sep 2020 08:32:55 -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 E4DD810082EB; Fri, 4 Sep 2020 12:32:49 +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 B213E1A885; Fri, 4 Sep 2020 12:32:49 +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 6F7B879DAE; Fri, 4 Sep 2020 12:32:49 +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 084CQCWv029711 for ; Fri, 4 Sep 2020 08:26:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5F9EE5C1DA; Fri, 4 Sep 2020 12:26:12 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-113.ams2.redhat.com [10.36.112.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4BAD5C1D0; Fri, 4 Sep 2020 12:26:08 +0000 (UTC) X-MC-Unique: y_XrONxbODeC-3rPMSl5Pg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH] cpu_map: Use g_auto* in cpuMapLoad Date: Fri, 4 Sep 2020 14:26:07 +0200 Message-Id: <20200904122607.46753-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Fri, 04 Sep 2020 08:32:48 -0400 Cc: Tim Wiederhake 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.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_map.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c index 913e34a067..cbf90d1395 100644 --- a/src/cpu/cpu_map.c +++ b/src/cpu/cpu_map.c @@ -169,12 +169,11 @@ int cpuMapLoad(const char *arch, cpuMapLoadCallback modelCB, void *data) { - xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - char *xpath =3D NULL; - int ret =3D -1; - char *mapfile; + g_autofree char *xpath =3D NULL; + g_autofree char *mapfile =3D NULL; =20 if (!(mapfile =3D virFileFindResource("index.xml", abs_top_srcdir "/src/cpu_map", @@ -186,11 +185,11 @@ int cpuMapLoad(const char *arch, if (arch =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("undefined hardware architecture")); - goto cleanup; + return -1; } =20 if (!(xml =3D virXMLParseFileCtxt(mapfile, &ctxt))) - goto cleanup; + return -1; =20 virBufferAsprintf(&buf, "./arch[@name=3D'%s']", arch); =20 @@ -201,28 +200,20 @@ int cpuMapLoad(const char *arch, if ((ctxt->node =3D virXPathNode(xpath, ctxt)) =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot find CPU map for %s architecture"), arch); - goto cleanup; + return -1; } =20 if (loadData(mapfile, ctxt, "vendor", vendorCB, data) < 0) - goto cleanup; + return -1; =20 if (loadData(mapfile, ctxt, "feature", featureCB, data) < 0) - goto cleanup; + return -1; =20 if (loadData(mapfile, ctxt, "model", modelCB, data) < 0) - goto cleanup; + return -1; =20 if (loadIncludes(ctxt, vendorCB, featureCB, modelCB, data) < 0) - goto cleanup; - - ret =3D 0; - - cleanup: - xmlXPathFreeContext(ctxt); - xmlFreeDoc(xml); - VIR_FREE(xpath); - VIR_FREE(mapfile); + return -1; =20 - return ret; + return 0; } --=20 2.26.2