[libvirt PATCH 08/16] conf: remove superfluous cleanup: labels and ret return variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After converting virNetworkDef * to g_autoptr(virNetworkDef) the
cleanup codepath was empty, so it has been removed.

Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
---
 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 = NULL;
-    int ret = -1;
     g_autofree char *xml = NULL;
     g_autoptr(virConnect) conn = NULL;
     g_autoptr(virNetwork) net = NULL;
@@ -29907,13 +29906,13 @@ virDomainNetResolveActualType(virDomainNetDef *iface)
         return -1;
 
     if (!(net = virNetworkLookupByName(conn, iface->data.network.name)))
-        goto cleanup;
+        return -1;
 
     if (!(xml = virNetworkGetXMLDesc(net, 0)))
-        goto cleanup;
+        return -1;
 
     if (!(def = virNetworkDefParseString(xml, NULL, false)))
-        goto cleanup;
+        return -1;
 
     switch ((virNetworkForwardType) def->forward.type) {
     case VIR_NETWORK_FORWARD_NONE:
@@ -29924,11 +29923,11 @@ virDomainNetResolveActualType(virDomainNetDef *iface)
          * NETWORK; we just keep the info from the portgroup in
          * iface->data.network.actual
          */
-        ret = VIR_DOMAIN_NET_TYPE_NETWORK;
+        return VIR_DOMAIN_NET_TYPE_NETWORK;
         break;
 
     case VIR_NETWORK_FORWARD_HOSTDEV:
-        ret = VIR_DOMAIN_NET_TYPE_HOSTDEV;
+        return VIR_DOMAIN_NET_TYPE_HOSTDEV;
         break;
 
     case VIR_NETWORK_FORWARD_BRIDGE:
@@ -29936,7 +29935,7 @@ virDomainNetResolveActualType(virDomainNetDef *iface)
             /* <forward type='bridge'/> <bridge name='xxx'/>
              * is VIR_DOMAIN_NET_TYPE_BRIDGE
              */
-            ret = VIR_DOMAIN_NET_TYPE_BRIDGE;
+            return VIR_DOMAIN_NET_TYPE_BRIDGE;
             break;
         }
 
@@ -29951,17 +29950,19 @@ virDomainNetResolveActualType(virDomainNetDef *iface)
         /* <forward type='bridge|private|vepa|passthrough'> are all
          * VIR_DOMAIN_NET_TYPE_DIRECT.
          */
-        ret = VIR_DOMAIN_NET_TYPE_DIRECT;
+        return VIR_DOMAIN_NET_TYPE_DIRECT;
         break;
 
     case VIR_NETWORK_FORWARD_LAST:
     default:
         virReportEnumRangeError(virNetworkForwardType, def->forward.type);
-        goto cleanup;
+        return -1;
     }
 
- cleanup:
-    return ret;
+    /* this line is unreachable due to the preceding switch, but the compiler
+     * requires some kind of return at the end of the function.
+     */
+    return VIR_NETWORK_FORWARD_NONE;
 }
 
 
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,
 
 
     if ((configFile = virNetworkConfigFile(stateDir, name)) == NULL)
-        goto error;
+        return NULL;
 
     if (!(xml = virXMLParseCtxt(configFile, NULL, _("(network status)"), &ctxt)))
-        goto error;
+        return NULL;
 
     if (!(node = virXPathNode("//network", ctxt))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Could not find any 'network' element in status file"));
-        goto error;
+        return NULL;
     }
 
     /* parse the definition first */
     ctxt->node = node;
     if (!(def = virNetworkDefParseXML(ctxt, xmlopt)))
-        goto error;
+        return NULL;
 
     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;
     }
 
     /* now parse possible status data */
@@ -893,7 +893,7 @@ virNetworkLoadState(virNetworkObjList *nets,
         if ((classIdStr = virXPathString("string(./class_id[1]/@bitmap)",
                                          ctxt))) {
             if (!(classIdMap = virBitmapParseUnlimited(classIdStr)))
-                goto error;
+                return NULL;
         }
 
         floor_sum = 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;
         }
 
         if ((n = virXPathNodeSet("./taint", ctxt, &nodes)) < 0)
-            goto error;
+            return NULL;
 
         for (i = 0; i < n; i++) {
             g_autofree char *str = 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,
     }
 
     /* create the object */
-    if (!(obj = virNetworkObjAssignDef(nets, def,
-                                       VIR_NETWORK_OBJ_LIST_ADD_LIVE)))
-        goto error;
-    /* do not put any "goto error" below this comment */
+    if (!(obj = virNetworkObjAssignDef(nets, def, VIR_NETWORK_OBJ_LIST_ADD_LIVE)))
+        return NULL;
+
     def = NULL;
 
     /* assign status data stored in the network object */
@@ -944,9 +943,6 @@ virNetworkLoadState(virNetworkObjList *nets,
     obj->active = true; /* network with a state file is by definition active */
 
     return obj;
-
- error:
-    return NULL;
 }
 
 
@@ -1213,29 +1209,29 @@ virNetworkObjUpdate(virNetworkObj *obj,
                     virNetworkXMLOption *xmlopt,
                     unsigned int flags)  /* virNetworkUpdateFlags */
 {
-    int ret = -1;
     g_autoptr(virNetworkDef) livedef = NULL;
     g_autoptr(virNetworkDef) configdef = NULL;
 
     /* normalize config data, and check for common invalid requests. */
     if (virNetworkObjConfigChangeSetup(obj, xmlopt, flags) < 0)
-       goto cleanup;
+        return -1;
 
     if (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE) {
         g_autoptr(virNetworkDef) checkdef = NULL;
 
         /* work on a copy of the def */
         if (!(livedef = 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 = virNetworkDefCopy(livedef, xmlopt, 0)))
-            goto cleanup;
+            return -1;
     }
 
     if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) {
@@ -1245,23 +1241,24 @@ virNetworkObjUpdate(virNetworkObj *obj,
         if (!(configdef = virNetworkDefCopy(virNetworkObjGetPersistentDef(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 = virNetworkDefCopy(configdef,
                                            xmlopt,
                                            VIR_NETWORK_XML_INACTIVE))) {
-            goto cleanup;
+            return -1;
         }
     }
 
     if (configdef) {
         /* successfully modified copy, now replace original */
         if (virNetworkObjReplacePersistentDef(obj, configdef) < 0)
-           goto cleanup;
+            return -1;
+
         configdef = NULL;
     }
     if (livedef) {
@@ -1270,9 +1267,7 @@ virNetworkObjUpdate(virNetworkObj *obj,
         obj->def = g_steal_pointer(&livedef);
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
-- 
2.37.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux