[libvirt] [PATCH v1 01/21] conf: remove unneeded cleanup labels

Daniel Henrique Barboza danielhb413 at gmail.com
Mon Oct 21 18:18:51 UTC 2019


Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/conf/domain_addr.c           |  23 +--
 src/conf/domain_capabilities.c   |  21 +-
 src/conf/domain_conf.c           | 334 +++++++++++--------------------
 src/conf/netdev_bandwidth_conf.c |  17 +-
 src/conf/network_conf.c          |  25 +--
 src/conf/node_device_conf.c      |  28 +--
 src/conf/numa_conf.c             |  25 +--
 src/conf/nwfilter_conf.c         |   4 +-
 src/conf/storage_conf.c          |   7 +-
 src/conf/virnetworkobj.c         |  14 +-
 src/conf/virsecretobj.c          |   5 +-
 11 files changed, 180 insertions(+), 323 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index dd8e04576a..0e505b19c0 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1789,7 +1789,6 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
                               virDomainDeviceVirtioSerialAddress *addr,
                               bool allowZero)
 {
-    int ret = -1;
     ssize_t port, startPort = 0;
     ssize_t i;
     unsigned int controller;
@@ -1801,7 +1800,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
     if (addrs->ncontrollers == 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("no virtio-serial controllers are available"));
-        goto cleanup;
+        return -1;
     }
 
     for (i = 0; i < addrs->ncontrollers; i++) {
@@ -1818,7 +1817,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
 
             if (idx == -1) {
                 if (virDomainVirtioSerialAddrSetAutoaddController(def, addrs, i) < 0)
-                    goto cleanup;
+                    return -1;
                 controller = i;
                 port = startPort + 1;
                 goto success;
@@ -1829,8 +1828,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
     virReportError(VIR_ERR_XML_ERROR, "%s",
                    _("Unable to find a free virtio-serial port"));
 
- cleanup:
-    return ret;
+    return -1;
 
  success:
     addr->bus = 0;
@@ -1838,8 +1836,7 @@ virDomainVirtioSerialAddrNext(virDomainDefPtr def,
     addr->controller = controller;
     VIR_DEBUG("Found free virtio serial controller %u port %u", addr->controller,
               addr->port);
-    ret = 0;
-    goto cleanup;
+    return 0;
 }
 
 static int
@@ -1880,7 +1877,6 @@ virDomainVirtioSerialAddrAssign(virDomainDefPtr def,
                                 bool allowZero,
                                 bool portOnly)
 {
-    int ret = -1;
     virDomainDeviceInfo nfo = { 0 };
     virDomainDeviceInfoPtr ptr = allowZero ? &nfo : info;
 
@@ -1889,20 +1885,17 @@ virDomainVirtioSerialAddrAssign(virDomainDefPtr def,
     if (portOnly) {
         if (virDomainVirtioSerialAddrNextFromController(addrs,
                                                         &ptr->addr.vioserial) < 0)
-            goto cleanup;
+            return -1;
     } else {
         if (virDomainVirtioSerialAddrNext(def, addrs, &ptr->addr.vioserial,
                                           allowZero) < 0)
-            goto cleanup;
+            return -1;
     }
 
     if (virDomainVirtioSerialAddrReserve(NULL, NULL, ptr, addrs) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 /* virDomainVirtioSerialAddrAutoAssign
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 3c4c7fd6d1..03d6ff141c 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -288,7 +288,6 @@ virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum,
                      size_t nvalues,
                      unsigned int *values)
 {
-    int ret = -1;
     size_t i;
 
     for (i = 0; i < nvalues; i++) {
@@ -300,15 +299,13 @@ virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum,
                            _("integer overflow on %s. Please contact the "
                              "libvirt development team at libvir-list at redhat.com"),
                            capsEnumName);
-            goto cleanup;
+            return -1;
         }
 
         capsEnum->values |= val;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -325,19 +322,15 @@ virDomainCapsEnumFormat(virBufferPtr buf,
                         const char *capsEnumName,
                         virDomainCapsValToStr valToStr)
 {
-    int ret = -1;
     size_t i;
 
-    if (!capsEnum->report) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (!capsEnum->report)
+        return 0;
 
     virBufferAsprintf(buf, "<enum name='%s'", capsEnumName);
     if (!capsEnum->values) {
         virBufferAddLit(buf, "/>\n");
-        ret = 0;
-        goto cleanup;
+        return 0;
     }
     virBufferAddLit(buf, ">\n");
     virBufferAdjustIndent(buf, 2);
@@ -354,9 +347,7 @@ virDomainCapsEnumFormat(virBufferPtr buf,
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</enum>\n");
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 80e19a15df..c3d5dc46f6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7072,7 +7072,6 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
 {
     g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
     g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
-    int ret = -1;
 
     if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) {
         virBufferAsprintf(buf, "<boot order='%u'", info->bootIndex);
@@ -7115,11 +7114,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
     }
 
     if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
-        info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
+        info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
         /* We're done here */
-        ret = 0;
-        goto cleanup;
-    }
+        return 0;
 
     virBufferAsprintf(&attrBuf, " type='%s'",
                       virDomainDeviceAddressTypeToString(info->type));
@@ -7214,12 +7211,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
     }
 
     if (virXMLFormatElement(buf, "address", &attrBuf, &childBuf) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
@@ -8396,10 +8390,10 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node,
 
     str = virXPathString("string(./rx/frames/@max)", ctxt);
     if (!str)
-        goto cleanup;
+        return NULL;
 
     if (VIR_ALLOC(ret) < 0)
-        goto cleanup;
+        return NULL;
 
     if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) {
         virReportError(VIR_ERR_XML_DETAIL,
@@ -8417,12 +8411,11 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node,
     }
     ret->rx_max_coalesced_frames = tmp;
 
- cleanup:
     return ret;
 
  error:
     VIR_FREE(ret);
-    goto cleanup;
+    return NULL;
 }
 
 static void
@@ -9837,7 +9830,6 @@ virDomainDiskDefParsePrivateData(xmlXPathContextPtr ctxt,
 {
     xmlNodePtr private_node = virXPathNode("./privateData", ctxt);
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
-    int ret = -1;
 
     if (!xmlopt ||
         !xmlopt->privateData.diskParse ||
@@ -9847,12 +9839,9 @@ virDomainDiskDefParsePrivateData(xmlXPathContextPtr ctxt,
     ctxt->node = private_node;
 
     if (xmlopt->privateData.diskParse(ctxt, disk) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -11309,7 +11298,6 @@ virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr def,
                                        xmlNodePtr node,
                                        xmlXPathContextPtr ctxt)
 {
-    int ret = -1;
     int tmpVal;
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     xmlNodePtr cur;
@@ -11323,7 +11311,7 @@ virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr def,
                 virReportError(VIR_ERR_XML_ERROR,
                                _("invalid reconnect enabled value: '%s'"),
                                tmp);
-                goto cleanup;
+                return -1;
             }
             def->enabled = tmpVal;
             VIR_FREE(tmp);
@@ -11335,20 +11323,18 @@ virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr def,
                     virReportError(VIR_ERR_XML_ERROR,
                                    _("invalid reconnect timeout value: '%s'"),
                                    tmp);
-                    goto cleanup;
+                    return -1;
                 }
             } else {
                 virReportError(VIR_ERR_XML_ERROR, "%s",
                                _("missing timeout for chardev with "
                                  "reconnect enabled"));
-                goto cleanup;
+                return -1;
             }
         }
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -12570,7 +12556,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
                               virSecurityLabelDefPtr* vmSeclabels,
                               int nvmSeclabels)
 {
-    int ret = -1;
     bool logParsed = false;
     bool protocolParsed = false;
     int sourceParsed = 0;
@@ -12685,13 +12670,11 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
         }
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 
  error:
     virDomainChrSourceDefClear(def);
-    goto cleanup;
+    return -1;
 }
 
 
@@ -13886,7 +13869,6 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     int enableVal;
     xmlNodePtr glNode;
-    int ret = -1;
     g_autofree char *fullscreen = virXMLPropString(node, "fullscreen");
     g_autofree char *enable = NULL;
 
@@ -13896,7 +13878,7 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
         if (virStringParseYesNo(fullscreen, &def->data.sdl.fullscreen) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("unknown fullscreen value '%s'"), fullscreen);
-            goto cleanup;
+            return -1;
         }
     } else {
         def->data.sdl.fullscreen = false;
@@ -13911,21 +13893,19 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
         if (!enable) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("sdl gl element missing enable"));
-            goto cleanup;
+            return -1;
         }
 
         enableVal = virTristateBoolTypeFromString(enable);
         if (enableVal < 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("unknown enable value '%s'"), enable);
-            goto cleanup;
+            return -1;
         }
         def->data.sdl.gl = enableVal;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -14961,7 +14941,6 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt,
                             virSysinfoBaseBoardDefPtr *baseBoard,
                             size_t *nbaseBoard)
 {
-    int ret = -1;
     size_t i, nboards = 0;
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     int n;
@@ -14969,10 +14948,10 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt,
     g_autofree xmlNodePtr *nodes = NULL;
 
     if ((n = virXPathNodeSet("./baseBoard", ctxt, &nodes)) < 0)
-        return ret;
+        return -1;
 
     if (n && VIR_ALLOC_N(boards, n) < 0)
-        goto cleanup;
+        return -1;
 
     for (i = 0; i < n; i++) {
         virSysinfoBaseBoardDefPtr def = boards + nboards;
@@ -15002,9 +14981,8 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt,
 
     *baseBoard = g_steal_pointer(&boards);
     *nbaseBoard = nboards;
-    ret = 0;
- cleanup:
-    return ret;
+
+    return 0;
 }
 
 
@@ -15941,7 +15919,6 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
                                  xmlXPathContextPtr ctxt,
                                  virDomainMemoryDefPtr def)
 {
-    int ret = -1;
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     ctxt->node = node;
     g_autofree char *nodemask = NULL;
@@ -15950,17 +15927,17 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
     case VIR_DOMAIN_MEMORY_MODEL_DIMM:
         if (virDomainParseMemory("./pagesize", "./pagesize/@unit", ctxt,
                                  &def->pagesize, false, false) < 0)
-            goto cleanup;
+            return -1;
 
         if ((nodemask = virXPathString("string(./nodemask)", ctxt))) {
             if (virBitmapParse(nodemask, &def->sourceNodes,
                                VIR_DOMAIN_CPUMASK_LEN) < 0)
-                goto cleanup;
+                return -1;
 
             if (virBitmapIsAllClear(def->sourceNodes)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("Invalid value of 'nodemask': %s"), nodemask);
-                goto cleanup;
+                return -1;
             }
         }
         break;
@@ -15969,12 +15946,12 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
         if (!(def->nvdimmPath = virXPathString("string(./path)", ctxt))) {
             virReportError(VIR_ERR_XML_DETAIL, "%s",
                            _("path is required for model 'nvdimm'"));
-            goto cleanup;
+            return -1;
         }
 
         if (virDomainParseMemory("./alignsize", "./alignsize/@unit", ctxt,
                                  &def->alignsize, false, false) < 0)
-            goto cleanup;
+            return -1;
 
         if (virXPathBoolean("boolean(./pmem)", ctxt))
             def->nvdimmPmem = true;
@@ -15986,10 +15963,7 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
         break;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -15998,7 +15972,6 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node,
                                  xmlXPathContextPtr ctxt,
                                  virDomainMemoryDefPtr def)
 {
-    int ret = -1;
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     ctxt->node = node;
     int rv;
@@ -16010,38 +15983,35 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node,
         (rv == 0 && def->targetNode < 0)) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("invalid value of memory device node"));
-        goto cleanup;
+        return -1;
     }
 
     if (virDomainParseMemory("./size", "./size/@unit", ctxt,
                              &def->size, true, false) < 0)
-        goto cleanup;
+        return -1;
 
     if (def->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
         if (virDomainParseMemory("./label/size", "./label/size/@unit", ctxt,
                                  &def->labelsize, false, false) < 0)
-            goto cleanup;
+            return -1;
 
         if (def->labelsize && def->labelsize < 128) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("nvdimm label must be at least 128KiB"));
-            goto cleanup;
+            return -1;
         }
 
         if (def->labelsize >= def->size) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("label size must be smaller than NVDIMM size"));
-            goto cleanup;
+            return -1;
         }
 
         if (virXPathBoolean("boolean(./readonly)", ctxt))
             def->readonly = true;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -16192,7 +16162,6 @@ static virDomainIOMMUDefPtr
 virDomainIOMMUDefParseXML(xmlNodePtr node,
                           xmlXPathContextPtr ctxt)
 {
-    virDomainIOMMUDefPtr ret = NULL;
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     xmlNodePtr driver;
     int val;
@@ -16202,17 +16171,17 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
     ctxt->node = node;
 
     if (VIR_ALLOC(iommu) < 0)
-        goto cleanup;
+        return NULL;
 
     if (!(tmp = virXMLPropString(node, "model"))) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("missing model for IOMMU device"));
-        goto cleanup;
+        return NULL;
     }
 
     if ((val = virDomainIOMMUModelTypeFromString(tmp)) < 0) {
         virReportError(VIR_ERR_XML_ERROR, _("unknown IOMMU model: %s"), tmp);
-        goto cleanup;
+        return NULL;
     }
 
     iommu->model = val;
@@ -16222,7 +16191,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
         if ((tmp = virXMLPropString(driver, "intremap"))) {
             if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
                 virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %s"), tmp);
-                goto cleanup;
+                return NULL;
             }
             iommu->intremap = val;
         }
@@ -16231,7 +16200,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
         if ((tmp = virXMLPropString(driver, "caching_mode"))) {
             if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
                 virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode value: %s"), tmp);
-                goto cleanup;
+                return NULL;
             }
             iommu->caching_mode = val;
         }
@@ -16239,7 +16208,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
         if ((tmp = virXMLPropString(driver, "iotlb"))) {
             if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
                 virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: %s"), tmp);
-                goto cleanup;
+                return NULL;
             }
             iommu->iotlb = val;
         }
@@ -16248,16 +16217,13 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
         if ((tmp = virXMLPropString(driver, "eim"))) {
             if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
                 virReportError(VIR_ERR_XML_ERROR, _("unknown eim value: %s"), tmp);
-                goto cleanup;
+                return NULL;
             }
             iommu->eim = val;
         }
     }
 
-    ret = g_steal_pointer(&iommu);
-
- cleanup:
-    return ret;
+    return g_steal_pointer(&iommu);
 }
 
 
@@ -16267,7 +16233,6 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
                           xmlXPathContextPtr ctxt,
                           unsigned int flags)
 {
-    virDomainVsockDefPtr ret = NULL;
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     xmlNodePtr cid;
     int val;
@@ -16277,12 +16242,12 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
     ctxt->node = node;
 
     if (!(vsock = virDomainVsockDefNew(xmlopt)))
-        goto cleanup;
+        return NULL;
 
     if ((tmp = virXMLPropString(node, "model"))) {
         if ((val = virDomainVsockModelTypeFromString(tmp)) < 0) {
             virReportError(VIR_ERR_XML_ERROR, _("unknown vsock model: %s"), tmp);
-            goto cleanup;
+            return NULL;
         }
         vsock->model = val;
     }
@@ -16297,7 +16262,7 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
                 virReportError(VIR_ERR_XML_DETAIL,
                                _("'cid' attribute must be a positive number: %s"),
                                tmp);
-                goto cleanup;
+                return NULL;
             }
         }
 
@@ -16308,19 +16273,16 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
                 virReportError(VIR_ERR_XML_DETAIL,
                                _("'auto' attribute can be 'yes' or 'no': %s"),
                                tmp);
-                goto cleanup;
+                return NULL;
             }
             vsock->auto_cid = val;
         }
     }
 
     if (virDomainDeviceInfoParseXML(xmlopt, node, &vsock->info, flags) < 0)
-        goto cleanup;
-
-    ret = g_steal_pointer(&vsock);
+        return NULL;
 
- cleanup:
-    return ret;
+    return g_steal_pointer(&vsock);
 }
 
 virDomainDeviceDefPtr
@@ -18480,7 +18442,6 @@ virDomainHugepagesParseXML(xmlNodePtr node,
                            xmlXPathContextPtr ctxt,
                            virDomainHugePagePtr hugepage)
 {
-    int ret = -1;
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     g_autofree char *nodeset = NULL;
 
@@ -18488,29 +18449,27 @@ virDomainHugepagesParseXML(xmlNodePtr node,
 
     if (virDomainParseMemory("./@size", "./@unit", ctxt,
                              &hugepage->size, true, false) < 0)
-        goto cleanup;
+        return -1;
 
     if (!hugepage->size) {
         virReportError(VIR_ERR_XML_DETAIL, "%s",
                        _("hugepage size can't be zero"));
-        goto cleanup;
+        return -1;
     }
 
     if ((nodeset = virXMLPropString(node, "nodeset"))) {
         if (virBitmapParse(nodeset, &hugepage->nodemask,
                            VIR_DOMAIN_CPUMASK_LEN) < 0)
-            goto cleanup;
+            return -1;
 
         if (virBitmapIsAllClear(hugepage->nodemask)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Invalid value of 'nodeset': %s"), nodeset);
-            goto cleanup;
+            return -1;
         }
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -19159,7 +19118,6 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt,
     unsigned int cache;
     int type;
     unsigned long long size;
-    int ret = -1;
     g_autofree char *tmp = NULL;
 
     ctxt->node = node;
@@ -19168,13 +19126,13 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt,
     if (!tmp) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("Missing cachetune attribute 'id'"));
-        goto cleanup;
+        return -1;
     }
     if (virStrToLong_uip(tmp, NULL, 10, &cache) < 0) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("Invalid cachetune attribute 'id' value '%s'"),
                        tmp);
-        goto cleanup;
+        return -1;
     }
     VIR_FREE(tmp);
 
@@ -19182,13 +19140,13 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt,
     if (!tmp) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("Missing cachetune attribute 'level'"));
-        goto cleanup;
+        return -1;
     }
     if (virStrToLong_uip(tmp, NULL, 10, &level) < 0) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("Invalid cachetune attribute 'level' value '%s'"),
                        tmp);
-        goto cleanup;
+        return -1;
     }
     VIR_FREE(tmp);
 
@@ -19196,27 +19154,25 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt,
     if (!tmp) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("Missing cachetune attribute 'type'"));
-        goto cleanup;
+        return -1;
     }
     type = virCacheTypeFromString(tmp);
     if (type < 0) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("Invalid cachetune attribute 'type' value '%s'"),
                        tmp);
-        goto cleanup;
+        return -1;
     }
 
     if (virDomainParseScaledValue("./@size", "./@unit",
                                   ctxt, &size, 1024,
                                   ULLONG_MAX, true) < 0)
-        goto cleanup;
+        return -1;
 
     if (virResctrlAllocSetCacheSize(alloc, level, type, cache, size) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -19611,7 +19567,6 @@ virDomainMemorytuneDefParseMemory(xmlXPathContextPtr ctxt,
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     unsigned int id;
     unsigned int bandwidth;
-    int ret = -1;
     g_autofree char *tmp = NULL;
 
     ctxt->node = node;
@@ -19620,13 +19575,13 @@ virDomainMemorytuneDefParseMemory(xmlXPathContextPtr ctxt,
     if (!tmp) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("Missing memorytune attribute 'id'"));
-        goto cleanup;
+        return -1;
     }
     if (virStrToLong_uip(tmp, NULL, 10, &id) < 0) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("Invalid memorytune attribute 'id' value '%s'"),
                        tmp);
-        goto cleanup;
+        return -1;
     }
     VIR_FREE(tmp);
 
@@ -19634,20 +19589,18 @@ virDomainMemorytuneDefParseMemory(xmlXPathContextPtr ctxt,
     if (!tmp) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("Missing memorytune attribute 'bandwidth'"));
-        goto cleanup;
+        return -1;
     }
     if (virStrToLong_uip(tmp, NULL, 10, &bandwidth) < 0) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("Invalid memorytune attribute 'bandwidth' value '%s'"),
                        tmp);
-        goto cleanup;
+        return -1;
     }
     if (virResctrlAllocSetMemoryBandwidth(alloc, id, bandwidth) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -24074,7 +24027,6 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
                                      virDomainXMLOptionPtr xmlopt)
 {
     g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
-    int ret = -1;
 
     if (!(flags & VIR_DOMAIN_DEF_FORMAT_STATUS) ||
         !xmlopt || !xmlopt->privateData.storageFormat)
@@ -24083,15 +24035,12 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
     virBufferSetChildIndent(&childBuf, buf);
 
     if (xmlopt->privateData.storageFormat(src, &childBuf) < 0)
-        goto cleanup;
+        return -1;
 
     if (virXMLFormatElement(buf, "privateData", NULL, &childBuf) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -24774,18 +24723,17 @@ virDomainFSDefFormat(virBufferPtr buf,
     const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy);
     const char *src = def->src->path;
     g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER;
-    int ret = -1;
 
     if (!type) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unexpected filesystem type %d"), def->type);
-        goto cleanup;
+        return -1;
     }
 
    if (!accessmode) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unexpected accessmode %d"), def->accessmode);
-        goto cleanup;
+        return -1;
     }
 
     virBufferAsprintf(buf,
@@ -24814,7 +24762,7 @@ virDomainFSDefFormat(virBufferPtr buf,
     virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
 
     if (virBufferCheckError(&driverBuf) < 0)
-        goto cleanup;
+        return -1;
 
     if (virBufferUse(&driverBuf)) {
         virBufferAddLit(buf, "<driver");
@@ -24864,7 +24812,7 @@ virDomainFSDefFormat(virBufferPtr buf,
         virBufferAddLit(buf, "<readonly/>\n");
 
     if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
-        goto cleanup;
+        return -1;
 
     if (def->space_hard_limit)
         virBufferAsprintf(buf, "<space_hard_limit unit='bytes'>"
@@ -24876,10 +24824,7 @@ virDomainFSDefFormat(virBufferPtr buf,
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</filesystem>\n");
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -26006,14 +25951,13 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
     const char *mode = virDomainSmartcardTypeToString(def->type);
     g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
     size_t i;
-    int ret = -1;
 
     virBufferSetChildIndent(&childBuf, buf);
 
     if (!mode) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unexpected smartcard type %d"), def->type);
-        goto cleanup;
+        return -1;
     }
 
     switch (def->type) {
@@ -26031,24 +25975,24 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
 
     case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
         if (virDomainChrSourceDefFormat(&childBuf, def->data.passthru, flags) < 0)
-            goto cleanup;
+            return -1;
         break;
 
     default:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unexpected smartcard type %d"), def->type);
-        goto cleanup;
+        return -1;
     }
     if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
-        goto cleanup;
+        return -1;
 
     if (virBufferCheckError(&childBuf) < 0)
-        goto cleanup;
+        return -1;
 
     virBufferAsprintf(buf, "<smartcard mode='%s'", mode);
     if (def->type == VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH &&
         virDomainChrAttrsDefFormat(buf, def->data.passthru, false) < 0) {
-        goto cleanup;
+        return -1;
     }
 
     if (virBufferUse(&childBuf)) {
@@ -26059,10 +26003,7 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
         virBufferAddLit(buf, "/>\n");
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
@@ -26139,24 +26080,23 @@ virDomainSoundDefFormat(virBufferPtr buf,
     const char *model = virDomainSoundModelTypeToString(def->model);
     g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
     size_t i;
-    int ret = -1;
 
     virBufferSetChildIndent(&childBuf, buf);
 
     if (!model) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unexpected sound model %d"), def->model);
-        goto cleanup;
+        return -1;
     }
 
     for (i = 0; i < def->ncodecs; i++)
         virDomainSoundCodecDefFormat(&childBuf, def->codecs[i]);
 
     if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
-        goto cleanup;
+        return -1;
 
     if (virBufferCheckError(&childBuf) < 0)
-        goto cleanup;
+        return -1;
 
     virBufferAsprintf(buf, "<sound model='%s'",  model);
     if (virBufferUse(&childBuf)) {
@@ -26167,10 +26107,7 @@ virDomainSoundDefFormat(virBufferPtr buf,
         virBufferAddLit(buf, "/>\n");
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -26532,19 +26469,18 @@ virDomainVideoDefFormat(virBufferPtr buf,
 {
     const char *model = virDomainVideoTypeToString(def->type);
     g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER;
-    int ret = -1;
 
     if (!model) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unexpected video model %d"), def->type);
-        goto cleanup;
+        return -1;
     }
 
     virBufferAddLit(buf, "<video>\n");
     virBufferAdjustIndent(buf, 2);
     virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
     if (virBufferCheckError(&driverBuf) < 0)
-        goto cleanup;
+        return -1;
     if (virBufferUse(&driverBuf) || (def->driver && def->driver->vgaconf) ||
         def->backend != VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT) {
         virBufferAddLit(buf, "<driver");
@@ -26586,15 +26522,12 @@ virDomainVideoDefFormat(virBufferPtr buf,
     }
 
     if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
-        goto cleanup;
+        return -1;
 
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</video>\n");
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
@@ -27606,40 +27539,37 @@ virDomainCachetuneDefFormat(virBufferPtr buf,
 {
     g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER;
     size_t i = 0;
-    int ret = -1;
     g_autofree char *vcpus = NULL;
 
     virBufferSetChildIndent(&childrenBuf, buf);
     if (virResctrlAllocForeachCache(resctrl->alloc,
                                     virDomainCachetuneDefFormatHelper,
                                     &childrenBuf) < 0)
-        goto cleanup;
+        return -1;
 
     for (i = 0; i < resctrl->nmonitors; i++) {
         if (virDomainResctrlMonDefFormatHelper(resctrl->monitors[i],
                                                VIR_RESCTRL_MONITOR_TYPE_CACHE,
                                                &childrenBuf) < 0)
-            goto cleanup;
+            return -1;
     }
 
     if (virBufferCheckError(&childrenBuf) < 0)
-        goto cleanup;
+        return -1;
 
-    if (!virBufferUse(&childrenBuf)) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (!virBufferUse(&childrenBuf))
+        return 0;
 
     vcpus = virBitmapFormat(resctrl->vcpus);
     if (!vcpus)
-        goto cleanup;
+        return -1;
 
     virBufferAsprintf(buf, "<cachetune vcpus='%s'", vcpus);
 
     if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
         const char *alloc_id = virResctrlAllocGetID(resctrl->alloc);
         if (!alloc_id)
-            goto cleanup;
+            return -1;
 
         virBufferAsprintf(buf, " id='%s'", alloc_id);
     }
@@ -27648,9 +27578,7 @@ virDomainCachetuneDefFormat(virBufferPtr buf,
     virBufferAddBuffer(buf, &childrenBuf);
     virBufferAddLit(buf, "</cachetune>\n");
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -27674,33 +27602,30 @@ virDomainMemorytuneDefFormat(virBufferPtr buf,
                             unsigned int flags)
 {
     g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER;
-    int ret = -1;
     g_autofree char *vcpus = NULL;
 
     virBufferSetChildIndent(&childrenBuf, buf);
     if (virResctrlAllocForeachMemory(resctrl->alloc,
                                      virDomainMemorytuneDefFormatHelper,
                                      &childrenBuf) < 0)
-        goto cleanup;
+        return -1;
 
     if (virBufferCheckError(&childrenBuf) < 0)
-        goto cleanup;
+        return -1;
 
-    if (!virBufferUse(&childrenBuf)) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (!virBufferUse(&childrenBuf))
+        return 0;
 
     vcpus = virBitmapFormat(resctrl->vcpus);
     if (!vcpus)
-        goto cleanup;
+        return -1;
 
     virBufferAsprintf(buf, "<memorytune vcpus='%s'", vcpus);
 
     if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
         const char *alloc_id = virResctrlAllocGetID(resctrl->alloc);
         if (!alloc_id)
-            goto cleanup;
+            return -1;
 
         virBufferAsprintf(buf, " id='%s'", alloc_id);
     }
@@ -27709,9 +27634,7 @@ virDomainMemorytuneDefFormat(virBufferPtr buf,
     virBufferAddBuffer(buf, &childrenBuf);
     virBufferAddLit(buf, "</memorytune>\n");
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
@@ -27721,7 +27644,6 @@ virDomainCputuneDefFormat(virBufferPtr buf,
 {
     size_t i;
     g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER;
-    int ret = -1;
 
     virBufferSetChildIndent(&childrenBuf, buf);
 
@@ -27769,7 +27691,7 @@ virDomainCputuneDefFormat(virBufferPtr buf,
             continue;
 
         if (!(cpumask = virBitmapFormat(vcpu->cpumask)))
-            goto cleanup;
+            return -1;
 
         virBufferAsprintf(&childrenBuf,
                           "<vcpupin vcpu='%zu' cpuset='%s'/>\n", i, cpumask);
@@ -27782,7 +27704,7 @@ virDomainCputuneDefFormat(virBufferPtr buf,
         virBufferAddLit(&childrenBuf, "<emulatorpin ");
 
         if (!(cpumask = virBitmapFormat(def->cputune.emulatorpin)))
-            goto cleanup;
+            return -1;
 
         virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask);
         VIR_FREE(cpumask);
@@ -27799,7 +27721,7 @@ virDomainCputuneDefFormat(virBufferPtr buf,
                           def->iothreadids[i]->iothread_id);
 
         if (!(cpumask = virBitmapFormat(def->iothreadids[i]->cpumask)))
-            goto cleanup;
+            return -1;
 
         virBufferAsprintf(&childrenBuf, "cpuset='%s'/>\n", cpumask);
         VIR_FREE(cpumask);
@@ -27837,10 +27759,7 @@ virDomainCputuneDefFormat(virBufferPtr buf,
         virBufferAddLit(buf, "</cputune>\n");
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -27911,7 +27830,6 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
     g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
     g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
     g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
-    int ret = -1;
 
     virBufferSetChildIndent(&childBuf, buf);
 
@@ -27933,18 +27851,15 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
     }
 
     if (virXMLFormatElement(&childBuf, "driver", &driverAttrBuf, NULL) < 0)
-        goto cleanup;
+        return -1;
 
     virBufferAsprintf(&attrBuf, " model='%s'",
                       virDomainIOMMUModelTypeToString(iommu->model));
 
     if (virXMLFormatElement(buf, "iommu", &attrBuf, &childBuf) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -27953,7 +27868,6 @@ virDomainMemtuneFormat(virBufferPtr buf,
                        const virDomainMemtune *mem)
 {
     g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
-    int ret = -1;
 
     virBufferSetChildIndent(&childBuf, buf);
 
@@ -27979,7 +27893,7 @@ virDomainMemtuneFormat(virBufferPtr buf,
     }
 
     if (virXMLFormatElement(buf, "memtune", NULL, &childBuf) < 0)
-        goto cleanup;
+        return -1;
 
     virBufferSetChildIndent(&childBuf, buf);
 
@@ -28002,11 +27916,9 @@ virDomainMemtuneFormat(virBufferPtr buf,
         virBufferAddLit(&childBuf, "<discard/>\n");
 
     if (virXMLFormatElement(buf, "memoryBacking", NULL, &childBuf) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -28017,7 +27929,6 @@ virDomainVsockDefFormat(virBufferPtr buf,
     g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
     g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
     g_auto(virBuffer) cidAttrBuf = VIR_BUFFER_INITIALIZER;
-    int ret = -1;
 
     if (vsock->model) {
         virBufferAsprintf(&attrBuf, " model='%s'",
@@ -28033,18 +27944,15 @@ virDomainVsockDefFormat(virBufferPtr buf,
     if (vsock->guest_cid != 0)
         virBufferAsprintf(&cidAttrBuf, " address='%u'", vsock->guest_cid);
     if (virXMLFormatElement(&childBuf, "cid", &cidAttrBuf, NULL) < 0)
-        goto cleanup;
+        return -1;
 
     if (virDomainDeviceInfoFormat(&childBuf, &vsock->info, 0) < 0)
-        goto cleanup;
+        return -1;
 
     if (virXMLFormatElement(buf, "vsock", &attrBuf, &childBuf) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 
diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_conf.c
index 9af2173b7b..dd1a63a5cf 100644
--- a/src/conf/netdev_bandwidth_conf.c
+++ b/src/conf/netdev_bandwidth_conf.c
@@ -264,15 +264,11 @@ virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
                          unsigned int class_id,
                          virBufferPtr buf)
 {
-    int ret = -1;
-
     if (!buf)
-        goto cleanup;
+        return -1;
 
-    if (!def) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (!def)
+        return 0;
 
     virBufferAddLit(buf, "<bandwidth");
     if (class_id)
@@ -281,14 +277,11 @@ virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
     virBufferAdjustIndent(buf, 2);
     if (virNetDevBandwidthRateFormat(def->in, buf, "inbound") < 0 ||
         virNetDevBandwidthRateFormat(def->out, buf, "outbound") < 0)
-        goto cleanup;
+        return -1;
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</bandwidth>\n");
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 void
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 7f8e43b25c..5d62231b0f 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -3062,18 +3062,17 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
                                unsigned int fflags G_GNUC_UNUSED)
 {
     size_t i;
-    int ret = -1;
     virNetworkIPDefPtr ipdef = virNetworkIPDefByIndex(def, parentIndex);
     virSocketAddrRange range;
 
     memset(&range, 0, sizeof(range));
 
     if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "range") < 0)
-        goto cleanup;
+        return -1;
 
     /* ipdef is the ip element that needs its range array updated */
     if (!ipdef)
-        goto cleanup;
+        return -1;
 
     /* parse the xml into a virSocketAddrRange */
     if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) {
@@ -3081,18 +3080,18 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("dhcp ranges cannot be modified, "
                          "only added or deleted"));
-        goto cleanup;
+        return -1;
     }
 
     if (virSocketAddrRangeParseXML(def->name, ipdef, ctxt->node, &range) < 0)
-        goto cleanup;
+        return -1;
 
     if (VIR_SOCKET_ADDR_FAMILY(&ipdef->address)
         != VIR_SOCKET_ADDR_FAMILY(&range.start)) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("the address family of a dhcp range must match "
                          "the address family of the dhcp element's parent"));
-        goto cleanup;
+        return -1;
     }
 
     /* check if an entry with same name/address/ip already exists */
@@ -3107,7 +3106,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
         (command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST)) {
 
         if (virNetworkDefUpdateCheckMultiDHCP(def, ipdef) < 0)
-            goto cleanup;
+            return -1;
 
         if (i < ipdef->nranges) {
             char *startip = virSocketAddrFormat(&range.start);
@@ -3122,7 +3121,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
                            endip ? endip : "unknown");
             VIR_FREE(startip);
             VIR_FREE(endip);
-            goto cleanup;
+            return -1;
         }
 
         /* add to beginning/end of list */
@@ -3130,14 +3129,14 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
                                command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST
                                ? 0 : ipdef->nranges,
                                ipdef->nranges, range) < 0)
-            goto cleanup;
+            return -1;
     } else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
 
         if (i == ipdef->nranges) {
             virReportError(VIR_ERR_OPERATION_INVALID,
                            _("couldn't locate a matching dhcp range entry "
                              "in network '%s'"), def->name);
-            goto cleanup;
+            return -1;
         }
 
         /* remove it */
@@ -3146,12 +3145,10 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
 
     } else {
         virNetworkDefUpdateUnknownCommand(command);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 7eb52dbf85..5ced615f1f 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2115,7 +2115,6 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
                      char **wwpn)
 {
     virNodeDevCapsDefPtr cap = NULL;
-    int ret = -1;
 
     cap = def->caps;
     while (cap != NULL) {
@@ -2132,12 +2131,10 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
     if (cap == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("Device is not a fibre channel HBA"));
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -2504,7 +2501,7 @@ virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath,
     ret = virPCIGetPhysicalFunction(sysfsPath,
                                     &pci_dev->physical_function);
     if (ret < 0)
-        goto cleanup;
+        return ret;
 
     if (pci_dev->physical_function)
         pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
@@ -2513,13 +2510,12 @@ virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath,
                                     &pci_dev->num_virtual_functions,
                                     &pci_dev->max_virtual_functions);
     if (ret < 0)
-        goto cleanup;
+        return ret;
 
     if (pci_dev->num_virtual_functions > 0 ||
         pci_dev->max_virtual_functions > 0)
         pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
 
- cleanup:
     return ret;
 }
 
@@ -2528,7 +2524,7 @@ static int
 virNodeDeviceGetPCIIOMMUGroupCaps(virNodeDevCapPCIDevPtr pci_dev)
 {
     size_t i;
-    int tmpGroup, ret = -1;
+    int tmpGroup;
     virPCIDeviceAddress addr;
 
     /* this could be a refresh, so clear out the old data */
@@ -2545,23 +2541,19 @@ virNodeDeviceGetPCIIOMMUGroupCaps(virNodeDevCapPCIDevPtr pci_dev)
     tmpGroup = virPCIDeviceAddressGetIOMMUGroupNum(&addr);
     if (tmpGroup == -1) {
         /* error was already reported */
-        goto cleanup;
+        return -1;
     }
-    if (tmpGroup == -2) {
+    if (tmpGroup == -2)
         /* -2 return means there is no iommu_group data */
-        ret = 0;
-        goto cleanup;
-    }
+        return 0;
     if (tmpGroup >= 0) {
         if (virPCIDeviceAddressGetIOMMUGroupAddresses(&addr, &pci_dev->iommuGroupDevices,
                                                       &pci_dev->nIommuGroupDevices) < 0)
-            goto cleanup;
+            return -1;
         pci_dev->iommuGroupNumber = tmpGroup;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
index 6720d5620d..4bc22ec7d9 100644
--- a/src/conf/numa_conf.c
+++ b/src/conf/numa_conf.c
@@ -390,24 +390,22 @@ int virDomainNumatuneGetMode(virDomainNumaPtr numatune,
                              int cellid,
                              virDomainNumatuneMemMode *mode)
 {
-    int ret = -1;
     virDomainNumatuneMemMode tmp_mode;
 
     if (!numatune)
-        return ret;
+        return -1;
 
     if (virDomainNumatuneNodeSpecified(numatune, cellid))
         tmp_mode = numatune->mem_nodes[cellid].mode;
     else if (numatune->memory.specified)
         tmp_mode = numatune->memory.mode;
     else
-        goto cleanup;
+        return -1;
 
     if (mode)
         *mode = tmp_mode;
-    ret = 0;
- cleanup:
-    return ret;
+
+    return 0;
 }
 
 virBitmapPtr
@@ -498,8 +496,6 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
                      int mode,
                      virBitmapPtr nodeset)
 {
-    int ret = -1;
-
     /* No need to do anything in this case */
     if (mode == -1 && placement == -1 && !nodeset)
         return 0;
@@ -517,7 +513,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("Unsupported numatune mode '%d'"),
                        mode);
-        goto cleanup;
+        return -1;
     }
 
     if (placement != -1 &&
@@ -525,7 +521,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("Unsupported numatune placement '%d'"),
                        mode);
-        goto cleanup;
+        return -1;
     }
 
     if (mode != -1)
@@ -534,7 +530,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
     if (nodeset) {
         virBitmapFree(numa->memory.nodeset);
         if (!(numa->memory.nodeset = virBitmapNewCopy(nodeset)))
-            goto cleanup;
+            return -1;
         if (placement == -1)
             placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC;
     }
@@ -551,7 +547,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("nodeset for NUMA memory tuning must be set "
                          "if 'placement' is 'static'"));
-        goto cleanup;
+        return -1;
     }
 
     /* setting nodeset when placement auto is invalid */
@@ -566,10 +562,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa,
 
     numa->memory.specified = true;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 static bool
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index cd97eb87ac..5c9d6ee811 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2087,13 +2087,11 @@ virNWFilterIncludeParse(xmlNodePtr cur)
     if (!ret->params)
         goto err_exit;
 
- cleanup:
     return ret;
 
  err_exit:
     virNWFilterIncludeDefFree(ret);
-    ret = NULL;
-    goto cleanup;
+    return NULL;
 }
 
 
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index f212eefe25..58ce29c101 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -343,17 +343,14 @@ int
 virStoragePoolOptionsPoolTypeSetXMLNamespace(int type,
                                              virXMLNamespacePtr ns)
 {
-    int ret = -1;
     virStoragePoolTypeInfoPtr backend = virStoragePoolTypeInfoLookup(type);
 
     if (!backend)
-        goto cleanup;
+        return -1;
 
     backend->poolOptions.ns = *ns;
-    ret = 0;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index e7017bffa9..c958c678ce 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -766,14 +766,13 @@ virNetworkObjConfigChangeSetup(virNetworkObjPtr obj,
                                unsigned int flags)
 {
     bool isActive;
-    int ret = -1;
 
     isActive = virNetworkObjIsActive(obj);
 
     if (!isActive && (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE)) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("network is not running"));
-        goto cleanup;
+        return -1;
     }
 
     if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) {
@@ -781,18 +780,16 @@ virNetworkObjConfigChangeSetup(virNetworkObjPtr obj,
             virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                            _("cannot change persistent config of a "
                              "transient network"));
-            goto cleanup;
+            return -1;
         }
         /* this should already have been done by the driver, but do it
          * anyway just in case.
          */
         if (isActive && (virNetworkObjSetDefTransient(obj, false, xmlopt) < 0))
-            goto cleanup;
+            return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -1676,10 +1673,9 @@ virNetworkObjLookupPort(virNetworkObjPtr net,
         virReportError(VIR_ERR_NO_NETWORK_PORT,
                        _("Network port with UUID %s does not exist"),
                        uuidstr);
-        goto cleanup;
+        return NULL;
     }
 
- cleanup:
     return ret;
 }
 
diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index ebf6ca7680..81c9f2c346 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -732,14 +732,13 @@ virSecretObjGetValue(virSecretObjPtr obj)
         virUUIDFormat(def->uuid, uuidstr);
         virReportError(VIR_ERR_NO_SECRET,
                        _("secret '%s' does not have a value"), uuidstr);
-        goto cleanup;
+        return NULL;
     }
 
     if (VIR_ALLOC_N(ret, obj->value_size) < 0)
-        goto cleanup;
+        return NULL;
     memcpy(ret, obj->value, obj->value_size);
 
- cleanup:
     return ret;
 }
 
-- 
2.21.0




More information about the libvir-list mailing list