From nobody Mon Feb 9 10:58:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1629203153; cv=none; d=zohomail.com; s=zohoarc; b=BP5ESOkoA7ylcipz/mRhCKX8UedAbSZsdIPEe2uBCe3gFiFtTKD47KocSSw+Xop3pf7lzklpdpU867T0xHpD+t0E0BBAI7NSyGsI9LNx/iECoH9GmZkRAccU9IDCMbwyu+6zJAtgkyw7/VDudnqVZ0KipmedztkBws2Kxu/vhDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629203153; 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=OvJUUIwYfknk+mjktKNhUASvImyrTI0Utin1XKu8nmo=; b=FHKn6jUmKhL7IC1PnTX1dMtBq9XVOgOFhZZF4Y8J0kM+4/n0B0Gv0PNefNFwKxhWJK1ka5Wdlo0q5iSY5HlGEoVFC/8LRUZBx+Cz2DfMaiGT2f3TxZ2TjD8wo795kqnZv1Cu6yOERhhZH81tmllBT8pFA3o4h0w/UVSkR1TgzA0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1629203153938458.1258643290163; Tue, 17 Aug 2021 05:25:53 -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-452-YIACK7gnPMGGtoYr1ITeqw-1; Tue, 17 Aug 2021 08:25:50 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E655801AC0; Tue, 17 Aug 2021 12:25:45 +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 F396160C0F; Tue, 17 Aug 2021 12:25:44 +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 7C953181A0F7; Tue, 17 Aug 2021 12:25:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17HCPhEH018179 for ; Tue, 17 Aug 2021 08:25:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC99360871; Tue, 17 Aug 2021 12:25:43 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4710260854 for ; Tue, 17 Aug 2021 12:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629203152; 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=OvJUUIwYfknk+mjktKNhUASvImyrTI0Utin1XKu8nmo=; b=Rio5b+mCycUJ33NSyp4Aa3XlAjkaI53K53lC24dzpnRESj9yVxnpjIMR1H1EIggsW6qVTh cRzYKl42OAvsgaZ/7XKxy0VaI+R+6ahdOyevZy0QJ+4qQ0qpZ61ZBtESS7NFJnC0i8G+wp gXlMq+1BwB73Jt4prHOMLuEaUySkijE= X-MC-Unique: YIACK7gnPMGGtoYr1ITeqw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/6] Remove redundant labels Date: Tue, 17 Aug 2021 14:25:33 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629203154657100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/conf/cpu_conf.c | 12 ++++-------- src/conf/virnetworkportdef.c | 10 +++------- src/conf/virnwfilterbindingdef.c | 10 +++------- src/conf/virnwfilterbindingobj.c | 10 +++------- src/conf/virsavecookie.c | 14 ++++---------- src/conf/virstorageobj.c | 12 +++++------- src/libxl/libxl_migration.c | 8 ++------ src/qemu/qemu_migration_cookie.c | 9 ++------- src/security/virt-aa-helper.c | 17 ++++++----------- src/storage/storage_util.c | 17 ++++++----------- src/vz/vz_driver.c | 4 +--- tests/cputest.c | 14 ++++++-------- tests/metadatatest.c | 13 ++++--------- 13 files changed, 49 insertions(+), 101 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 4434120557..1674cd6957 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -283,23 +283,19 @@ virCPUDefParseXMLString(const char *xml, { g_autoptr(xmlDoc) doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - int ret =3D -1; =20 if (!xml) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing CPU definitio= n")); - goto cleanup; + return -1; } =20 if (!(doc =3D virXMLParseStringCtxt(xml, _("(CPU_definition)"), &ctxt)= )) - goto cleanup; + return -1; =20 if (virCPUDefParseXML(ctxt, NULL, type, cpu, validateXML) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c index 5e916ab2b8..c1749eebe0 100644 --- a/src/conf/virnetworkportdef.c +++ b/src/conf/virnetworkportdef.c @@ -269,23 +269,19 @@ virNetworkPortDefParseNode(xmlDocPtr xml, xmlNodePtr root) { g_autoptr(xmlXPathContext) ctxt =3D NULL; - virNetworkPortDef *def =3D NULL; =20 if (STRNEQ((const char *)root->name, "networkport")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("unknown root element for network port")); - goto cleanup; + return NULL; } =20 if (!(ctxt =3D virXMLXPathContextNew(xml))) - goto cleanup; + return NULL; =20 ctxt->node =3D root; - def =3D virNetworkPortDefParseXML(ctxt); - - cleanup: - return def; + return virNetworkPortDefParseXML(ctxt); } =20 =20 diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbinding= def.c index 3428b05841..5f671030bb 100644 --- a/src/conf/virnwfilterbindingdef.c +++ b/src/conf/virnwfilterbindingdef.c @@ -160,23 +160,19 @@ virNWFilterBindingDefParseNode(xmlDocPtr xml, xmlNodePtr root) { g_autoptr(xmlXPathContext) ctxt =3D NULL; - virNWFilterBindingDef *def =3D NULL; =20 if (STRNEQ((const char *)root->name, "filterbinding")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("unknown root element for nwfilter binding")); - goto cleanup; + return NULL; } =20 if (!(ctxt =3D virXMLXPathContextNew(xml))) - goto cleanup; + return NULL; =20 ctxt->node =3D root; - def =3D virNWFilterBindingDefParseXML(ctxt); - - cleanup: - return def; + return virNWFilterBindingDefParseXML(ctxt); } =20 =20 diff --git a/src/conf/virnwfilterbindingobj.c b/src/conf/virnwfilterbinding= obj.c index 279e334d3f..29fbb63b5f 100644 --- a/src/conf/virnwfilterbindingobj.c +++ b/src/conf/virnwfilterbindingobj.c @@ -237,23 +237,19 @@ virNWFilterBindingObjParseNode(xmlDocPtr doc, xmlNodePtr root) { g_autoptr(xmlXPathContext) ctxt =3D NULL; - virNWFilterBindingObj *obj =3D NULL; =20 if (STRNEQ((const char *)root->name, "filterbindingstatus")) { virReportError(VIR_ERR_XML_ERROR, _("unknown root element '%s' for filter binding"), root->name); - goto cleanup; + return NULL; } =20 if (!(ctxt =3D virXMLXPathContextNew(doc))) - goto cleanup; + return NULL; =20 ctxt->node =3D root; - obj =3D virNWFilterBindingObjParseXML(doc, ctxt); - - cleanup: - return obj; + return virNWFilterBindingObjParseXML(doc, ctxt); } =20 =20 diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c index 3bb97246af..6cb7fafb1f 100644 --- a/src/conf/virsavecookie.c +++ b/src/conf/virsavecookie.c @@ -81,22 +81,16 @@ virSaveCookieParseString(const char *xml, { g_autoptr(xmlDoc) doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - int ret =3D -1; =20 *obj =3D NULL; =20 - if (!xml) { - ret =3D 0; - goto cleanup; - } + if (!xml) + return 0; =20 if (!(doc =3D virXMLParseStringCtxt(xml, _("(save cookie)"), &ctxt))) - goto cleanup; + return -1; =20 - ret =3D virSaveCookieParseNode(ctxt, obj, saveCookie); - - cleanup: - return ret; + return virSaveCookieParseNode(ctxt, obj, saveCookie); } =20 =20 diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 1f6fedba13..f906c5b141 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1652,30 +1652,30 @@ virStoragePoolObjLoadState(virStoragePoolObjList *p= ools, return NULL; =20 if (!(xml =3D virXMLParseCtxt(stateFile, NULL, _("(pool state)"), &ctx= t))) - goto cleanup; + return NULL; =20 if (!(node =3D virXPathNode("//pool", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not find any 'pool' element in state file"= )); - goto cleanup; + return NULL; } =20 ctxt->node =3D node; if (!(def =3D virStoragePoolDefParseXML(ctxt))) - goto cleanup; + return NULL; =20 if (STRNEQ(name, def->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Storage pool state file '%s' does not match " "pool name '%s'"), stateFile, def->name); - goto cleanup; + return NULL; } =20 /* create the object */ if (!(obj =3D virStoragePoolObjListAdd(pools, def, VIR_STORAGE_POOL_OBJ_LIST_ADD_CHE= CK_LIVE))) - goto cleanup; + return NULL; def =3D NULL; =20 /* XXX: future handling of some additional useful status data, @@ -1684,8 +1684,6 @@ virStoragePoolObjLoadState(virStoragePoolObjList *poo= ls, */ =20 obj->active =3D true; - - cleanup: return obj; } =20 diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index a2c2b6dbde..aa719a19d2 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -151,7 +151,6 @@ libxlMigrationEatCookie(const char *cookiein, g_autoptr(xmlDoc) doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autofree char *uuidstr =3D NULL; - int ret =3D -1; =20 /* * Assume a legacy (V1) migration stream if request came from a @@ -209,14 +208,11 @@ libxlMigrationEatCookie(const char *cookiein, } =20 *migout =3D mig; - ret =3D 0; - goto cleanup; + return 0; =20 error: libxlMigrationCookieFree(mig); - - cleanup: - return ret; + return -1; } =20 static void diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 106897cacd..b67728f9c0 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1433,18 +1433,13 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookie = *mig, { g_autoptr(xmlDoc) doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - int ret =3D -1; =20 VIR_DEBUG("xml=3D%s", NULLSTR(xml)); =20 if (!(doc =3D virXMLParseStringCtxt(xml, _("(qemu_migration_cookie)"),= &ctxt))) - goto cleanup; + return -1; =20 - ret =3D qemuMigrationCookieXMLParse(mig, driver, qemuCaps, doc, ctxt, = flags); - - cleanup: - - return ret; + return qemuMigrationCookieXMLParse(mig, driver, qemuCaps, doc, ctxt, f= lags); } =20 =20 diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index c0bbd7414a..77b2307594 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -567,34 +567,33 @@ verify_xpath_context(xmlXPathContextPtr ctxt) static int caps_mockup(vahControl * ctl, const char *xmlStr) { - int rc =3D -1; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; char *arch; =20 if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(domain_definition)"), &ctxt))) { - goto cleanup; + return -1; } =20 if (!virXMLNodeNameEqual(ctxt->node, "domain")) { vah_error(NULL, 0, _("unexpected root element, expecting "= )); - goto cleanup; + return -1; } =20 /* Quick sanity check for some required elements */ if (verify_xpath_context(ctxt) !=3D 0) - goto cleanup; + return -1; =20 ctl->virtType =3D virXPathString("string(./@type)", ctxt); if (!ctl->virtType) { vah_error(ctl, 0, _("domain type is not defined")); - goto cleanup; + return -1; } ctl->os =3D virXPathString("string(./os/type[1])", ctxt); if (!ctl->os) { vah_error(ctl, 0, _("os.type is not defined")); - goto cleanup; + return -1; } arch =3D virXPathString("string(./os/type[1]/@arch)", ctxt); if (!arch) { @@ -604,11 +603,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr) VIR_FREE(arch); } =20 - rc =3D 0; - - cleanup: - - return rc; + return 0; } =20 virDomainDefParserConfig virAAHelperDomainDefParserConfig =3D { diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 7ee736535c..53792765ff 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2897,26 +2897,25 @@ virStorageUtilGlusterExtractPoolSources(const char = *host, virStoragePoolSource *src =3D NULL; size_t i; int nnodes; - int ret =3D -1; g_autofree xmlNodePtr *nodes =3D NULL; g_autofree char *volname =3D NULL; =20 if (!(doc =3D virXMLParseStringCtxt(xml, _("(gluster_cli_output)"), &c= txt))) - goto cleanup; + return -1; =20 if ((nnodes =3D virXPathNodeSet("//volumes/volume", ctxt, &nodes)) < 0) - goto cleanup; + return -1; =20 for (i =3D 0; i < nnodes; i++) { ctxt->node =3D nodes[i]; =20 if (!(src =3D virStoragePoolSourceListNewSource(list))) - goto cleanup; + return -1; =20 if (!(volname =3D virXPathString("string(./name)", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to extract gluster volume name")); - goto cleanup; + return -1; } =20 if (pooltype =3D=3D VIR_STORAGE_POOL_NETFS) { @@ -2928,7 +2927,7 @@ virStorageUtilGlusterExtractPoolSources(const char *h= ost, } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("unsupported gluster lookup")); - goto cleanup; + return -1; } =20 src->hosts =3D g_new0(virStoragePoolSourceHost, 1); @@ -2937,11 +2936,7 @@ virStorageUtilGlusterExtractPoolSources(const char *= host, src->hosts[0].name =3D g_strdup(host); } =20 - ret =3D nnodes; - - cleanup: - - return ret; + return nnodes; } =20 =20 diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 9eba9d47fb..a1d05f834b 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -2837,13 +2837,11 @@ vzEatCookie(const char *cookiein, int cookieinlen, = unsigned int flags) goto error; } =20 - cleanup: return mig; =20 error: vzMigrationCookieFree(mig); - mig =3D NULL; - goto cleanup; + return NULL; } =20 #define VZ_MIGRATION_FLAGS (VIR_MIGRATE_PAUSED | \ diff --git a/tests/cputest.c b/tests/cputest.c index 14606f5864..7816de87f7 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -79,11 +79,10 @@ cpuTestLoadXML(virArch arch, const char *name) virArchToString(arch), name); =20 if (!(doc =3D virXMLParseFileCtxt(xml, &ctxt))) - goto cleanup; + return NULL; =20 virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, false); =20 - cleanup: return cpu; } =20 @@ -105,12 +104,12 @@ cpuTestLoadMultiXML(virArch arch, virArchToString(arch), name); =20 if (!(doc =3D virXMLParseFileCtxt(xml, &ctxt))) - goto cleanup; + return NULL; =20 n =3D virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes); if (n <=3D 0) { fprintf(stderr, "\nNo /cpuTest/cpu elements found in %s\n", xml); - goto cleanup; + return NULL; } =20 cpus =3D g_new0(virCPUDef *, n); @@ -119,19 +118,18 @@ cpuTestLoadMultiXML(virArch arch, ctxt->node =3D nodes[i]; if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i], false) < 0) - goto cleanup_cpus; + goto error; } =20 *count =3D n; =20 - cleanup: return cpus; =20 - cleanup_cpus: + error: for (i =3D 0; i < n; i++) virCPUDefFree(cpus[i]); VIR_FREE(cpus); - goto cleanup; + return NULL; } =20 =20 diff --git a/tests/metadatatest.c b/tests/metadatatest.c index 2c560c27c1..e565383ce2 100644 --- a/tests/metadatatest.c +++ b/tests/metadatatest.c @@ -61,22 +61,17 @@ getMetadataFromXML(virDomainPtr dom) xmlNodePtr node; =20 g_autofree char *xml =3D NULL; - char *ret =3D NULL; =20 if (!(xml =3D virDomainGetXMLDesc(dom, 0))) - goto cleanup; + return NULL; =20 if (!(doc =3D virXMLParseStringCtxt(xml, "(domain_definition)", &ctxt)= )) - goto cleanup; + return NULL; =20 if (!(node =3D virXPathNode("//metadata/*", ctxt))) - goto cleanup; + return NULL; =20 - ret =3D virXMLNodeToString(node->doc, node); - - cleanup: - - return ret; + return virXMLNodeToString(node->doc, node); } =20 =20 --=20 2.31.1