From nobody Tue Feb 10 00:57:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1661175128; cv=none; d=zohomail.com; s=zohoarc; b=eTvCTf8icbU82XGltq4k4+PdgE24rWpPzyHP48qSmjpfshR2Bvq6m+6HfdOnaOynBtWm/svABVkN/NwvCo5/KXNkZRGaKnLyZkEn6BFTPPgDU+VX/tJ8B67x9EioQ4Z9hcrjks0w9rCKfUNh4DfojqwomU9XJg9v6+AM6QSHw9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661175128; 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=EW8NKPGU6YaV/6VWRjdxFQxCb6oKHzxMg1wRBOjgZ0M=; b=MaQ1V+ryWKewlEQFlpxe/A4FWPORraMklqoDcBnn2bEhWeZa6JCv5Z+hMXQM9RKUrM9FWl4RATOR9DOcf8inDXX+IVUq09ryyfAtiLEmwym6DBzXYZTx3QTbRpCdy3+okc7w3Q/p7A3IQiJt10JmckJOUcZm3droGTf9c5IuduQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1661175128549369.25491054446013; Mon, 22 Aug 2022 06:32:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-139-YuRr3kH1OES3fBvdncpYEg-1; Mon, 22 Aug 2022 09:32:05 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 48F69299E750; Mon, 22 Aug 2022 13:31:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 336DAC15BBA; Mon, 22 Aug 2022 13:31:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 17C8E1946A4B; Mon, 22 Aug 2022 13:31:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2B0891946A44 for ; Mon, 22 Aug 2022 13:31:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0263B40CFD0D; Mon, 22 Aug 2022 13:31:52 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.2.16.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id E237740CFD0A for ; Mon, 22 Aug 2022 13:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661175127; 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=EW8NKPGU6YaV/6VWRjdxFQxCb6oKHzxMg1wRBOjgZ0M=; b=gtiz8+7OMViuD7iUuVGGpMYh35OQb13gLULrH8rpjlB7KYXyDR9rUMdDSG7VhESQd8FQbA n5q5QTdZxW2vrr4oflGJUsH0LPVOypWTkGekKD3uggNe4o8U3eAw83ZMe1Go7mSMZJJ/U1 QddyqqT8lVWH05RboISdybkL9ygZ1YQ= X-MC-Unique: YuRr3kH1OES3fBvdncpYEg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 08/16] conf: remove superfluous cleanup: labels and ret return variables Date: Mon, 22 Aug 2022 09:31:42 -0400 Message-Id: <20220822133150.1098794-9-laine@redhat.com> In-Reply-To: <20220822133150.1098794-1-laine@redhat.com> References: <20220822133150.1098794-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661175129141100008 Content-Type: text/plain; charset="utf-8"; x-default="true" After converting virNetworkDef * to g_autoptr(virNetworkDef) the cleanup codepath was empty, so it has been removed. Signed-off-by: Laine Stump --- src/conf/domain_conf.c | 23 +++++++++--------- src/conf/virnetworkobj.c | 51 ++++++++++++++++++---------------------- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f66a19311b..610bbcfd58 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29892,7 +29892,6 @@ int virDomainNetResolveActualType(virDomainNetDef *iface) { g_autoptr(virNetworkDef) def =3D NULL; - int ret =3D -1; g_autofree char *xml =3D NULL; g_autoptr(virConnect) conn =3D NULL; g_autoptr(virNetwork) net =3D NULL; @@ -29907,13 +29906,13 @@ virDomainNetResolveActualType(virDomainNetDef *if= ace) return -1; =20 if (!(net =3D virNetworkLookupByName(conn, iface->data.network.name))) - goto cleanup; + return -1; =20 if (!(xml =3D virNetworkGetXMLDesc(net, 0))) - goto cleanup; + return -1; =20 if (!(def =3D virNetworkDefParseString(xml, NULL, false))) - goto cleanup; + return -1; =20 switch ((virNetworkForwardType) def->forward.type) { case VIR_NETWORK_FORWARD_NONE: @@ -29924,11 +29923,11 @@ virDomainNetResolveActualType(virDomainNetDef *if= ace) * NETWORK; we just keep the info from the portgroup in * iface->data.network.actual */ - ret =3D VIR_DOMAIN_NET_TYPE_NETWORK; + return VIR_DOMAIN_NET_TYPE_NETWORK; break; =20 case VIR_NETWORK_FORWARD_HOSTDEV: - ret =3D VIR_DOMAIN_NET_TYPE_HOSTDEV; + return VIR_DOMAIN_NET_TYPE_HOSTDEV; break; =20 case VIR_NETWORK_FORWARD_BRIDGE: @@ -29936,7 +29935,7 @@ virDomainNetResolveActualType(virDomainNetDef *ifac= e) /* * is VIR_DOMAIN_NET_TYPE_BRIDGE */ - ret =3D VIR_DOMAIN_NET_TYPE_BRIDGE; + return VIR_DOMAIN_NET_TYPE_BRIDGE; break; } =20 @@ -29951,17 +29950,19 @@ virDomainNetResolveActualType(virDomainNetDef *if= ace) /* are all * VIR_DOMAIN_NET_TYPE_DIRECT. */ - ret =3D VIR_DOMAIN_NET_TYPE_DIRECT; + return VIR_DOMAIN_NET_TYPE_DIRECT; break; =20 case VIR_NETWORK_FORWARD_LAST: default: virReportEnumRangeError(virNetworkForwardType, def->forward.type); - goto cleanup; + return -1; } =20 - cleanup: - return ret; + /* this line is unreachable due to the preceding switch, but the compi= ler + * requires some kind of return at the end of the function. + */ + return VIR_NETWORK_FORWARD_NONE; } =20 =20 diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 3896f116fc..b4c61fff85 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -856,28 +856,28 @@ virNetworkLoadState(virNetworkObjList *nets, =20 =20 if ((configFile =3D virNetworkConfigFile(stateDir, name)) =3D=3D NULL) - goto error; + return NULL; =20 if (!(xml =3D virXMLParseCtxt(configFile, NULL, _("(network status)"),= &ctxt))) - goto error; + return NULL; =20 if (!(node =3D virXPathNode("//network", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not find any 'network' element in status f= ile")); - goto error; + return NULL; } =20 /* parse the definition first */ ctxt->node =3D node; if (!(def =3D virNetworkDefParseXML(ctxt, xmlopt))) - goto error; + return NULL; =20 if (STRNEQ(name, def->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Network config filename '%s'" " does not match network name '%s'"), configFile, def->name); - goto error; + return NULL; } =20 /* now parse possible status data */ @@ -893,7 +893,7 @@ virNetworkLoadState(virNetworkObjList *nets, if ((classIdStr =3D virXPathString("string(./class_id[1]/@bitmap)", ctxt))) { if (!(classIdMap =3D virBitmapParseUnlimited(classIdStr))) - goto error; + return NULL; } =20 floor_sum =3D virXPathString("string(./floor[1]/@sum)", ctxt); @@ -902,11 +902,11 @@ virNetworkLoadState(virNetworkObjList *nets, virReportError(VIR_ERR_INTERNAL_ERROR, _("Malformed 'floor_sum' attribute: %s"), floor_sum); - goto error; + return NULL; } =20 if ((n =3D virXPathNodeSet("./taint", ctxt, &nodes)) < 0) - goto error; + return NULL; =20 for (i =3D 0; i < n; i++) { g_autofree char *str =3D virXMLPropString(nodes[i], "flag"); @@ -915,7 +915,7 @@ virNetworkLoadState(virNetworkObjList *nets, if (flag < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown taint flag %s"), str); - goto error; + return NULL; } /* Compute taint mask here. The network object does not * exist yet, so we can't use virNetworkObjtTaint. */ @@ -925,10 +925,9 @@ virNetworkLoadState(virNetworkObjList *nets, } =20 /* create the object */ - if (!(obj =3D virNetworkObjAssignDef(nets, def, - VIR_NETWORK_OBJ_LIST_ADD_LIVE))) - goto error; - /* do not put any "goto error" below this comment */ + if (!(obj =3D virNetworkObjAssignDef(nets, def, VIR_NETWORK_OBJ_LIST_A= DD_LIVE))) + return NULL; + def =3D NULL; =20 /* assign status data stored in the network object */ @@ -944,9 +943,6 @@ virNetworkLoadState(virNetworkObjList *nets, obj->active =3D true; /* network with a state file is by definition ac= tive */ =20 return obj; - - error: - return NULL; } =20 =20 @@ -1213,29 +1209,29 @@ virNetworkObjUpdate(virNetworkObj *obj, virNetworkXMLOption *xmlopt, unsigned int flags) /* virNetworkUpdateFlags */ { - int ret =3D -1; g_autoptr(virNetworkDef) livedef =3D NULL; g_autoptr(virNetworkDef) configdef =3D NULL; =20 /* normalize config data, and check for common invalid requests. */ if (virNetworkObjConfigChangeSetup(obj, xmlopt, flags) < 0) - goto cleanup; + return -1; =20 if (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE) { g_autoptr(virNetworkDef) checkdef =3D NULL; =20 /* work on a copy of the def */ if (!(livedef =3D virNetworkDefCopy(obj->def, xmlopt, 0))) - goto cleanup; + return -1; + if (virNetworkDefUpdateSection(livedef, command, section, parentIndex, xml, flags) < 0) { - goto cleanup; + return -1; } /* run a final format/parse cycle to make sure we didn't * add anything illegal to the def */ if (!(checkdef =3D virNetworkDefCopy(livedef, xmlopt, 0))) - goto cleanup; + return -1; } =20 if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) { @@ -1245,23 +1241,24 @@ virNetworkObjUpdate(virNetworkObj *obj, if (!(configdef =3D virNetworkDefCopy(virNetworkObjGetPersistentDe= f(obj), xmlopt, VIR_NETWORK_XML_INACTIVE))) { - goto cleanup; + return -1; } if (virNetworkDefUpdateSection(configdef, command, section, parentIndex, xml, flags) < 0) { - goto cleanup; + return -1; } if (!(checkdef =3D virNetworkDefCopy(configdef, xmlopt, VIR_NETWORK_XML_INACTIVE))) { - goto cleanup; + return -1; } } =20 if (configdef) { /* successfully modified copy, now replace original */ if (virNetworkObjReplacePersistentDef(obj, configdef) < 0) - goto cleanup; + return -1; + configdef =3D NULL; } if (livedef) { @@ -1270,9 +1267,7 @@ virNetworkObjUpdate(virNetworkObj *obj, obj->def =3D g_steal_pointer(&livedef); } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 --=20 2.37.1