From nobody Mon Feb 9 17:56:15 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 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 1637326472591696.465695021245; Fri, 19 Nov 2021 04:54:32 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-iApjFrrsPLaj871psuMvgg-1; Fri, 19 Nov 2021 07:54:27 -0500 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 9903A1927802; Fri, 19 Nov 2021 12:54:22 +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 7985A5F4ED; Fri, 19 Nov 2021 12:54:22 +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 485B44EA39; Fri, 19 Nov 2021 12:54:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AJCmvCT004260 for ; Fri, 19 Nov 2021 07:48:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 46D4C2026D46; Fri, 19 Nov 2021 12:48:57 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FEF12026D5D for ; Fri, 19 Nov 2021 12:48:51 +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-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0AB48801212 for ; Fri, 19 Nov 2021 12:48:51 +0000 (UTC) Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-499-UKGOoNbvO32QOpAbbcF_ww-1; Fri, 19 Nov 2021 07:48:49 -0500 Received: by mail-ua1-f43.google.com with SMTP id j14so11171985uan.10 for ; Fri, 19 Nov 2021 04:48:49 -0800 (PST) Received: from rekt.ibmuc.com ([152.250.208.89]) by smtp.gmail.com with ESMTPSA id s27sm1570629vkl.24.2021.11.19.04.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 04:48:48 -0800 (PST) X-MC-Unique: iApjFrrsPLaj871psuMvgg-1 X-MC-Unique: UKGOoNbvO32QOpAbbcF_ww-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o4CJwY7L56/BNhyJPlouLujoJqAciOBgWmuMZ2aJy9Y=; b=DddKCy7p2zm50aX8EW4t5cLtsaeHftEuXm4uHVJ47nJlhnZV1nEJIep/XwybDXm9RK cmyq+uucSZGS75h+WGWhAJ+RzgNOGDfxlxHS2UIqO7rcwf1TdCJcRfv1Xth3644nKaH6 bECjgmxgHzrDwtZlabnNrkwgZ++GWs2+C8MzcGqrQGc++NOOVp5l6/FDcqnX7fOMx8If +lkHBAyQPJMAwh9KV4qjGDazuswKAvtdA5XTsJtllLLZfr87hiPO+KabOK1IR27T71t0 +AFexNKXFA3GC0iOMx7/O0yGPdtlzO2h7RY34TpxNEzUaRTDRePYl8Mt66TQnkSWhfSw cy3g== X-Gm-Message-State: AOAM531S7bF+Rm+JwjYJLdIEu3epQQgr3+Z48PxHNeDSHh/eGqbHJsqj PNejwSgZiKUnJiFmOXgwDhChvTf2/oX9cw== X-Google-Smtp-Source: ABdhPJxlj0mZCJxBKXbOWXl0vgU3Xko3nTlQSj3ZZ88kGVzGYTB1qyukSLzd7kqlOllEmChq83f9GA== X-Received: by 2002:a67:e40d:: with SMTP id d13mr94201138vsf.11.1637326128874; Fri, 19 Nov 2021 04:48:48 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 8/8] qemu_capabilities.c: del 'cleanup' label in virQEMUCapsLoadHostCPUModelInfo() Date: Fri, 19 Nov 2021 09:48:30 -0300 Message-Id: <20211119124830.569230-9-danielhb413@gmail.com> In-Reply-To: <20211119124830.569230-1-danielhb413@gmail.com> References: <20211119124830.569230-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.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.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.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1637326474787100001 Content-Type: text/plain; charset="utf-8" Create extra g_autofree strings and use them in an adequate scope to eliminate the need for VIR_FREE() calls and the 'cleanup' label. Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_capabilities.c | 43 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9567ab7662..71dabdadd7 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3723,20 +3723,18 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *c= aps, xmlXPathContextPtr ctxt, const char *typeStr) { - char *str =3D NULL; + g_autofree char *migratability =3D NULL; xmlNodePtr hostCPUNode; g_autofree xmlNodePtr *nodes =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autoptr(qemuMonitorCPUModelInfo) hostCPU =3D NULL; g_autofree char *xpath =3D g_strdup_printf("./hostCPU[@type=3D'%s']", = typeStr); - int ret =3D -1; size_t i; int n; int val; =20 if (!(hostCPUNode =3D virXPathNode(xpath, ctxt))) { - ret =3D 0; - goto cleanup; + return 0; } =20 hostCPU =3D g_new0(qemuMonitorCPUModelInfo, 1); @@ -3745,17 +3743,16 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *c= aps, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing host CPU model name in QEMU " "capabilities cache")); - goto cleanup; + return -1; } =20 - if (!(str =3D virXMLPropString(hostCPUNode, "migratability")) || - (val =3D virTristateBoolTypeFromString(str)) <=3D 0) { + if (!(migratability =3D virXMLPropString(hostCPUNode, "migratability")= ) || + (val =3D virTristateBoolTypeFromString(migratability)) <=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid migratability value for host CPU model")= ); - goto cleanup; + return -1; } hostCPU->migratability =3D val =3D=3D VIR_TRISTATE_BOOL_YES; - VIR_FREE(str); =20 ctxt->node =3D hostCPUNode; =20 @@ -3765,6 +3762,8 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *cap= s, =20 for (i =3D 0; i < n; i++) { qemuMonitorCPUProperty *prop =3D hostCPU->props + i; + g_autofree char *type =3D NULL; + g_autofree char *migratable =3D NULL; =20 ctxt->node =3D nodes[i]; =20 @@ -3772,17 +3771,16 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *c= aps, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing 'name' attribute for a host CPU" " model property in QEMU capabilities cac= he")); - goto cleanup; + return -1; } =20 - if (!(str =3D virXMLPropString(ctxt->node, "type")) || - (val =3D qemuMonitorCPUPropertyTypeFromString(str)) < 0) { + if (!(type =3D virXMLPropString(ctxt->node, "type")) || + (val =3D qemuMonitorCPUPropertyTypeFromString(type)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing or invalid CPU model property ty= pe " "in QEMU capabilities cache")); - goto cleanup; + return -1; } - VIR_FREE(str); =20 prop->type =3D val; switch (prop->type) { @@ -3798,7 +3796,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *cap= s, _("invalid string value for '%s' host C= PU " "model property in QEMU capabilities = cache"), prop->name); - goto cleanup; + return -1; } break; =20 @@ -3809,7 +3807,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *cap= s, _("invalid number value for '%s' host C= PU " "model property in QEMU capabilities = cache"), prop->name); - goto cleanup; + return -1; } break; =20 @@ -3817,27 +3815,22 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *c= aps, break; } =20 - if ((str =3D virXMLPropString(ctxt->node, "migratable"))) { - if ((val =3D virTristateBoolTypeFromString(str)) <=3D 0) { + if ((migratable =3D virXMLPropString(ctxt->node, "migratable")= )) { + if ((val =3D virTristateBoolTypeFromString(migratable)) <= =3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown migratable value for '%s' ho= st " "CPU model property"), prop->name); - goto cleanup; + return -1; } =20 prop->migratable =3D val; - VIR_FREE(str); } } } =20 caps->hostCPU.info =3D g_steal_pointer(&hostCPU); - ret =3D 0; - - cleanup: - VIR_FREE(str); - return ret; + return 0; } =20 =20 --=20 2.31.1