[PATCH] lib: Drop needless one line labels

Daniel Henrique Barboza danielhb413 at gmail.com
Mon Nov 15 09:29:07 UTC 2021



On 11/12/21 13:22, Michal Privoznik wrote:
> In some cases we have a label that contains nothing but a return
> statement. The amount of such labels rises as we use automagic
> cleanup. Anyway, such labels are pointless and can be dropped.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---


Reviewed-by: Daniel Henrique Barboza <danielhb413 at gmail.com>

>   examples/c/domain/dommigrate.c       |  6 +-
>   src/conf/domain_conf.c               | 70 +++++++++-----------
>   src/conf/netdev_vport_profile_conf.c | 33 +++++-----
>   src/conf/storage_conf.c              | 12 ++--
>   src/conf/storage_source_conf.c       | 15 ++---
>   src/conf/virsavecookie.c             |  3 +-
>   src/hypervisor/virhostdev.c          |  4 +-
>   src/libxl/libxl_migration.c          |  5 +-
>   src/libxl/xen_xl.c                   |  9 +--
>   src/openvz/openvz_driver.c           |  5 +-
>   src/qemu/qemu_capabilities.c         |  5 +-
>   src/qemu/qemu_monitor_json.c         | 16 ++---
>   src/qemu/qemu_snapshot.c             | 21 +++---
>   src/qemu/qemu_virtiofs.c             | 22 +++----
>   src/rpc/virnetlibsshsession.c        | 10 +--
>   src/storage/storage_backend_iscsi.c  | 13 ++--
>   src/test/test_driver.c               |  5 +-
>   src/util/vircgroup.c                 |  4 +-
>   src/util/vircgroupv1.c               | 24 +++----
>   src/util/virdnsmasq.c                | 42 +++++-------
>   src/util/virhostcpu.c                | 11 ++--
>   tests/domainconftest.c               |  5 +-
>   tests/qemuxml2argvtest.c             | 11 +---
>   tests/virpcitest.c                   | 15 ++---
>   tools/virsh-domain.c                 |  8 +--
>   tools/virsh-host.c                   |  6 +-
>   tools/virsh-nodedev.c                | 45 +++++--------
>   tools/virsh-volume.c                 | 96 +++++++++++-----------------
>   28 files changed, 199 insertions(+), 322 deletions(-)
> 
> diff --git a/examples/c/domain/dommigrate.c b/examples/c/domain/dommigrate.c
> index 3d32ada6d3..07a947e869 100644
> --- a/examples/c/domain/dommigrate.c
> +++ b/examples/c/domain/dommigrate.c
> @@ -42,7 +42,7 @@ main(int argc, char *argv[])
>   
>       if (argc < 4) {
>           usage(argv[0]);
> -        goto out;
> +        return EXIT_FAILURE;
>       }
>   
>       src_uri = argv[1];
> @@ -54,7 +54,7 @@ main(int argc, char *argv[])
>       if (!conn) {
>           fprintf(stderr, "No connection to the source hypervisor: %s.\n",
>                   virGetLastErrorMessage());
> -        goto out;
> +        return EXIT_FAILURE;
>       }
>   
>       printf("Attempting to retrieve domain %s...\n", domname);
> @@ -79,7 +79,5 @@ main(int argc, char *argv[])
>       if (dom != NULL)
>           virDomainFree(dom);
>       virConnectClose(conn);
> -
> - out:
>       return ret;
>   }
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index da0c64b460..54218e76e7 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -18859,7 +18859,7 @@ virDomainDefParseIDs(virDomainDef *def,
>       /* Extract domain name */
>       if (!(def->name = virXPathString("string(./name[1])", ctxt))) {
>           virReportError(VIR_ERR_NO_NAME, NULL);
> -        goto error;
> +        return -1;
>       }
>   
>       /* Extract domain uuid. If both uuid and sysinfo/system/entry/uuid
> @@ -18870,50 +18870,47 @@ virDomainDefParseIDs(virDomainDef *def,
>           if (virUUIDGenerate(def->uuid) < 0) {
>               virReportError(VIR_ERR_INTERNAL_ERROR,
>                              "%s", _("Failed to generate UUID"));
> -            goto error;
> +            return -1;
>           }
>           *uuid_generated = true;
>       } else {
>           if (virUUIDParse(tmp, def->uuid) < 0) {
>               virReportError(VIR_ERR_INTERNAL_ERROR,
>                              "%s", _("malformed uuid element"));
> -            goto error;
> +            return -1;
>           }
>           VIR_FREE(tmp);
>       }
>   
>       /* Extract domain genid - a genid can either be provided or generated */
>       if ((n = virXPathNodeSet("./genid", ctxt, &nodes)) < 0)
> -        goto error;
> +        return -1;
>   
>       if (n > 0) {
>           if (n != 1) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("element 'genid' can only appear once"));
> -            goto error;
> +            return -1;
>           }
>           def->genidRequested = true;
>           if (!(tmp = virXPathString("string(./genid)", ctxt))) {
>               if (virUUIDGenerate(def->genid) < 0) {
>                   virReportError(VIR_ERR_INTERNAL_ERROR,
>                                  "%s", _("Failed to generate genid"));
> -                goto error;
> +                return -1;
>               }
>               def->genidGenerated = true;
>           } else {
>               if (virUUIDParse(tmp, def->genid) < 0) {
>                   virReportError(VIR_ERR_INTERNAL_ERROR,
>                                  "%s", _("malformed genid element"));
> -                goto error;
> +                return -1;
>               }
>               VIR_FREE(tmp);
>           }
>       }
>       VIR_FREE(nodes);
>       return 0;
> -
> - error:
> -    return -1;
>   }
>   
>   
> @@ -19002,20 +18999,20 @@ virDomainDefParseMemory(virDomainDef *def,
>       /* Extract domain memory */
>       if (virDomainParseMemory("./memory[1]", NULL, ctxt,
>                                &def->mem.total_memory, false, true) < 0)
> -        goto error;
> +        return -1;
>   
>       if (virDomainParseMemory("./currentMemory[1]", NULL, ctxt,
>                                &def->mem.cur_balloon, false, true) < 0)
> -        goto error;
> +        return -1;
>   
>       if (virDomainParseMemory("./maxMemory[1]", NULL, ctxt,
>                                &def->mem.max_memory, false, false) < 0)
> -        goto error;
> +        return -1;
>   
>       if (virXPathUInt("string(./maxMemory[1]/@slots)", ctxt, &def->mem.memory_slots) == -2) {
>           virReportError(VIR_ERR_XML_ERROR, "%s",
>                          _("Failed to parse memory slot count"));
> -        goto error;
> +        return -1;
>       }
>   
>       /* and info about it */
> @@ -19023,7 +19020,7 @@ virDomainDefParseMemory(virDomainDef *def,
>           (def->mem.dump_core = virTristateSwitchTypeFromString(tmp)) <= 0) {
>           virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                          _("Invalid memory core dump attribute value '%s'"), tmp);
> -        goto error;
> +        return -1;
>       }
>       VIR_FREE(tmp);
>   
> @@ -19032,7 +19029,7 @@ virDomainDefParseMemory(virDomainDef *def,
>           if ((def->mem.source = virDomainMemorySourceTypeFromString(tmp)) <= 0) {
>               virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                              _("unknown memoryBacking/source/type '%s'"), tmp);
> -            goto error;
> +            return -1;
>           }
>           VIR_FREE(tmp);
>       }
> @@ -19042,7 +19039,7 @@ virDomainDefParseMemory(virDomainDef *def,
>           if ((def->mem.access = virDomainMemoryAccessTypeFromString(tmp)) <= 0) {
>               virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                              _("unknown memoryBacking/access/mode '%s'"), tmp);
> -            goto error;
> +            return -1;
>           }
>           VIR_FREE(tmp);
>       }
> @@ -19052,7 +19049,7 @@ virDomainDefParseMemory(virDomainDef *def,
>           if ((def->mem.allocation = virDomainMemoryAllocationTypeFromString(tmp)) <= 0) {
>               virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                              _("unknown memoryBacking/allocation/mode '%s'"), tmp);
> -            goto error;
> +            return -1;
>           }
>           VIR_FREE(tmp);
>       }
> @@ -19062,7 +19059,7 @@ virDomainDefParseMemory(virDomainDef *def,
>           if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, &nodes)) < 0) {
>               virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                              _("cannot extract hugepages nodes"));
> -            goto error;
> +            return -1;
>           }
>   
>           if (n) {
> @@ -19071,7 +19068,7 @@ virDomainDefParseMemory(virDomainDef *def,
>               for (i = 0; i < n; i++) {
>                   if (virDomainHugepagesParseXML(nodes[i], ctxt,
>                                                  &def->mem.hugepages[i]) < 0)
> -                    goto error;
> +                    return -1;
>                   def->mem.nhugepages++;
>               }
>   
> @@ -19093,9 +19090,6 @@ virDomainDefParseMemory(virDomainDef *def,
>           def->mem.discard = VIR_TRISTATE_BOOL_YES;
>   
>       return 0;
> -
> - error:
> -    return -1;
>   }
>   
>   
> @@ -19446,43 +19440,40 @@ virDomainDefLifecycleParse(virDomainDef *def,
>                                        &def->onReboot,
>                                        VIR_DOMAIN_LIFECYCLE_ACTION_RESTART,
>                                        virDomainLifecycleActionTypeFromString) < 0)
> -        goto error;
> +        return -1;
>   
>       if (virDomainEventActionParseXML(ctxt, "on_poweroff",
>                                        "string(./on_poweroff[1])",
>                                        &def->onPoweroff,
>                                        VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY,
>                                        virDomainLifecycleActionTypeFromString) < 0)
> -        goto error;
> +        return -1;
>   
>       if (virDomainEventActionParseXML(ctxt, "on_crash",
>                                        "string(./on_crash[1])",
>                                        &def->onCrash,
>                                        VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY,
>                                        virDomainLifecycleActionTypeFromString) < 0)
> -        goto error;
> +        return -1;
>   
>       if (virDomainEventActionParseXML(ctxt, "on_lockfailure",
>                                        "string(./on_lockfailure[1])",
>                                        &def->onLockFailure,
>                                        VIR_DOMAIN_LOCK_FAILURE_DEFAULT,
>                                        virDomainLockFailureTypeFromString) < 0)
> -        goto error;
> +        return -1;
>   
>       if (virDomainPMStateParseXML(ctxt,
>                                    "string(./pm/suspend-to-mem/@enabled)",
>                                    &def->pm.s3) < 0)
> -        goto error;
> +        return -1;
>   
>       if (virDomainPMStateParseXML(ctxt,
>                                    "string(./pm/suspend-to-disk/@enabled)",
>                                    &def->pm.s4) < 0)
> -        goto error;
> +        return -1;
>   
>       return 0;
> -
> - error:
> -    return -1;
>   }
>   
>   
> @@ -19499,7 +19490,7 @@ virDomainDefClockParse(virDomainDef *def,
>           (def->clock.offset = virDomainClockOffsetTypeFromString(tmp)) < 0) {
>           virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                          _("unknown clock offset '%s'"), tmp);
> -        goto error;
> +        return -1;
>       }
>       VIR_FREE(tmp);
>   
> @@ -19516,7 +19507,7 @@ virDomainDefClockParse(virDomainDef *def,
>                       virReportError(VIR_ERR_XML_ERROR,
>                                      _("unknown clock adjustment '%s'"),
>                                      tmp);
> -                    goto error;
> +                    return -1;
>                   }
>                   switch (def->clock.offset) {
>                   case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
> @@ -19546,7 +19537,7 @@ virDomainDefClockParse(virDomainDef *def,
>               if ((def->clock.data.variable.basis = virDomainClockBasisTypeFromString(tmp)) < 0) {
>                   virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                                  _("unknown clock basis '%s'"), tmp);
> -                goto error;
> +                return -1;
>               }
>               VIR_FREE(tmp);
>           } else {
> @@ -19559,13 +19550,13 @@ virDomainDefClockParse(virDomainDef *def,
>           if (!def->clock.data.timezone) {
>               virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                              _("missing 'timezone' attribute for clock with offset='timezone'"));
> -            goto error;
> +            return -1;
>           }
>           break;
>       }
>   
>       if ((n = virXPathNodeSet("./clock/timer", ctxt, &nodes)) < 0)
> -        goto error;
> +        return -1;
>   
>       if (n)
>           def->clock.timers = g_new0(virDomainTimerDef *, n);
> @@ -19574,16 +19565,13 @@ virDomainDefClockParse(virDomainDef *def,
>           virDomainTimerDef *timer = virDomainTimerDefParseXML(nodes[i], ctxt);
>   
>           if (!timer)
> -            goto error;
> +            return -1;
>   
>           def->clock.timers[def->clock.ntimers++] = timer;
>       }
>       VIR_FREE(nodes);
>   
>       return 0;
> -
> - error:
> -    return -1;
>   }
>   
>   static int
> diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_profile_conf.c
> index dfffc4dd70..d13833d7df 100644
> --- a/src/conf/netdev_vport_profile_conf.c
> +++ b/src/conf/netdev_vport_profile_conf.c
> @@ -45,14 +45,14 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
>           (virtPort->virtPortType = virNetDevVPortTypeFromString(virtPortType)) <= 0) {
>           virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                          _("unknown virtualport type %s"), virtPortType);
> -        goto error;
> +        return NULL;
>       }
>   
>       if ((virtPort->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE) &&
>           (flags & VIR_VPORT_XML_REQUIRE_TYPE)) {
>           virReportError(VIR_ERR_XML_ERROR, "%s",
>                          _("missing required virtualport type"));
> -        goto error;
> +        return NULL;
>       }
>   
>       while (cur != NULL) {
> @@ -74,12 +74,12 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
>           if (virStrToLong_ui(virtPortManagerID, NULL, 0, &val)) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("cannot parse value of managerid parameter"));
> -            goto error;
> +            return NULL;
>           }
>           if (val > 0xff) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("value of managerid out of range"));
> -            goto error;
> +            return NULL;
>           }
>           virtPort->managerID = (uint8_t)val;
>           virtPort->managerID_specified = true;
> @@ -91,12 +91,12 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
>           if (virStrToLong_ui(virtPortTypeID, NULL, 0, &val)) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("cannot parse value of typeid parameter"));
> -            goto error;
> +            return NULL;
>           }
>           if (val > 0xffffff) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("value for typeid out of range"));
> -            goto error;
> +            return NULL;
>           }
>           virtPort->typeID = (uint32_t)val;
>           virtPort->typeID_specified = true;
> @@ -108,12 +108,12 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
>           if (virStrToLong_ui(virtPortTypeIDVersion, NULL, 0, &val)) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("cannot parse value of typeidversion parameter"));
> -            goto error;
> +            return NULL;
>           }
>           if (val > 0xff) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("value of typeidversion out of range"));
> -            goto error;
> +            return NULL;
>           }
>           virtPort->typeIDVersion = (uint8_t)val;
>           virtPort->typeIDVersion_specified = true;
> @@ -123,7 +123,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
>           if (virUUIDParse(virtPortInstanceID, virtPort->instanceID) < 0) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("cannot parse instanceid parameter as a uuid"));
> -            goto error;
> +            return NULL;
>           }
>           virtPort->instanceID_specified = true;
>       }
> @@ -132,14 +132,14 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
>           virStrcpyStatic(virtPort->profileID, virtPortProfileID) < 0) {
>           virReportError(VIR_ERR_XML_ERROR, "%s",
>                          _("profileid parameter too long"));
> -        goto error;
> +        return NULL;
>       }
>   
>       if (virtPortInterfaceID) {
>           if (virUUIDParse(virtPortInterfaceID, virtPort->interfaceID) < 0) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("cannot parse interfaceid parameter as a uuid"));
> -            goto error;
> +            return NULL;
>           }
>           virtPort->interfaceID_specified = true;
>       }
> @@ -152,7 +152,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
>               if (virUUIDGenerate(virtPort->instanceID) < 0) {
>                   virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                                  _("cannot generate a random uuid for instanceid"));
> -                goto error;
> +                return NULL;
>               }
>               virtPort->instanceID_specified = true;
>           }
> @@ -162,7 +162,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
>               if (virUUIDGenerate(virtPort->interfaceID) < 0) {
>                   virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                                  _("cannot generate a random uuid for interfaceid"));
> -                goto error;
> +                return NULL;
>               }
>               virtPort->interfaceID_specified = true;
>           }
> @@ -172,16 +172,13 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
>   
>       if ((flags & VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES) &&
>           (virNetDevVPortProfileCheckComplete(virtPort, false) < 0)) {
> -        goto error;
> +        return NULL;
>       }
>   
>       if (virNetDevVPortProfileCheckNoExtras(virtPort) < 0)
> -        goto error;
> +        return NULL;
>   
>       return g_steal_pointer(&virtPort);
> -
> - error:
> -    return NULL;
>   }
>   
>   
> diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
> index c78456695c..6690d26ffd 100644
> --- a/src/conf/storage_conf.c
> +++ b/src/conf/storage_conf.c
> @@ -692,7 +692,6 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
>                           const char *permxpath)
>   {
>       long long val;
> -    int ret = -1;
>       VIR_XPATH_NODE_AUTORESTORE(ctxt)
>       xmlNodePtr node;
>       g_autofree char *mode = NULL;
> @@ -715,7 +714,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
>           if (virStrToLong_i(mode, NULL, 8, &tmp) < 0 || (tmp & ~0777)) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("malformed octal mode"));
> -            goto error;
> +            return -1;
>           }
>           perms->mode = tmp;
>       } else {
> @@ -731,7 +730,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
>                val != -1)) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("malformed owner element"));
> -            goto error;
> +            return -1;
>           }
>   
>           perms->uid = val;
> @@ -746,17 +745,14 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
>                val != -1)) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("malformed group element"));
> -            goto error;
> +            return -1;
>           }
>           perms->gid = val;
>       }
>   
>       /* NB, we're ignoring missing labels here - they'll simply inherit */
>       perms->label = virXPathString("string(./label)", ctxt);
> -
> -    ret = 0;
> - error:
> -    return ret;
> +    return 0;
>   }
>   
>   
> diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c
> index 5ca06fa30a..44944e1dbd 100644
> --- a/src/conf/storage_source_conf.c
> +++ b/src/conf/storage_source_conf.c
> @@ -235,7 +235,6 @@ virStorageAuthDefParse(xmlNodePtr node,
>                          xmlXPathContextPtr ctxt)
>   {
>       VIR_XPATH_NODE_AUTORESTORE(ctxt)
> -    virStorageAuthDef *ret = NULL;
>       xmlNodePtr secretnode = NULL;
>       g_autoptr(virStorageAuthDef) authdef = NULL;
>       g_autofree char *authtype = NULL;
> @@ -247,7 +246,7 @@ virStorageAuthDefParse(xmlNodePtr node,
>       if (!(authdef->username = virXPathString("string(./@username)", ctxt))) {
>           virReportError(VIR_ERR_XML_ERROR, "%s",
>                          _("missing username for auth"));
> -        goto cleanup;
> +        return NULL;
>       }
>   
>       authdef->authType = VIR_STORAGE_AUTH_TYPE_NONE;
> @@ -259,14 +258,14 @@ virStorageAuthDefParse(xmlNodePtr node,
>           if ((authdef->authType = virStorageAuthTypeFromString(authtype)) < 0) {
>               virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                              _("unknown auth type '%s'"), authtype);
> -            goto cleanup;
> +            return NULL;
>           }
>       }
>   
>       if (!(secretnode = virXPathNode("./secret ", ctxt))) {
>           virReportError(VIR_ERR_XML_ERROR, "%s",
>                          _("Missing <secret> element in auth"));
> -        goto cleanup;
> +        return NULL;
>       }
>   
>       /* Used by the domain disk xml parsing in order to ensure the
> @@ -279,13 +278,9 @@ virStorageAuthDefParse(xmlNodePtr node,
>       authdef->secrettype = virXMLPropString(secretnode, "type");
>   
>       if (virSecretLookupParseSecret(secretnode, &authdef->seclookupdef) < 0)
> -        goto cleanup;
> +        return NULL;
>   
> -    ret = g_steal_pointer(&authdef);
> -
> - cleanup:
> -
> -    return ret;
> +    return g_steal_pointer(&authdef);
>   }
>   
>   
> diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c
> index c24a292355..5fc9ca06e1 100644
> --- a/src/conf/virsavecookie.c
> +++ b/src/conf/virsavecookie.c
> @@ -61,9 +61,8 @@ virSaveCookieParse(xmlXPathContextPtr ctxt,
>   
>       *obj = NULL;
>   
> -    if (!(ctxt->node = virXPathNode("./cookie", ctxt))) {
> +    if (!(ctxt->node = virXPathNode("./cookie", ctxt)))
>           return 0;
> -    }
>   
>       return virSaveCookieParseNode(ctxt, obj, saveCookie);
>   }
> diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
> index 14ea560309..e44eb7f1d3 100644
> --- a/src/hypervisor/virhostdev.c
> +++ b/src/hypervisor/virhostdev.c
> @@ -92,7 +92,7 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceAddress *devAddr, void *opa
>           if (helperData->usesVFIO &&
>               STREQ_NULLABLE(actual_drvname, helperData->driverName) &&
>               STREQ_NULLABLE(actual_domname, helperData->domainName))
> -            goto iommu_owner;
> +            return 0;
>   
>           if (actual_drvname && actual_domname)
>               virReportError(VIR_ERR_OPERATION_INVALID,
> @@ -106,7 +106,7 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceAddress *devAddr, void *opa
>                              virPCIDeviceGetName(actual));
>           return -1;
>       }
> - iommu_owner:
> +
>       return 0;
>   }
>   
> diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
> index aa719a19d2..be5cc7e049 100644
> --- a/src/libxl/libxl_migration.c
> +++ b/src/libxl/libxl_migration.c
> @@ -902,7 +902,7 @@ libxlMigrationSrcStartTunnel(libxlDriverPrivate *driver,
>       tc->dataFD[0] = -1;
>       tc->dataFD[1] = -1;
>       if (virPipe(tc->dataFD) < 0)
> -        goto out;
> +        return -1;
>   
>       arg = &tc->tmThread;
>       /* Read from pipe */
> @@ -915,7 +915,7 @@ libxlMigrationSrcStartTunnel(libxlDriverPrivate *driver,
>                               name, false, arg) < 0) {
>           virReportError(errno, "%s",
>                          _("Unable to create tunnel migration thread"));
> -        goto out;
> +        return -1;
>       }
>   
>       virObjectUnlock(vm);
> @@ -923,7 +923,6 @@ libxlMigrationSrcStartTunnel(libxlDriverPrivate *driver,
>       ret = libxlDoMigrateSrcSend(driver, vm, flags, tc->dataFD[1]);
>       virObjectLock(vm);
>   
> - out:
>       /* libxlMigrationSrcStopTunnel will be called in libxlDoMigrateSrcP2P
>        * to free all resources for us.
>        */
> diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
> index 05d4abbe81..17c5184b9b 100644
> --- a/src/libxl/xen_xl.c
> +++ b/src/libxl/xen_xl.c
> @@ -1607,7 +1607,6 @@ xenFormatXLDisk(virConfValue *list, virDomainDiskDef *disk)
>       int format = virDomainDiskGetFormat(disk);
>       const char *driver = virDomainDiskGetDriver(disk);
>       g_autofree char *target = NULL;
> -    int ret = -1;
>   
>       /* format */
>       virBufferAddLit(&buf, "format=");
> @@ -1646,7 +1645,7 @@ xenFormatXLDisk(virConfValue *list, virDomainDiskDef *disk)
>       if (disk->transient) {
>           virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>                          _("transient disks not supported yet"));
> -        goto cleanup;
> +        return -1;
>       }
>   
>       /* backendtype */
> @@ -1673,7 +1672,7 @@ xenFormatXLDisk(virConfValue *list, virDomainDiskDef *disk)
>        * it must come last.
>        */
>       if (xenFormatXLDiskSrc(disk->src, &target) < 0)
> -        goto cleanup;
> +        return -1;
>   
>       if (target)
>           virBufferAsprintf(&buf, ",target=%s", target);
> @@ -1689,10 +1688,8 @@ xenFormatXLDisk(virConfValue *list, virDomainDiskDef *disk)
>           tmp->next = val;
>       else
>           list->list = val;
> -    ret = 0;
>   
> - cleanup:
> -    return ret;
> +    return 0;
>   }
>   
>   
> diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
> index 93549e914a..681eb734ce 100644
> --- a/src/openvz/openvz_driver.c
> +++ b/src/openvz/openvz_driver.c
> @@ -799,7 +799,7 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
>           if (openvzDomainSetNetwork(conn, def->name, def->nets[i], &buf) < 0) {
>               virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                              _("Could not configure network"));
> -            goto exit;
> +            return -1;
>           }
>       }
>   
> @@ -817,9 +817,6 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
>       }
>   
>       return 0;
> -
> - exit:
> -    return -1;
>   }
>   
>   
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 67fae46a34..e87cda8c11 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -5580,14 +5580,11 @@ virQEMUCapsCacheNew(const char *libDir,
>           priv->kernelVersion = g_strdup_printf("%s %s", uts.release, uts.version);
>   
>       priv->cpuData = virCPUDataGetHost();
> -
> - cleanup:
>       return cache;
>   
>    error:
>       virObjectUnref(cache);
> -    cache = NULL;
> -    goto cleanup;
> +    return NULL;
>   }
>   
>   
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 9186d59ca2..731227b158 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -2058,16 +2058,16 @@ qemuMonitorJSONGetMemoryStats(qemuMonitor *mon,
>       }
>   
>       if (!balloonpath)
> -        goto cleanup;
> +        return ret;
>   
>       if (!(cmd = qemuMonitorJSONMakeCommand("qom-get",
>                                              "s:path", balloonpath,
>                                              "s:property", "guest-stats",
>                                              NULL)))
> -        goto cleanup;
> +        return ret;
>   
>       if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
> -        goto cleanup;
> +        return ret;
>   
>       if ((data = virJSONValueObjectGetObject(reply, "error"))) {
>           const char *klass = virJSONValueObjectGetString(data, "class");
> @@ -2077,18 +2077,18 @@ qemuMonitorJSONGetMemoryStats(qemuMonitor *mon,
>               STREQ_NULLABLE(desc, "guest hasn't updated any stats yet")) {
>               virReportError(VIR_ERR_OPERATION_INVALID, "%s",
>                              _("the guest hasn't updated any stats yet"));
> -            goto cleanup;
> +            return ret;
>           }
>       }
>   
>       if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
> -        goto cleanup;
> +        return ret;
>   
>       data = virJSONValueObjectGetObject(reply, "return");
>   
>       if (!(statsdata = virJSONValueObjectGet(data, "stats"))) {
>           VIR_DEBUG("data does not include 'stats'");
> -        goto cleanup;
> +        return ret;
>       }
>   
>       GET_BALLOON_STATS(statsdata, "stat-swap-in",
> @@ -2114,9 +2114,7 @@ qemuMonitorJSONGetMemoryStats(qemuMonitor *mon,
>       GET_BALLOON_STATS(statsdata, "stat-htlb-pgfail",
>                         VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL, 1);
>   
> -    ret = got;
> - cleanup:
> -    return ret;
> +    return got;
>   }
>   #undef GET_BALLOON_STATS
>   
> diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
> index d105eead27..bd58d500eb 100644
> --- a/src/qemu/qemu_snapshot.c
> +++ b/src/qemu/qemu_snapshot.c
> @@ -1577,12 +1577,12 @@ qemuSnapshotCreateXML(virDomainPtr domain,
>           parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;
>   
>       if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
> -        goto cleanup;
> +        return NULL;
>   
>       if (!vm->persistent && (flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT)) {
>           virReportError(VIR_ERR_OPERATION_INVALID, "%s",
>                          _("cannot halt after transient domain snapshot"));
> -        goto cleanup;
> +        return NULL;
>       }
>       if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) ||
>           !virDomainObjIsActive(vm))
> @@ -1593,7 +1593,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
>   
>       if (!(def = virDomainSnapshotDefParseString(xmlDesc, driver->xmlopt,
>                                                   priv->qemuCaps, NULL, parse_flags)))
> -        goto cleanup;
> +        return NULL;
>   
>       /* reject snapshot names containing slashes or starting with dot as
>        * snapshot definitions are saved in files named by the snapshot name */
> @@ -1603,7 +1603,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
>                              _("invalid snapshot name '%s': "
>                                "name can't contain '/'"),
>                              def->parent.name);
> -            goto cleanup;
> +            return NULL;
>           }
>   
>           if (def->parent.name[0] == '.') {
> @@ -1611,7 +1611,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
>                              _("invalid snapshot name '%s': "
>                                "name can't start with '.'"),
>                              def->parent.name);
> -            goto cleanup;
> +            return NULL;
>           }
>       }
>   
> @@ -1622,7 +1622,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
>           virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
>                          _("live snapshot creation is supported only "
>                            "during full system snapshots"));
> -        goto cleanup;
> +        return NULL;
>       }
>   
>       /* allow snapshots only in certain states */
> @@ -1640,7 +1640,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
>           if (!redefine) {
>               virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid domain state %s"),
>                              virDomainSnapshotStateTypeToString(state));
> -            goto cleanup;
> +            return NULL;
>           }
>           break;
>   
> @@ -1648,7 +1648,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
>           virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
>                          _("qemu doesn't support taking snapshots of "
>                            "PMSUSPENDED guests"));
> -        goto cleanup;
> +        return NULL;
>   
>           /* invalid states */
>       case VIR_DOMAIN_SNAPSHOT_NOSTATE:
> @@ -1656,7 +1656,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
>       case VIR_DOMAIN_SNAPSHOT_LAST:
>           virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid domain state %s"),
>                          virDomainSnapshotStateTypeToString(state));
> -        goto cleanup;
> +        return NULL;
>       }
>   
>       /* We are going to modify the domain below. Internal snapshots would use
> @@ -1665,7 +1665,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
>        * job mask appropriately. */
>       if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SNAPSHOT,
>                                      VIR_DOMAIN_JOB_OPERATION_SNAPSHOT, flags) < 0)
> -        goto cleanup;
> +        return NULL;
>   
>       qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
>   
> @@ -1801,7 +1801,6 @@ qemuSnapshotCreateXML(virDomainPtr domain,
>   
>       qemuDomainObjEndAsyncJob(driver, vm);
>   
> - cleanup:
>       return snapshot;
>   }
>   
> diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
> index 0c12c5ea22..1b853a5a59 100644
> --- a/src/qemu/qemu_virtiofs.c
> +++ b/src/qemu/qemu_virtiofs.c
> @@ -182,7 +182,6 @@ qemuVirtioFSStart(virQEMUDriver *driver,
>       pid_t pid = (pid_t) -1;
>       VIR_AUTOCLOSE fd = -1;
>       VIR_AUTOCLOSE logfd = -1;
> -    int ret = -1;
>       int rc;
>   
>       if (!virFileExists(fs->src->path)) {
> @@ -193,12 +192,12 @@ qemuVirtioFSStart(virQEMUDriver *driver,
>       }
>   
>       if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias)))
> -        goto cleanup;
> +        goto error;
>   
>       socket_path = qemuDomainGetVHostUserFSSocketPath(vm->privateData, fs);
>   
>       if ((fd = qemuVirtioFSOpenChardev(driver, vm, socket_path)) < 0)
> -        goto cleanup;
> +        goto error;
>   
>       logpath = qemuVirtioFSCreateLogFilename(cfg, vm->def, fs->info.alias);
>   
> @@ -206,7 +205,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
>           g_autoptr(virLogManager) logManager = virLogManagerNew(driver->privileged);
>   
>           if (!logManager)
> -            goto cleanup;
> +            goto error;
>   
>           if ((logfd = virLogManagerDomainOpenLogFile(logManager,
>                                                       "qemu",
> @@ -215,12 +214,12 @@ qemuVirtioFSStart(virQEMUDriver *driver,
>                                                       logpath,
>                                                       0,
>                                                       NULL, NULL)) < 0)
> -            goto cleanup;
> +            goto error;
>       } else {
>           if ((logfd = open(logpath, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR)) < 0) {
>               virReportSystemError(errno, _("failed to create logfile %s"),
>                                    logpath);
> -            goto cleanup;
> +            goto error;
>           }
>           if (virSetCloseExec(logfd) < 0) {
>               virReportSystemError(errno, _("failed to set close-on-exec flag on %s"),
> @@ -230,7 +229,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
>       }
>   
>       if (!(cmd = qemuVirtioFSBuildCommandLine(cfg, fs, &fd)))
> -        goto cleanup;
> +        goto error;
>   
>       /* so far only running as root is supported */
>       virCommandSetUID(cmd, 0);
> @@ -243,7 +242,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
>       virCommandDaemonize(cmd);
>   
>       if (qemuExtDeviceLogCommand(driver, vm, cmd, "virtiofsd") < 0)
> -        goto cleanup;
> +        goto error;
>   
>       rc = virCommandRun(cmd, NULL);
>   
> @@ -267,10 +266,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
>           goto error;
>       }
>   
> -    ret = 0;
> -
> - cleanup:
> -    return ret;
> +    return 0;
>   
>    error:
>       if (pid != -1)
> @@ -279,7 +275,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
>           unlink(pidfile);
>       if (socket_path)
>           unlink(socket_path);
> -    goto cleanup;
> +    return -1;
>   }
>   
>   
> diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
> index 22d54c99be..a3adc85728 100644
> --- a/src/rpc/virnetlibsshsession.c
> +++ b/src/rpc/virnetlibsshsession.c
> @@ -453,7 +453,6 @@ virNetLibsshImportPrivkey(virNetLibsshSession *sess,
>                             virNetLibsshAuthMethod *priv,
>                             ssh_key *ret_key)
>   {
> -    int err;
>       int ret;
>       ssh_key key;
>   
> @@ -470,8 +469,7 @@ virNetLibsshImportPrivkey(virNetLibsshSession *sess,
>           virReportError(VIR_ERR_AUTH_FAILED,
>                          _("error while reading private key '%s'"),
>                          priv->filename);
> -        err = SSH_AUTH_ERROR;
> -        goto error;
> +        return SSH_AUTH_ERROR;
>       } else if (ret == SSH_ERROR) {
>           if (virGetLastErrorCode() == VIR_ERR_OK) {
>               virReportError(VIR_ERR_AUTH_FAILED,
> @@ -479,15 +477,11 @@ virNetLibsshImportPrivkey(virNetLibsshSession *sess,
>                                "passphrase?"),
>                              priv->filename);
>           }
> -        err = SSH_AUTH_ERROR;
> -        goto error;
> +        return SSH_AUTH_ERROR;
>       }
>   
>       *ret_key = key;
>       return SSH_AUTH_SUCCESS;
> -
> - error:
> -    return err;
>   }
>   
>   
> diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
> index ed17ed11a6..eef1d91062 100644
> --- a/src/storage/storage_backend_iscsi.c
> +++ b/src/storage/storage_backend_iscsi.c
> @@ -91,7 +91,6 @@ static int
>   virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
>                                       uint32_t *host)
>   {
> -    int ret = -1;
>       g_autoptr(DIR) sysdir = NULL;
>       struct dirent *dirent = NULL;
>       int direrr;
> @@ -101,17 +100,16 @@ virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
>       virWaitForDevices();
>   
>       if (virDirOpen(&sysdir, sysfs_path) < 0)
> -        goto cleanup;
> +        return -1;
>   
>       while ((direrr = virDirRead(sysdir, &dirent, sysfs_path)) > 0) {
>           if (STRPREFIX(dirent->d_name, "target")) {
>               if (sscanf(dirent->d_name, "target%u:", host) == 1) {
> -                ret = 0;
> -                goto cleanup;
> +                return 0;
>               } else {
>                   virReportError(VIR_ERR_INTERNAL_ERROR,
>                                  _("Failed to parse target '%s'"), dirent->d_name);
> -                goto cleanup;
> +                return -1;
>               }
>           }
>       }
> @@ -120,11 +118,10 @@ virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
>           virReportError(VIR_ERR_INTERNAL_ERROR,
>                          _("Failed to get host number for iSCSI session "
>                            "with path '%s'"), sysfs_path);
> -        goto cleanup;
> +        return -1;
>       }
>   
> - cleanup:
> -    return ret;
> +    return -1;
>   }
>   
>   static int
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index ea474d55ac..d2577b2b16 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -858,13 +858,13 @@ testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char *type)
>           absFile = testBuildFilename(file, relFile);
>   
>           if (!(doc = virXMLParse(absFile, NULL, type, NULL, false)))
> -            goto error;
> +            return NULL;
>   
>           ret = xmlCopyNode(xmlDocGetRootElement(doc), 1);
>           if (!ret) {
>               virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                              _("Failed to copy XML node"));
> -            goto error;
> +            return NULL;
>           }
>           xmlReplaceNode(node, ret);
>           xmlFreeNode(node);
> @@ -872,7 +872,6 @@ testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char *type)
>           ret = node;
>       }
>   
> - error:
>       return ret;
>   }
>   
> diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
> index 6234095827..51da6e6a2f 100644
> --- a/src/util/vircgroup.c
> +++ b/src/util/vircgroup.c
> @@ -2764,8 +2764,7 @@ virCgroupKillRecursiveInternal(virCgroup *group,
>   
>       if (rc == 0) {
>           VIR_DEBUG("Path %s does not exist, assuming done", keypath);
> -        killedAny = false;
> -        goto done;
> +        return 0;
>       }
>   
>       while ((direrr = virDirRead(dp, &ent, keypath)) > 0) {
> @@ -2791,7 +2790,6 @@ virCgroupKillRecursiveInternal(virCgroup *group,
>       if (direrr < 0)
>           return -1;
>   
> - done:
>       return killedAny ? 1 : 0;
>   }
>   
> diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
> index 8a04bb2e4a..96f36c3b4d 100644
> --- a/src/util/vircgroupv1.c
> +++ b/src/util/vircgroupv1.c
> @@ -926,7 +926,6 @@ virCgroupV1SetOwner(virCgroup *cgroup,
>                       gid_t gid,
>                       int controllers)
>   {
> -    int ret = -1;
>       size_t i;
>       int direrr;
>   
> @@ -945,7 +944,7 @@ virCgroupV1SetOwner(virCgroup *cgroup,
>                                  cgroup->legacy[i].placement);
>   
>           if (virDirOpen(&dh, base) < 0)
> -            goto cleanup;
> +            return -1;
>   
>           while ((direrr = virDirRead(dh, &de, base)) > 0) {
>               g_autofree char *entry = NULL;
> @@ -956,24 +955,21 @@ virCgroupV1SetOwner(virCgroup *cgroup,
>                   virReportSystemError(errno,
>                                        _("cannot chown '%s' to (%u, %u)"),
>                                        entry, uid, gid);
> -                goto cleanup;
> +                return -1;
>               }
>           }
>           if (direrr < 0)
> -            goto cleanup;
> +            return -1;
>   
>           if (chown(base, uid, gid) < 0) {
>               virReportSystemError(errno,
>                                    _("cannot chown '%s' to (%u, %u)"),
>                                    base, uid, gid);
> -            goto cleanup;
> +            return -1;
>           }
>       }
>   
> -    ret = 0;
> -
> - cleanup:
> -    return ret;
> +    return 0;
>   }
>   
>   
> @@ -1599,7 +1595,6 @@ virCgroupV1GetMemoryStat(virCgroup *group,
>                            unsigned long long *inactiveFile,
>                            unsigned long long *unevictable)
>   {
> -    int ret = -1;
>       g_autofree char *stat = NULL;
>       char *line = NULL;
>       unsigned long long cacheVal = 0;
> @@ -1629,12 +1624,12 @@ virCgroupV1GetMemoryStat(virCgroup *group,
>           if (!valueStr) {
>               virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                              _("Cannot parse 'memory.stat' cgroup file."));
> -            goto cleanup;
> +            return -1;
>           }
>           *valueStr = '\0';
>   
>           if (virStrToLong_ull(valueStr + 1, NULL, 10, &value) < 0)
> -            goto cleanup;
> +            return -1;
>   
>           if (STREQ(line, "cache"))
>               cacheVal = value >> 10;
> @@ -1662,10 +1657,7 @@ virCgroupV1GetMemoryStat(virCgroup *group,
>       *inactiveFile = inactiveFileVal;
>       *unevictable = unevictableVal;
>   
> -    ret = 0;
> -
> - cleanup:
> -    return ret;
> +    return 0;
>   }
>   
>   
> diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
> index f2f606913f..2dd9a20377 100644
> --- a/src/util/virdnsmasq.c
> +++ b/src/util/virdnsmasq.c
> @@ -172,10 +172,8 @@ addnhostsWrite(const char *path,
>   
>       if (!(f = fopen(tmp, "w"))) {
>           istmp = false;
> -        if (!(f = fopen(path, "w"))) {
> -            rc = -errno;
> -            goto cleanup;
> -        }
> +        if (!(f = fopen(path, "w")))
> +            return -errno;
>       }
>   
>       for (i = 0; i < nhosts; i++) {
> @@ -186,7 +184,7 @@ addnhostsWrite(const char *path,
>               if (istmp)
>                   unlink(tmp);
>   
> -            goto cleanup;
> +            return rc;
>           }
>   
>           for (j = 0; j < hosts[i].nhostnames; j++) {
> @@ -197,7 +195,7 @@ addnhostsWrite(const char *path,
>                   if (istmp)
>                       unlink(tmp);
>   
> -                goto cleanup;
> +                return rc;
>               }
>           }
>   
> @@ -208,23 +206,20 @@ addnhostsWrite(const char *path,
>               if (istmp)
>                   unlink(tmp);
>   
> -            goto cleanup;
> +            return rc;
>           }
>       }
>   
> -    if (VIR_FCLOSE(f) == EOF) {
> -        rc = -errno;
> -        goto cleanup;
> -    }
> +    if (VIR_FCLOSE(f) == EOF)
> +        return -errno;
>   
>       if (istmp && rename(tmp, path) < 0) {
>           rc = -errno;
>           unlink(tmp);
> -        goto cleanup;
> +        return rc;
>       }
>   
> - cleanup:
> -    return rc;
> +    return 0;
>   }
>   
>   static int
> @@ -369,10 +364,8 @@ hostsfileWrite(const char *path,
>   
>       if (!(f = fopen(tmp, "w"))) {
>           istmp = false;
> -        if (!(f = fopen(path, "w"))) {
> -            rc = -errno;
> -            goto cleanup;
> -        }
> +        if (!(f = fopen(path, "w")))
> +            return -errno;
>       }
>   
>       for (i = 0; i < nhosts; i++) {
> @@ -383,23 +376,20 @@ hostsfileWrite(const char *path,
>               if (istmp)
>                   unlink(tmp);
>   
> -            goto cleanup;
> +            return rc;
>           }
>       }
>   
> -    if (VIR_FCLOSE(f) == EOF) {
> -        rc = -errno;
> -        goto cleanup;
> -    }
> +    if (VIR_FCLOSE(f) == EOF)
> +        return -errno;
>   
>       if (istmp && rename(tmp, path) < 0) {
>           rc = -errno;
>           unlink(tmp);
> -        goto cleanup;
> +        return rc;
>       }
>   
> - cleanup:
> -    return rc;
> +    return 0;
>   }
>   
>   static int
> diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
> index 3563a662d5..67b6910626 100644
> --- a/src/util/virhostcpu.c
> +++ b/src/util/virhostcpu.c
> @@ -90,7 +90,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
>       g_autofree long *cpu_times = NULL;
>       struct clockinfo clkinfo;
>       size_t i, j, cpu_times_size, clkinfo_size;
> -    int cpu_times_num, offset, hz, stathz, ret = -1;
> +    int cpu_times_num, offset, hz, stathz;
>       struct field_cpu_map {
>           const char *field;
>           int idx[CPUSTATES];
> @@ -151,7 +151,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
>           virReportSystemError(errno,
>                                _("sysctl failed for '%s'"),
>                                sysctl_name);
> -        goto cleanup;
> +        return -1;
>       }
>   
>       for (i = 0; cpu_map[i].field != NULL; i++) {
> @@ -161,7 +161,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
>               virReportError(VIR_ERR_INTERNAL_ERROR,
>                              _("Field '%s' too long for destination"),
>                              cpu_map[i].field);
> -            goto cleanup;
> +            return -1;
>           }
>   
>           param->value = 0;
> @@ -169,10 +169,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
>               param->value += cpu_times[offset + cpu_map[i].idx[j]] * TICK_TO_NSEC;
>       }
>   
> -    ret = 0;
> -
> - cleanup:
> -    return ret;
> +    return 0;
>   }
>   
>   #endif /* __FreeBSD__ */
> diff --git a/tests/domainconftest.c b/tests/domainconftest.c
> index 71fd1f7b73..14d84b0071 100644
> --- a/tests/domainconftest.c
> +++ b/tests/domainconftest.c
> @@ -76,10 +76,10 @@ mymain(void)
>       int ret = 0;
>   
>       if ((caps = virTestGenericCapsInit()) == NULL)
> -        goto cleanup;
> +        return EXIT_FAILURE;
>   
>       if (!(xmlopt = virTestGenericDomainXMLConfInit()))
> -        goto cleanup;
> +        return EXIT_FAILURE;
>   
>   #define DO_TEST_GET_FS(fspath, expect) \
>       do { \
> @@ -100,7 +100,6 @@ mymain(void)
>       virObjectUnref(caps);
>       virObjectUnref(xmlopt);
>   
> - cleanup:
>       return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
>   }
>   
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 161e7efa62..58f16ef459 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -141,20 +141,15 @@ fakeStorageVolLookupByName(virStoragePoolPtr pool,
>           return NULL;
>       }
>   
> -    if (!strchr(name, '+'))
> -        goto fallback;
> -
>       if (!(volinfo = g_strsplit(name, "+", 2)))
>           return NULL;
>   
> -    if (!volinfo[1])
> -        goto fallback;
> +    if (!volinfo[1]) {
> +        return virGetStorageVol(pool->conn, pool->name, name, "block", NULL, NULL);
> +    }
>   
>       return virGetStorageVol(pool->conn, pool->name, volinfo[1], volinfo[0],
>                              NULL, NULL);
> -
> - fallback:
> -    return virGetStorageVol(pool->conn, pool->name, name, "block", NULL, NULL);
>   }
>   
>   static int
> diff --git a/tests/virpcitest.c b/tests/virpcitest.c
> index 4c0f0b91c3..ad2fcc6751 100644
> --- a/tests/virpcitest.c
> +++ b/tests/virpcitest.c
> @@ -81,7 +81,7 @@ testVirPCIDeviceNew(const void *opaque G_GNUC_UNUSED)
>           virReportError(VIR_ERR_INTERNAL_ERROR, \
>                          "Unexpected count of items in " #list ": %d, " \
>                          "expecting %zu", count, (size_t) cnt); \
> -        goto cleanup; \
> +        return -1; \
>       }
>   
>   static int
> @@ -165,7 +165,6 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED)
>   static int
>   testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED)
>   {
> -    int ret = -1;
>       virPCIDevice *dev[] = {NULL, NULL, NULL};
>       size_t i, nDev = G_N_ELEMENTS(dev);
>       g_autoptr(virPCIDeviceList) activeDevs = NULL;
> @@ -174,17 +173,17 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED)
>   
>       if (!(activeDevs = virPCIDeviceListNew()) ||
>           !(inactiveDevs = virPCIDeviceListNew()))
> -        goto cleanup;
> +        return -1;
>   
>       for (i = 0; i < nDev; i++) {
>           virPCIDeviceAddress devAddr = {.domain = 0, .bus = 0,
>                                          .slot = i + 1, .function = 0};
>           if (!(dev[i] = virPCIDeviceNew(&devAddr)))
> -            goto cleanup;
> +            return -1;
>   
>           if (virPCIDeviceListAdd(inactiveDevs, dev[i]) < 0) {
>               virPCIDeviceFree(dev[i]);
> -            goto cleanup;
> +            return -1;
>           }
>   
>           CHECK_LIST_COUNT(activeDevs, 0);
> @@ -198,15 +197,13 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED)
>   
>       for (i = 0; i < nDev; i++) {
>           if (virPCIDeviceReattach(dev[i], activeDevs, inactiveDevs) < 0)
> -            goto cleanup;
> +            return -1;
>   
>           CHECK_LIST_COUNT(activeDevs, 0);
>           CHECK_LIST_COUNT(inactiveDevs, nDev - i - 1);
>       }
>   
> -    ret = 0;
> - cleanup:
> -    return ret;
> +    return 0;
>   }
>   
>   struct testPCIDevData {
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 22f428f702..c592d0281a 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -4453,7 +4453,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
>           return false;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0)
> -        goto cleanup;
> +        return false;
>   
>       if (vshCommandOptBool(cmd, "verbose"))
>           verbose = true;
> @@ -4462,7 +4462,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
>                           true,
>                           doSave,
>                           &data) < 0)
> -        goto cleanup;
> +        return false;
>   
>       virshWatchJob(ctl, dom, verbose, eventLoop,
>                     &data.ret, 0, NULL, NULL, _("Save"));
> @@ -4472,7 +4472,6 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
>       if (!data.ret)
>           vshPrintExtra(ctl, _("\nDomain '%s' saved to %s\n"), name, to);
>   
> - cleanup:
>       return !data.ret;
>   }
>   
> @@ -4770,7 +4769,7 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
>                           true,
>                           doManagedsave,
>                           &data) < 0)
> -        goto cleanup;
> +        return false;
>   
>       virshWatchJob(ctl, dom, verbose, eventLoop,
>                     &data.ret, 0, NULL, NULL, _("Managedsave"));
> @@ -4780,7 +4779,6 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
>       if (!data.ret)
>           vshPrintExtra(ctl, _("\nDomain '%s' state saved by libvirt\n"), name);
>   
> - cleanup:
>       return !data.ret;
>   }
>   
> diff --git a/tools/virsh-host.c b/tools/virsh-host.c
> index fc84415e7b..5ae6657347 100644
> --- a/tools/virsh-host.c
> +++ b/tools/virsh-host.c
> @@ -1122,11 +1122,11 @@ vshExtractCPUDefXMLs(vshControl *ctl,
>           }
>       }
>   
> - cleanup:
> -    return g_steal_pointer(&cpus);
> +    return cpus;
>   
>    error:
> -    goto cleanup;
> +    g_strfreev(cpus);
> +    return NULL;
>   }
>   
>   
> diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
> index 424865962f..fe15d2d702 100644
> --- a/tools/virsh-nodedev.c
> +++ b/tools/virsh-nodedev.c
> @@ -141,7 +141,6 @@ static bool
>   cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
>   {
>       g_autoptr(virshNodeDevice) dev = NULL;
> -    bool ret = false;
>       const char *device_value = NULL;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0)
> @@ -149,18 +148,16 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
>   
>       dev = vshFindNodeDevice(ctl, device_value);
>       if (!dev)
> -        goto cleanup;
> +        return false;
>   
>       if (virNodeDeviceDestroy(dev) == 0) {
>           vshPrintExtra(ctl, _("Destroyed node device '%s'\n"), device_value);
>       } else {
>           vshError(ctl, _("Failed to destroy node device '%s'"), device_value);
> -        goto cleanup;
> +        return false;
>       }
>   
> -    ret = true;
> - cleanup:
> -    return ret;
> +    return true;
>   }
>   
>   struct virshNodeList {
> @@ -578,7 +575,6 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd)
>       g_autoptr(virshNodeDevice) device = NULL;
>       g_autofree char *xml = NULL;
>       const char *device_value = NULL;
> -    bool ret = false;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0)
>            return false;
> @@ -586,16 +582,13 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd)
>       device = vshFindNodeDevice(ctl, device_value);
>   
>       if (!device)
> -        goto cleanup;
> +        return false;
>   
>       if (!(xml = virNodeDeviceGetXMLDesc(device, 0)))
> -        goto cleanup;
> +        return false;
>   
>       vshPrint(ctl, "%s\n", xml);
> -
> -    ret = true;
> - cleanup:
> -    return ret;
> +    return true;
>   }
>   
>   /*
> @@ -1013,7 +1006,6 @@ static bool
>   cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
>   {
>       g_autoptr(virshNodeDevice) dev = NULL;
> -    bool ret = false;
>       const char *device_value = NULL;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0)
> @@ -1022,17 +1014,15 @@ cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
>       dev = vshFindNodeDevice(ctl, device_value);
>   
>       if (!dev)
> -        goto cleanup;
> +        return false;
>   
>       if (virNodeDeviceUndefine(dev, 0) < 0) {
>           vshError(ctl, _("Failed to undefine node device '%s'"), device_value);
> -        goto cleanup;
> +        return false;
>       }
>   
>       vshPrintExtra(ctl, _("Undefined node device '%s'\n"), device_value);
> -    ret = true;
> - cleanup:
> -    return ret;
> +    return true;
>   }
>   
>   
> @@ -1163,7 +1153,6 @@ static bool
>   cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
>   {
>       g_autoptr(virshNodeDevice) dev = NULL;
> -    bool ret = false;
>       const char *name = NULL;
>       int autostart;
>   
> @@ -1172,7 +1161,8 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
>   
>       dev = vshFindNodeDevice(ctl, name);
>   
> -    if (!dev) goto cleanup;
> +    if (!dev)
> +        return false;
>   
>       autostart = !vshCommandOptBool(cmd, "disable");
>   
> @@ -1181,7 +1171,7 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
>               vshError(ctl, _("failed to mark device %s as autostarted"), name);
>           else
>               vshError(ctl, _("failed to unmark device %s as autostarted"), name);
> -        goto cleanup;
> +        return false;
>       }
>   
>       if (autostart)
> @@ -1189,9 +1179,7 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
>       else
>           vshPrintExtra(ctl, _("Device %s unmarked as autostarted\n"), name);
>   
> -    ret = true;
> - cleanup:
> -    return ret;
> +    return true;
>   }
>   
>   
> @@ -1224,7 +1212,6 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd)
>   {
>       g_autoptr(virshNodeDevice) device = NULL;
>       const char *device_value = NULL;
> -    bool ret = false;
>       int autostart;
>       const char *parent = NULL;
>   
> @@ -1234,7 +1221,7 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd)
>       device = vshFindNodeDevice(ctl, device_value);
>   
>       if (!device)
> -        goto cleanup;
> +        return false;
>   
>       parent = virNodeDeviceGetParent(device);
>       vshPrint(ctl, "%-15s %s\n", _("Name:"), virNodeDeviceGetName(device));
> @@ -1248,9 +1235,7 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd)
>       else
>           vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ? _("yes") : _("no"));
>   
> -    ret = true;
> - cleanup:
> -    return ret;
> +    return true;
>   }
>   
>   
> diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
> index 12773d900b..ca40fbcd72 100644
> --- a/tools/virsh-volume.c
> +++ b/tools/virsh-volume.c
> @@ -238,7 +238,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
>       g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
>       unsigned long flags = 0;
>       virshControl *priv = ctl->privData;
> -    bool ret = false;
>   
>       if (vshCommandOptBool(cmd, "prealloc-metadata"))
>           flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
> @@ -247,27 +246,27 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
>           return false;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0)
> -        goto cleanup;
> +        return false;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0)
> -        goto cleanup;
> +        return false;
>   
>       if (virshVolSize(capacityStr, &capacity) < 0) {
>           vshError(ctl, _("Malformed size %s"), capacityStr);
> -        goto cleanup;
> +        return false;
>       }
>   
>       if (vshCommandOptStringQuiet(ctl, cmd, "allocation", &allocationStr) > 0 &&
>           virshVolSize(allocationStr, &allocation) < 0) {
>           vshError(ctl, _("Malformed size %s"), allocationStr);
> -        goto cleanup;
> +        return false;
>       }
>   
>       if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0 ||
>           vshCommandOptStringReq(ctl, cmd, "backing-vol", &snapshotStrVol) < 0 ||
>           vshCommandOptStringReq(ctl, cmd, "backing-vol-format",
>                                  &snapshotStrFormat) < 0)
> -        goto cleanup;
> +        return false;
>   
>       virBufferAddLit(&buf, "<volume>\n");
>       virBufferAdjustIndent(&buf, 2);
> @@ -325,11 +324,11 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
>           }
>           if (snapVol == NULL) {
>               vshError(ctl, _("failed to get vol '%s'"), snapshotStrVol);
> -            goto cleanup;
> +            return false;
>           }
>   
>           if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
> -            goto cleanup;
> +            return false;
>           }
>   
>           /* Create XML for the backing store */
> @@ -353,15 +352,12 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
>       } else {
>           if (!(vol = virStorageVolCreateXML(pool, xml, flags))) {
>               vshError(ctl, _("Failed to create vol %s"), name);
> -            goto cleanup;
> +            return false;
>           }
>           vshPrintExtra(ctl, _("Vol %s created\n"), name);
>       }
>   
> -    ret = true;
> -
> - cleanup:
> -    return ret;
> +    return true;
>   }
>   
>   /*
> @@ -393,7 +389,6 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
>       g_autoptr(virshStoragePool) pool = NULL;
>       g_autoptr(virshStorageVol) vol = NULL;
>       const char *from = NULL;
> -    bool ret = false;
>       unsigned int flags = 0;
>       g_autofree char *buffer = NULL;
>   
> @@ -404,23 +399,21 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
>           return false;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
> -        goto cleanup;
> +        return false;
>   
>       if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
>           vshSaveLibvirtError();
> -        goto cleanup;
> +        return false;
>       }
>   
>       if (!(vol = virStorageVolCreateXML(pool, buffer, flags))) {
>           vshError(ctl, _("Failed to create vol from %s"), from);
> -        goto cleanup;
> +        return false;
>       }
>   
>       vshPrintExtra(ctl, _("Vol %s created from %s\n"),
>                     virStorageVolGetName(vol), from);
> -    ret = true;
> - cleanup:
> -    return ret;
> +    return true;
>   }
>   
>   /*
> @@ -463,12 +456,11 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
>       g_autoptr(virshStorageVol) newvol = NULL;
>       g_autoptr(virshStorageVol) inputvol = NULL;
>       const char *from = NULL;
> -    bool ret = false;
>       g_autofree char *buffer = NULL;
>       unsigned int flags = 0;
>   
>       if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
> -        goto cleanup;
> +        return false;
>   
>       if (vshCommandOptBool(cmd, "prealloc-metadata"))
>           flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
> @@ -477,28 +469,26 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
>           flags |= VIR_STORAGE_VOL_CREATE_REFLINK;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
> -        goto cleanup;
> +        return false;
>   
>       if (!(inputvol = virshCommandOptVol(ctl, cmd, "vol", "inputpool", NULL)))
> -        goto cleanup;
> +        return false;
>   
>       if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
>           vshReportError(ctl);
> -        goto cleanup;
> +        return false;
>       }
>   
>       newvol = virStorageVolCreateXMLFrom(pool, buffer, inputvol, flags);
>   
>       if (!newvol) {
>           vshError(ctl, _("Failed to create vol from %s"), from);
> -        goto cleanup;
> +        return false;
>       }
>   
>       vshPrintExtra(ctl, _("Vol %s created from input vol %s\n"),
>                     virStorageVolGetName(newvol), virStorageVolGetName(inputvol));
> -    ret = true;
> - cleanup:
> -    return ret;
> +    return true;
>   }
>   
>   static xmlChar *
> @@ -653,7 +643,6 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
>   {
>       const char *file = NULL;
>       g_autoptr(virshStorageVol) vol = NULL;
> -    bool ret = false;
>       VIR_AUTOCLOSE fd = -1;
>       g_autoptr(virshStream) st = NULL;
>       const char *name = NULL;
> @@ -673,16 +662,16 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
>           return false;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0)
> -        goto cleanup;
> +        return false;
>   
>       if ((fd = open(file, O_RDONLY)) < 0) {
>           vshError(ctl, _("cannot read %s"), file);
> -        goto cleanup;
> +        return false;
>       }
>   
>       if (fstat(fd, &sb) < 0) {
>           vshError(ctl, _("unable to stat %s"), file);
> -        goto cleanup;
> +        return false;
>       }
>   
>       cbData.ctl = ctl;
> @@ -694,12 +683,12 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
>   
>       if (!(st = virStreamNew(priv->conn, 0))) {
>           vshError(ctl, _("cannot create a new stream"));
> -        goto cleanup;
> +        return false;
>       }
>   
>       if (virStorageVolUpload(vol, st, offset, length, flags) < 0) {
>           vshError(ctl, _("cannot upload to volume %s"), name);
> -        goto cleanup;
> +        return false;
>       }
>   
>       if (flags & VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM) {
> @@ -707,30 +696,27 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
>                                      virshStreamInData,
>                                      virshStreamSourceSkip, &cbData) < 0) {
>               vshError(ctl, _("cannot send data to volume %s"), name);
> -            goto cleanup;
> +            return false;
>           }
>       } else {
>           if (virStreamSendAll(st, virshStreamSource, &cbData) < 0) {
>               vshError(ctl, _("cannot send data to volume %s"), name);
> -            goto cleanup;
> +            return false;
>           }
>       }
>   
>       if (VIR_CLOSE(fd) < 0) {
>           vshError(ctl, _("cannot close file %s"), file);
>           virStreamAbort(st);
> -        goto cleanup;
> +        return false;
>       }
>   
>       if (virStreamFinish(st) < 0) {
>           vshError(ctl, _("cannot close volume %s"), name);
> -        goto cleanup;
> +        return false;
>       }
>   
> -    ret = true;
> -
> - cleanup:
> -    return ret;
> +    return true;
>   }
>   
>   /*
> @@ -931,7 +917,6 @@ static bool
>   cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
>   {
>       g_autoptr(virshStorageVol) vol = NULL;
> -    bool ret = false;
>       const char *name;
>       const char *algorithm_str = NULL;
>       int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO;
> @@ -941,12 +926,12 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
>           return false;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "algorithm", &algorithm_str) < 0)
> -        goto out;
> +        return false;
>   
>       if (algorithm_str &&
>           (algorithm = virshStorageVolWipeAlgorithmTypeFromString(algorithm_str)) < 0) {
>           vshError(ctl, _("Unsupported algorithm '%s'"), algorithm_str);
> -        goto out;
> +        return false;
>       }
>   
>       if ((funcRet = virStorageVolWipePattern(vol, algorithm, 0)) < 0) {
> @@ -957,13 +942,11 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
>   
>       if (funcRet < 0) {
>           vshError(ctl, _("Failed to wipe vol %s"), name);
> -        goto out;
> +        return false;
>       }
>   
>       vshPrintExtra(ctl, _("Vol %s wiped\n"), name);
> -    ret = true;
> - out:
> -    return ret;
> +    return true;
>   }
>   
>   
> @@ -1111,7 +1094,6 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
>       const char *capacityStr = NULL;
>       unsigned long long capacity = 0;
>       unsigned int flags = 0;
> -    bool ret = false;
>       bool delta = vshCommandOptBool(cmd, "delta");
>   
>       if (vshCommandOptBool(cmd, "allocate"))
> @@ -1123,7 +1105,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
>           return false;
>   
>       if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0)
> -        goto cleanup;
> +        return false;
>       virSkipSpaces(&capacityStr);
>       if (*capacityStr == '-') {
>           /* The API always requires a positive value; but we allow a
> @@ -1134,7 +1116,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
>           } else {
>               vshError(ctl, "%s",
>                        _("negative size requires --shrink"));
> -            goto cleanup;
> +            return false;
>           }
>       }
>   
> @@ -1143,7 +1125,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
>   
>       if (virshVolSize(capacityStr, &capacity) < 0) {
>           vshError(ctl, _("Malformed size %s"), capacityStr);
> -        goto cleanup;
> +        return false;
>       }
>   
>       if (virStorageVolResize(vol, capacity, flags) < 0) {
> @@ -1151,16 +1133,14 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
>                    delta ? _("Failed to change size of volume '%s' by %s")
>                    : _("Failed to change size of volume '%s' to %s"),
>                    virStorageVolGetName(vol), capacityStr);
> -        goto cleanup;
> +        return false;
>       }
>   
>       vshPrintExtra(ctl,
>                     delta ? _("Size of volume '%s' successfully changed by %s\n")
>                     : _("Size of volume '%s' successfully changed to %s\n"),
>                     virStorageVolGetName(vol), capacityStr);
> -    ret = true;
> - cleanup:
> -    return ret;
> +    return true;
>   }
>   
>   /*
> 




More information about the libvir-list mailing list