diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index cb1544665e..21407a3957 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -141,7 +141,6 @@ bhyveConnectGetCapabilities(virConnectPtr conn) { struct _bhyveConn *privconn = conn->privateData; g_autoptr(virCaps) caps = NULL; - char *xml = NULL; if (virConnectGetCapabilitiesEnsureACL(conn) < 0) return NULL; @@ -149,14 +148,10 @@ bhyveConnectGetCapabilities(virConnectPtr conn) if (!(caps = bhyveDriverGetCapabilities(privconn))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to get Capabilities")); - goto cleanup; + return NULL; } - if (!(xml = virCapabilitiesFormatXML(caps))) - goto cleanup; - - cleanup: - return xml; + return virCapabilitiesFormatXML(caps); } static virDomainObj * @@ -1558,7 +1553,6 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn, const char *nativeConfig, unsigned int flags) { - char *xml = NULL; g_autoptr(virDomainDef) def = NULL; struct _bhyveConn *privconn = conn->privateData; unsigned bhyveCaps = bhyveDriverGetBhyveCaps(privconn); @@ -1571,18 +1565,15 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn, if (STRNEQ(nativeFormat, BHYVE_CONFIG_FORMAT_ARGV)) { virReportError(VIR_ERR_INVALID_ARG, _("unsupported config type %s"), nativeFormat); - goto cleanup; + return NULL; } def = bhyveParseCommandLineString(nativeConfig, bhyveCaps, privconn->xmlopt); if (def == NULL) - goto cleanup; + return NULL; - xml = virDomainDefFormat(def, privconn->xmlopt, 0); - - cleanup: - return xml; + return virDomainDefFormat(def, privconn->xmlopt, 0); } static char * diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index a9cbbca560..98f1e89003 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -57,13 +57,13 @@ virCaps *virCHDriverCapsInit(void) if ((caps = virCapabilitiesNew(virArchFromHost(), false, false)) == NULL) - goto cleanup; + return NULL; if (!(caps->host.numa = virCapabilitiesHostNUMANewHost())) - goto cleanup; + return NULL; if (virCapabilitiesInitCaches(caps) < 0) - goto cleanup; + return NULL; guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, caps->host.arch, NULL, NULL, 0, NULL); @@ -71,9 +71,6 @@ virCaps *virCHDriverCapsInit(void) virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, NULL, NULL, 0, NULL); return g_steal_pointer(&caps); - - cleanup: - return NULL; } /** diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 4d938f4d7f..3327f0132e 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -271,7 +271,7 @@ hypervCapsInit(hypervPrivate *priv) return NULL; if (hypervLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) - goto error; + return NULL; /* i686 caps */ guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, @@ -288,9 +288,6 @@ hypervCapsInit(hypervPrivate *priv) NULL, NULL, 0, NULL); return g_steal_pointer(&caps); - - error: - return NULL; } diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 9084dacb40..970ad37306 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -645,18 +645,15 @@ libxlMakeCapabilities(libxl_ctx *ctx) return NULL; if (libxlCapsInitHost(ctx, caps) < 0) - goto error; + return NULL; if (libxlCapsInitNuma(ctx, caps) < 0) - goto error; + return NULL; if (libxlCapsInitGuests(ctx, caps) < 0) - goto error; + return NULL; return g_steal_pointer(&caps); - - error: - return NULL; } /* diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index f37c228139..1ac6253ad7 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1891,7 +1891,6 @@ libxlDriverGetDom0MaxmemConf(libxlDriverConfig *cfg, size_t i; size_t j; libxl_physinfo physinfo; - int ret = -1; if (cfg->verInfo->commandline == NULL || !(cmd_tokens = g_strsplit(cfg->verInfo->commandline, " ", 0))) @@ -1931,8 +1930,7 @@ libxlDriverGetDom0MaxmemConf(libxlDriverConfig *cfg, } } *maxmem = *maxmem * multiplier; - ret = 0; - goto cleanup; + return 0; } } } @@ -1942,14 +1940,11 @@ libxlDriverGetDom0MaxmemConf(libxlDriverConfig *cfg, libxl_physinfo_init(&physinfo); if (libxl_get_physinfo(cfg->ctx, &physinfo)) { VIR_WARN("libxl_get_physinfo failed"); - goto cleanup; + return -1; } *maxmem = (physinfo.total_pages * cfg->verInfo->pagesize) / 1024; libxl_physinfo_dispose(&physinfo); - ret = 0; - - cleanup: - return ret; + return 0; } diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 32c31d240e..e68ca1cde3 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -1575,19 +1575,15 @@ xenMakeIPList(virNetDevIPInfo *guestIP) { size_t i; g_auto(GStrv) address_array = NULL; - char *ret = NULL; address_array = g_new0(char *, guestIP->nips + 1); for (i = 0; i < guestIP->nips; i++) { address_array[i] = virSocketAddrFormat(&guestIP->ips[i]->address); if (!address_array[i]) - goto cleanup; + return NULL; } - ret = g_strjoinv(" ", address_array); - - cleanup: - return ret; + return g_strjoinv(" ", address_array); } static int diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 8aba115d96..7604e3d534 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -248,7 +248,6 @@ xenParseXLCPUID(virConf *conf, virDomainDef *def) g_autofree char *cpuid_str = NULL; g_auto(GStrv) cpuid_pairs = NULL; size_t i; - int ret = -1; int policy; if (xenConfigGetString(conf, "cpuid", &cpuid_str, NULL) < 0) @@ -267,29 +266,27 @@ xenParseXLCPUID(virConf *conf, virDomainDef *def) cpuid_pairs = g_strsplit(cpuid_str, ",", 0); if (!cpuid_pairs) - goto cleanup; + return -1; - if (!cpuid_pairs[0]) { - ret = 0; - goto cleanup; - } + if (!cpuid_pairs[0]) + return 0; if (STRNEQ(cpuid_pairs[0], "host")) { virReportError(VIR_ERR_CONF_SYNTAX, _("cpuid starting with %s is not supported, only libxl format is"), cpuid_pairs[0]); - goto cleanup; + return -1; } for (i = 1; cpuid_pairs[i]; i++) { g_auto(GStrv) name_and_value = g_strsplit(cpuid_pairs[i], "=", 2); if (!name_and_value) - goto cleanup; + return -1; if (!name_and_value[0] || !name_and_value[1]) { virReportError(VIR_ERR_CONF_SYNTAX, _("Invalid libxl cpuid key=value element: %s"), cpuid_pairs[i]); - goto cleanup; + return -1; } if (STREQ(name_and_value[1], "1")) { policy = VIR_CPU_FEATURE_FORCE; @@ -305,19 +302,16 @@ xenParseXLCPUID(virConf *conf, virDomainDef *def) virReportError(VIR_ERR_CONF_SYNTAX, _("Invalid libxl cpuid value: %s"), cpuid_pairs[i]); - goto cleanup; + return -1; } if (virCPUDefAddFeature(def->cpu, xenTranslateCPUFeature(name_and_value[0], true), policy) < 0) - goto cleanup; + return -1; } - ret = 0; - - cleanup: - return ret; + return 0; } @@ -1292,7 +1286,6 @@ xenFormatXLCPUID(virConf *conf, virDomainDef *def) g_auto(GStrv) cpuid_pairs = NULL; g_autofree char *cpuid_string = NULL; size_t i, j; - int ret = -1; if (!def->cpu) return 0; @@ -1341,13 +1334,10 @@ xenFormatXLCPUID(virConf *conf, virDomainDef *def) cpuid_string = g_strjoinv(",", cpuid_pairs); if (xenConfigSetString(conf, "cpuid", cpuid_string) < 0) - goto cleanup; + return -1; } - ret = 0; - - cleanup: - return ret; + return 0; } static int diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index e9186b879e..8955578d54 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -65,14 +65,14 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) if ((caps = virCapabilitiesNew(virArchFromHost(), false, false)) == NULL) - goto error; + return NULL; /* Some machines have problematic NUMA topology causing * unexpected failures. We don't want to break the lxc * driver in this scenario, so log errors & carry on */ if (!(caps->host.numa = virCapabilitiesHostNUMANewHost())) - goto error; + return NULL; if (virCapabilitiesInitCaches(caps) < 0) VIR_WARN("Failed to get host CPU cache info"); @@ -89,13 +89,13 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) if (virGetHostUUID(caps->host.host_uuid)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot get the host uuid")); - goto error; + return NULL; } if (!(lxc_path = virFileFindResource("libvirt_lxc", abs_top_builddir "/src", LIBEXECDIR))) - goto error; + return NULL; guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE, caps->host.arch, lxc_path, NULL, 0, NULL); @@ -130,7 +130,7 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) virCapabilitiesHostSecModelAddBaseLabel(&caps->host.secModels[0], type, label) < 0) - goto error; + return NULL; VIR_DEBUG("Initialized caps for security driver \"%s\" with " "DOI \"%s\"", model, doi); @@ -139,9 +139,6 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) } return g_steal_pointer(&caps); - - error: - return NULL; } diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 13f2fd4c29..1d5b9bf429 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -515,13 +515,12 @@ static int lxcContainerUnmountSubtree(const char *prefix, size_t i; int saveErrno; const char *failedUmount = NULL; - int ret = -1; VIR_DEBUG("Unmount subtree from %s", prefix); if (virFileGetMountReverseSubtree("/proc/mounts", prefix, &mounts, &nmounts) < 0) - goto cleanup; + return -1; for (i = 0; i < nmounts; i++) { VIR_DEBUG("Umount %s", mounts[i]); if (umount(mounts[i]) < 0) { @@ -540,7 +539,7 @@ static int lxcContainerUnmountSubtree(const char *prefix, virReportSystemError(saveErrno, _("Failed to unmount '%s' and could not detach subtree '%s'"), failedUmount, mounts[nmounts-1]); - goto cleanup; + return -1; } /* This unmounts the tmpfs on which the old root filesystem was hosted */ if (isOldRootFS && @@ -548,14 +547,11 @@ static int lxcContainerUnmountSubtree(const char *prefix, virReportSystemError(saveErrno, _("Failed to unmount '%s' and could not unmount old root '%s'"), failedUmount, mounts[nmounts-1]); - goto cleanup; + return -1; } } - ret = 0; - - cleanup: - return ret; + return 0; } static int lxcContainerResolveSymlinks(virDomainFSDef *fs, bool gentle) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index aa4bdd68ac..fe583ccb76 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -928,7 +928,6 @@ static char *lxcConnectDomainXMLFromNative(virConnectPtr conn, const char *nativeConfig, unsigned int flags) { - char *xml = NULL; g_autoptr(virDomainDef) def = NULL; virLXCDriver *driver = conn->privateData; g_autoptr(virCaps) caps = virLXCDriverGetCapabilities(driver, false); @@ -936,21 +935,18 @@ static char *lxcConnectDomainXMLFromNative(virConnectPtr conn, virCheckFlags(0, NULL); if (virConnectDomainXMLFromNativeEnsureACL(conn) < 0) - goto cleanup; + return NULL; if (STRNEQ(nativeFormat, LXC_CONFIG_FORMAT)) { virReportError(VIR_ERR_INVALID_ARG, _("unsupported config type %s"), nativeFormat); - goto cleanup; + return NULL; } if (!(def = lxcParseConfigString(nativeConfig, caps, driver->xmlopt))) - goto cleanup; + return NULL; - xml = virDomainDefFormat(def, driver->xmlopt, 0); - - cleanup: - return xml; + return virDomainDefFormat(def, driver->xmlopt, 0); } /** diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index e9b58cbd1a..84ed33521f 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -119,7 +119,7 @@ static char ** lxcStringSplit(const char *string) } if (!(parts = g_strsplit(tmp, " ", 0))) - goto error; + return NULL; /* Append NULL element */ VIR_EXPAND_N(result, ntokens, 1); @@ -133,9 +133,6 @@ static char ** lxcStringSplit(const char *string) } return g_steal_pointer(&result); - - error: - return NULL; } static lxcFstab * @@ -250,7 +247,6 @@ lxcAddFstabLine(virDomainDef *def, lxcFstab *fstab) bool readonly; int type = VIR_DOMAIN_FS_TYPE_MOUNT; unsigned long long usage = 0; - int ret = -1; if (!options) return -1; @@ -262,10 +258,8 @@ lxcAddFstabLine(virDomainDef *def, lxcFstab *fstab) } /* Check that we don't add basic mounts */ - if (lxcIsBasicMountLocation(dst)) { - ret = 0; - goto cleanup; - } + if (lxcIsBasicMountLocation(dst)) + return 0; if (STREQ(fstab->type, "tmpfs")) { char *sizeStr = NULL; @@ -275,14 +269,14 @@ lxcAddFstabLine(virDomainDef *def, lxcFstab *fstab) for (i = 0; options[i]; i++) { if ((sizeStr = STRSKIP(options[i], "size="))) { if (lxcConvertSize(sizeStr, &usage) < 0) - goto cleanup; + return -1; break; } } if (!sizeStr) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing tmpfs size, set the size option")); - goto cleanup; + return -1; } } else { src = fstab->src; @@ -296,12 +290,9 @@ lxcAddFstabLine(virDomainDef *def, lxcFstab *fstab) readonly = g_strv_contains((const char **)options, "ro"); if (lxcAddFSDef(def, type, src, dst, readonly, usage) < 0) - goto cleanup; + return -1; - ret = 1; - - cleanup: - return ret; + return 1; } static int @@ -961,7 +952,6 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfValue *value, void *data) virDomainDef *def = data; size_t i = 0; g_autofree char *path = NULL; - int ret = -1; if (!STRPREFIX(name, "lxc.cgroup.blkio.") || STREQ(name, "lxc.cgroup.blkio.weight")|| !value->str) @@ -974,7 +964,7 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfValue *value, void *data) virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid %s value: '%s'"), name, value->str); - goto cleanup; + return -1; } path = g_strdup_printf("/dev/block/%s", parts[0]); @@ -996,44 +986,41 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfValue *value, void *data) if (virStrToLong_ui(parts[1], NULL, 10, &device->weight) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse device weight: '%s'"), parts[1]); - goto cleanup; + return -1; } } else if (STREQ(name, "lxc.cgroup.blkio.throttle.read_bps_device")) { if (virStrToLong_ull(parts[1], NULL, 10, &device->rbps) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse read_bps_device: '%s'"), parts[1]); - goto cleanup; + return -1; } } else if (STREQ(name, "lxc.cgroup.blkio.throttle.write_bps_device")) { if (virStrToLong_ull(parts[1], NULL, 10, &device->wbps) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse write_bps_device: '%s'"), parts[1]); - goto cleanup; + return -1; } } else if (STREQ(name, "lxc.cgroup.blkio.throttle.read_iops_device")) { if (virStrToLong_ui(parts[1], NULL, 10, &device->riops) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse read_iops_device: '%s'"), parts[1]); - goto cleanup; + return -1; } } else if (STREQ(name, "lxc.cgroup.blkio.throttle.write_iops_device")) { if (virStrToLong_ui(parts[1], NULL, 10, &device->wiops) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse write_iops_device: '%s'"), parts[1]); - goto cleanup; + return -1; } } else { VIR_WARN("Unhandled blkio tune config: %s", name); } - ret = 0; - - cleanup: - return ret; + return 0; } static int diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 9cae025517..625208c86b 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -361,7 +361,6 @@ virLXCProcessSetupInterfaceDirect(virLXCDriver *driver, virDomainDef *def, virDomainNetDef *net) { - char *ret = NULL; char *res_ifname = NULL; const virNetDevBandwidth *bw; const virNetDevVPortProfile *prof; @@ -407,12 +406,9 @@ virLXCProcessSetupInterfaceDirect(virLXCDriver *driver, cfg->stateDir, NULL, 0, macvlan_create_flags) < 0) - goto cleanup; + return NULL; - ret = res_ifname; - - cleanup: - return ret; + return res_ifname; } static const char *nsInfoLocal[VIR_LXC_DOMAIN_NAMESPACE_LAST] = { @@ -834,7 +830,7 @@ static virLXCMonitor *virLXCProcessConnectMonitor(virLXCDriver *driver, g_autoptr(virLXCDriverConfig) cfg = virLXCDriverGetConfig(driver); if (virSecurityManagerSetSocketLabel(driver->securityManager, vm->def) < 0) - goto cleanup; + return NULL; /* Hold an extra reference because we can't allow 'vm' to be * deleted while the monitor is active. This will be unreffed @@ -847,14 +843,11 @@ static virLXCMonitor *virLXCProcessConnectMonitor(virLXCDriver *driver, virObjectUnref(vm); if (virSecurityManagerClearSocketLabel(driver->securityManager, vm->def) < 0) { - if (monitor) { + if (monitor) virObjectUnref(monitor); - monitor = NULL; - } - goto cleanup; + return NULL; } - cleanup: return monitor; } @@ -1015,7 +1008,7 @@ virLXCProcessBuildControllerCmd(virLXCDriver *driver, virCommandRequireHandshake(cmd); cleanup: - return cmd; + return cmd; error: virCommandFree(cmd); cmd = NULL; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 020a9e5df0..0e93b79922 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -298,12 +298,12 @@ testBuildCapabilities(virConnectPtr conn) size_t i, j; if ((caps = virCapabilitiesNew(VIR_ARCH_I686, false, false)) == NULL) - goto error; + return NULL; if (virCapabilitiesAddHostFeature(caps, "pae") < 0) - goto error; + return NULL; if (virCapabilitiesAddHostFeature(caps, "nonpae") < 0) - goto error; + return NULL; virCapabilitiesHostInitIOMMU(caps); @@ -362,9 +362,6 @@ testBuildCapabilities(virConnectPtr conn) caps->host.secModels[0].doi = g_strdup(""); return g_steal_pointer(&caps); - - error: - return NULL; } diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index bf8db47ad4..5cfc20f1ed 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -853,10 +853,9 @@ virCgroupSetPartitionSuffix(const char *path, char **res) { g_auto(GStrv) tokens = NULL; size_t i; - int ret = -1; if (!(tokens = g_strsplit(path, "/", 0))) - return ret; + return -1; for (i = 0; tokens[i] != NULL; i++) { /* Special case the 3 top level fixed dirs @@ -878,16 +877,13 @@ virCgroupSetPartitionSuffix(const char *path, char **res) } if (virCgroupPartitionEscape(&(tokens[i])) < 0) - goto cleanup; + return -1; } if (!(*res = g_strjoinv("/", tokens))) - goto cleanup; + return -1; - ret = 0; - - cleanup: - return ret; + return 0; } diff --git a/src/util/virfirmware.c b/src/util/virfirmware.c index cc5e315b7a..b2e3491544 100644 --- a/src/util/virfirmware.c +++ b/src/util/virfirmware.c @@ -58,11 +58,10 @@ virFirmwareFreeList(virFirmware **firmwares, size_t nfirmwares) int virFirmwareParse(const char *str, virFirmware *firmware) { - int ret = -1; g_auto(GStrv) token = NULL; if (!(token = g_strsplit(str, ":", 0))) - goto cleanup; + return -1; if (token[0]) { virSkipSpaces((const char **) &token[0]); @@ -76,15 +75,13 @@ virFirmwareParse(const char *str, virFirmware *firmware) virReportError(VIR_ERR_CONF_SYNTAX, _("Invalid nvram format: '%s'"), str); - goto cleanup; + return -1; } firmware->name = g_strdup(token[0]); firmware->nvram = g_strdup(token[1]); - ret = 0; - cleanup: - return ret; + return 0; } @@ -93,12 +90,11 @@ virFirmwareParseList(const char *list, virFirmware ***firmwares, size_t *nfirmwares) { - int ret = -1; g_auto(GStrv) token = NULL; size_t i, j; if (!(token = g_strsplit(list, ":", 0))) - goto cleanup; + return -1; for (i = 0; token[i]; i += 2) { if (!token[i] || !token[i + 1] || @@ -106,7 +102,7 @@ virFirmwareParseList(const char *list, virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid --with-loader-nvram list: %s"), list); - goto cleanup; + return -1; } } @@ -123,7 +119,5 @@ virFirmwareParseList(const char *list, } } - ret = 0; - cleanup: - return ret; + return 0; } diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 1353efa6ab..c16cc2be00 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -115,32 +115,29 @@ vzBuildCapabilities(void) return NULL; if (!(caps->host.numa = virCapabilitiesHostNUMANewHost())) - goto error; + return NULL; if (virCapabilitiesInitCaches(caps) < 0) - goto error; + return NULL; for (i = 0; i < G_N_ELEMENTS(ostypes); i++) for (j = 0; j < G_N_ELEMENTS(archs); j++) for (k = 0; k < G_N_ELEMENTS(emulators); k++) if (vzCapsAddGuestDomain(caps, ostypes[i], archs[j], emulators[k], virt_types[k]) < 0) - goto error; + return NULL; if (virCapabilitiesGetNodeInfo(&nodeinfo)) - goto error; + return NULL; if (!(caps->host.cpu = virCPUGetHost(caps->host.arch, VIR_CPU_TYPE_HOST, &nodeinfo, NULL))) - goto error; + return NULL; if (virCapabilitiesAddHostMigrateTransport(caps, "vzmigr") < 0) - goto error; + return NULL; return g_steal_pointer(&caps); - - error: - return NULL; } static void vzDriverDispose(void * obj) diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c index aec4647678..942c8e7aa4 100644 --- a/tests/qemucaps2xmltest.c +++ b/tests/qemucaps2xmltest.c @@ -94,12 +94,12 @@ testGetCaps(char *capsData, const testQemuData *data) if ((qemuCaps = testQemuGetCaps(capsData)) == NULL) { fprintf(stderr, "failed to parse qemu capabilities flags"); - goto error; + return NULL; } if ((caps = virCapabilitiesNew(arch, false, false)) == NULL) { fprintf(stderr, "failed to create the fake capabilities"); - goto error; + return NULL; } if (virQEMUCapsInitGuestFromBinary(caps, @@ -107,13 +107,10 @@ testGetCaps(char *capsData, const testQemuData *data) qemuCaps, arch) < 0) { fprintf(stderr, "failed to create the capabilities from qemu"); - goto error; + return NULL; } return g_steal_pointer(&caps); - - error: - return NULL; } static int diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c index d69eb3fc24..3ad8298895 100644 --- a/tests/vboxsnapshotxmltest.c +++ b/tests/vboxsnapshotxmltest.c @@ -21,11 +21,10 @@ testFilterXML(char *xml) g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_auto(GStrv) xmlLines = NULL; char **xmlLine; - char *ret = NULL; if (!(xmlLines = g_strsplit(xml, "\n", 0))) { VIR_FREE(xml); - goto cleanup; + return NULL; } VIR_FREE(xml); @@ -36,10 +35,7 @@ testFilterXML(char *xml) virBufferStrcat(&buf, *xmlLine, "\n", NULL); } - ret = virBufferContentAndReset(&buf); - - cleanup: - return ret; + return virBufferContentAndReset(&buf); } static int diff --git a/tests/virconftest.c b/tests/virconftest.c index 32d3d8849b..3b203b6ae6 100644 --- a/tests/virconftest.c +++ b/tests/virconftest.c @@ -370,7 +370,6 @@ static int testConfParseStringList(const void *opaque G_GNUC_UNUSED) "string_list = [\"foo\", \"bar\"]\n" \ "string = \"foo\"\n"; - int ret = -1; g_autoptr(virConf) conf = virConfReadString(srcdata, 0); g_auto(GStrv) str = NULL; @@ -380,50 +379,47 @@ static int testConfParseStringList(const void *opaque G_GNUC_UNUSED) if (virConfGetValueType(conf, "string_list") != VIR_CONF_LIST) { fprintf(stderr, "expected a list for 'string_list'\n"); - goto cleanup; + return -1; } if (virConfGetValueStringList(conf, "string_list", false, &str) < 0) - goto cleanup; + return -1; if (!str || g_strv_length(str) != 2) { fprintf(stderr, "expected a 2 element list\n"); - goto cleanup; + return -1; } if (STRNEQ_NULLABLE(str[0], "foo")) { fprintf(stderr, "Expected 'foo' got '%s'\n", str[0]); - goto cleanup; + return -1; } if (STRNEQ_NULLABLE(str[1], "bar")) { fprintf(stderr, "Expected 'bar' got '%s'\n", str[1]); - goto cleanup; + return -1; } if (virConfGetValueStringList(conf, "string", false, &str) != -1) { fprintf(stderr, "Expected error for 'string'\n"); - goto cleanup; + return -1; } if (virConfGetValueStringList(conf, "string", true, &str) < 0) - goto cleanup; + return -1; if (!str || g_strv_length(str) != 1) { fprintf(stderr, "expected a 1 element list\n"); - goto cleanup; + return -1; } if (STRNEQ_NULLABLE(str[0], "foo")) { fprintf(stderr, "Expected 'foo' got '%s'\n", str[0]); - goto cleanup; + return -1; } - - ret = 0; - cleanup: - return ret; + return 0; } diff --git a/tests/virfiletest.c b/tests/virfiletest.c index 2fbece8f63..1e95c77d06 100644 --- a/tests/virfiletest.c +++ b/tests/virfiletest.c @@ -64,7 +64,6 @@ struct testFileGetMountSubtreeData { static int testFileGetMountSubtree(const void *opaque) { - int ret = -1; g_auto(GStrv) gotmounts = NULL; size_t gotnmounts = 0; const struct testFileGetMountSubtreeData *data = opaque; @@ -74,21 +73,18 @@ static int testFileGetMountSubtree(const void *opaque) data->prefix, &gotmounts, &gotnmounts) < 0) - goto cleanup; + return -1; } else { if (virFileGetMountSubtree(data->path, data->prefix, &gotmounts, &gotnmounts) < 0) - goto cleanup; + return -1; } - ret = testFileCheckMounts(data->prefix, - gotmounts, gotnmounts, - data->mounts, data->nmounts); - - cleanup: - return ret; + return testFileCheckMounts(data->prefix, + gotmounts, gotnmounts, + data->mounts, data->nmounts); } #endif /* ! defined WITH_MNTENT_H && defined WITH_GETMNTENT_R */ diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 77fcec5613..b406076020 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -129,7 +129,6 @@ testStringSearch(const void *opaque) const struct stringSearchData *data = opaque; g_auto(GStrv) matches = NULL; ssize_t nmatches; - int ret = -1; nmatches = virStringSearch(data->str, data->regexp, data->maxMatches, &matches); @@ -138,7 +137,7 @@ testStringSearch(const void *opaque) if (nmatches != -1) { fprintf(stderr, "expected error on %s but got %zd matches\n", data->str, nmatches); - goto cleanup; + return -1; } } else { size_t i; @@ -146,35 +145,32 @@ testStringSearch(const void *opaque) if (nmatches < 0) { fprintf(stderr, "expected %zu matches on %s but got error\n", data->expectNMatches, data->str); - goto cleanup; + return -1; } if (nmatches != data->expectNMatches) { fprintf(stderr, "expected %zu matches on %s but got %zd\n", data->expectNMatches, data->str, nmatches); - goto cleanup; + return -1; } if (g_strv_length(matches) != nmatches) { fprintf(stderr, "expected %zu matches on %s but got %u matches\n", data->expectNMatches, data->str, g_strv_length(matches)); - goto cleanup; + return -1; } for (i = 0; i < nmatches; i++) { if (STRNEQ(matches[i], data->expectMatches[i])) { fprintf(stderr, "match %zu expected '%s' but got '%s'\n", i, data->expectMatches[i], matches[i]); - goto cleanup; + return -1; } } } - ret = 0; - - cleanup: - return ret; + return 0; }