After previous cleanups some labels became needles because they contain just a return statement. There's no point in having such labels. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/bhyve/bhyve_parse_command.c | 15 ++++++-------- src/conf/domain_conf.c | 4 +--- src/conf/virdomainobjlist.c | 13 +++++------- src/libxl/libxl_domain.c | 12 ++++------- src/libxl/libxl_driver.c | 24 +++++++++------------- src/libxl/xen_xl.c | 29 ++++++++++++--------------- src/libxl/xen_xm.c | 13 +++++------- src/lxc/lxc_native.c | 35 +++++++++++++++------------------ src/qemu/qemu_saveimage.c | 14 +++++-------- src/test/test_driver.c | 12 ++++------- src/vz/vz_driver.c | 18 +++++++---------- src/vz/vz_sdk.c | 35 +++++++++++++++------------------ 12 files changed, 91 insertions(+), 133 deletions(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 6ee3c8305b..2a5959ba1d 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -941,14 +941,14 @@ bhyveParseCommandLineString(const char* nativeConfig, g_auto(GStrv) loader_argv = NULL; if (!(def = virDomainDefNew(xmlopt))) - goto cleanup; + return NULL; /* Initialize defaults. */ def->virtType = VIR_DOMAIN_VIRT_BHYVE; if (virUUIDGenerate(def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to generate uuid")); - goto cleanup; + return NULL; } def->id = -1; def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME; @@ -958,21 +958,18 @@ bhyveParseCommandLineString(const char* nativeConfig, &bhyve_argc, &bhyve_argv)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to convert the command string to argv-lists")); - goto error; + return NULL; } if (bhyveParseBhyveCommandLine(def, xmlopt, caps, bhyve_argc, bhyve_argv)) - goto error; + return NULL; if (loader_argv && STREQ(loader_argv[0], "/usr/sbin/bhyveload")) { if (bhyveParseBhyveLoadCommandLine(def, loader_argc, loader_argv)) - goto error; + return NULL; } else if (loader_argv) { if (bhyveParseCustomLoaderCommandLine(def, loader_argc, loader_argv)) - goto error; + return NULL; } - cleanup: return g_steal_pointer(&def); - error: - goto cleanup; } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4059acba7f..107d2a4f5d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3845,7 +3845,7 @@ virDomainDefNew(virDomainXMLOption *xmlopt) ret = g_new0(virDomainDef, 1); if (!(ret->numa = virDomainNumaNew())) - goto error; + return NULL; ret->mem.hard_limit = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; ret->mem.soft_limit = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; @@ -3857,8 +3857,6 @@ virDomainDefNew(virDomainXMLOption *xmlopt) ret->scsiBusMaxUnit = SCSI_NARROW_BUS_MAX_CONT_UNIT; return g_steal_pointer(&ret); - error: - return NULL; } diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 7d3828162b..70b73e87ec 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -489,21 +489,21 @@ virDomainObjListLoadConfig(virDomainObjList *doms, g_autoptr(virDomainDef) oldDef = NULL; if ((configFile = virDomainConfigFile(configDir, name)) == NULL) - goto error; + return NULL; if (!(def = virDomainDefParseFile(configFile, xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL))) - goto error; + return NULL; if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL) - goto error; + return NULL; if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) - goto error; + return NULL; if (!(dom = virDomainObjListAddLocked(doms, &def, xmlopt, 0, &oldDef))) - goto error; + return NULL; dom->autostart = autostart; @@ -511,9 +511,6 @@ virDomainObjListLoadConfig(virDomainObjList *doms, (*notify)(dom, oldDef == NULL, opaque); return dom; - - error: - return NULL; } diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index b3a9521e16..60079ba63f 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1487,20 +1487,16 @@ libxlDomainDefCheckABIStability(libxlDriverPrivate *driver, virDomainDef *src, virDomainDef *dst) { - bool ret = false; g_autoptr(virDomainDef) migratableDefSrc = NULL; g_autoptr(virDomainDef) migratableDefDst = NULL; if (!(migratableDefSrc = virDomainDefCopy(src, driver->xmlopt, NULL, true)) || !(migratableDefDst = virDomainDefCopy(dst, driver->xmlopt, NULL, true))) - goto cleanup; + return false; - ret = virDomainDefCheckABIStability(migratableDefSrc, - migratableDefDst, - driver->xmlopt); - - cleanup: - return ret; + return virDomainDefCheckABIStability(migratableDefSrc, + migratableDefDst, + driver->xmlopt); } diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 5b49089f7d..0b14b5093e 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5824,7 +5824,7 @@ libxlDomainMigratePrepareTunnel3Params(virConnectPtr dconn, virCheckFlags(LIBXL_MIGRATION_FLAGS, -1); if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0) - goto error; + return -1; if (virTypedParamsGetString(params, nparams, VIR_MIGRATE_PARAM_DEST_XML, @@ -5836,22 +5836,19 @@ libxlDomainMigratePrepareTunnel3Params(virConnectPtr dconn, VIR_MIGRATE_PARAM_URI, &uri_in) < 0) - goto error; + return -1; if (!(def = libxlDomainMigrationDstPrepareDef(driver, dom_xml, dname))) - goto error; + return -1; if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0) - goto error; + return -1; if (libxlDomainMigrationDstPrepareTunnel3(dconn, st, &def, cookiein, cookieinlen, flags) < 0) - goto error; + return -1; return 0; - - error: - return -1; } static int @@ -5890,22 +5887,19 @@ libxlDomainMigratePrepare3Params(virConnectPtr dconn, VIR_MIGRATE_PARAM_URI, &uri_in) < 0) - goto error; + return -1; if (!(def = libxlDomainMigrationDstPrepareDef(driver, dom_xml, dname))) - goto error; + return -1; if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) - goto error; + return -1; if (libxlDomainMigrationDstPrepare(dconn, &def, uri_in, uri_out, cookiein, cookieinlen, flags) < 0) - goto error; + return -1; return 0; - - error: - return -1; } static int diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index fc05f8f502..8aba115d96 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1126,49 +1126,46 @@ xenParseXL(virConf *conf, if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XL, xmlopt) < 0) - goto cleanup; + return NULL; if (xenParseXLOS(conf, def, caps) < 0) - goto cleanup; + return NULL; if (xenParseXLVnuma(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXLXenbusLimits(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXLCPUID(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXLDisk(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXLSpice(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXLInputDevs(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXLUSB(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXLUSBController(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXLChannel(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXLNamespaceData(conf, def) < 0) - goto cleanup; + return NULL; if (virDomainDefPostParse(def, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, xmlopt, NULL) < 0) - goto cleanup; + return NULL; return g_steal_pointer(&def); - - cleanup: - return NULL; } diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 1fc3e99b08..9c2d091918 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -418,25 +418,22 @@ xenParseXM(virConf *conf, if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XM, xmlopt) < 0) - goto cleanup; + return NULL; if (xenParseXMOS(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXMDiskList(conf, def) < 0) - goto cleanup; + return NULL; if (xenParseXMInputDevs(conf, def) < 0) - goto cleanup; + return NULL; if (virDomainDefPostParse(def, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, xmlopt, NULL) < 0) - goto cleanup; + return NULL; return g_steal_pointer(&def); - - cleanup: - return NULL; } static int diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 8f38c6e086..972e9cdc15 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -1094,12 +1094,12 @@ lxcParseConfigString(const char *config, return NULL; if (!(vmdef = virDomainDefNew(xmlopt))) - goto error; + return NULL; if (virUUIDGenerate(vmdef->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to generate uuid")); - goto error; + return NULL; } vmdef->id = -1; @@ -1113,10 +1113,10 @@ lxcParseConfigString(const char *config, /* Value not handled by the LXC driver, setting to * minimum required to make XML parsing pass */ if (virDomainDefSetVcpusMax(vmdef, 1, xmlopt) < 0) - goto error; + return NULL; if (virDomainDefSetVcpus(vmdef, 1) < 0) - goto error; + return NULL; vmdef->nfss = 0; vmdef->os.type = VIR_DOMAIN_OSTYPE_EXE; @@ -1139,7 +1139,7 @@ lxcParseConfigString(const char *config, /* Check for pre LXC 3.0 legacy key */ if (virConfGetValueString(properties, "lxc.utsname", &value) <= 0) - goto error; + return NULL; } vmdef->name = g_strdup(value); @@ -1148,7 +1148,7 @@ lxcParseConfigString(const char *config, vmdef->name = g_strdup("unnamed"); if (lxcSetRootfs(vmdef, properties) < 0) - goto error; + return NULL; /* LXC 3.0 uses "lxc.mount.fstab", while legacy used just "lxc.mount". * In either case, generate the error to use "lxc.mount.entry" instead */ @@ -1157,50 +1157,47 @@ lxcParseConfigString(const char *config, virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("lxc.mount.fstab or lxc.mount found, use " "lxc.mount.entry lines instead")); - goto error; + return NULL; } /* Loop over lxc.mount.entry to add filesystem devices for them */ if (virConfWalk(properties, lxcFstabWalkCallback, vmdef) < 0) - goto error; + return NULL; /* Network configuration */ if (lxcConvertNetworkSettings(vmdef, properties) < 0) - goto error; + return NULL; /* Consoles */ if (lxcCreateConsoles(vmdef, properties) < 0) - goto error; + return NULL; /* lxc.idmap or legacy lxc.id_map */ if (virConfWalk(properties, lxcIdmapWalkCallback, vmdef) < 0) - goto error; + return NULL; /* lxc.cgroup.memory.* */ if (lxcSetMemTune(vmdef, properties) < 0) - goto error; + return NULL; /* lxc.cgroup.cpu.* */ if (lxcSetCpuTune(vmdef, properties) < 0) - goto error; + return NULL; /* lxc.cgroup.cpuset.* */ if (lxcSetCpusetTune(vmdef, properties) < 0) - goto error; + return NULL; /* lxc.cgroup.blkio.* */ if (lxcSetBlkioTune(vmdef, properties) < 0) - goto error; + return NULL; /* lxc.cap.drop */ lxcSetCapDrop(vmdef, properties); if (virDomainDefPostParse(vmdef, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, xmlopt, NULL) < 0) - goto error; + return NULL; return g_steal_pointer(&vmdef); - - error: - return NULL; } diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index cdba3aa34d..557ee2cd21 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -718,19 +718,18 @@ qemuSaveImageUpdateDef(virQEMUDriver *driver, virDomainDef *def, const char *newxml) { - virDomainDef *ret = NULL; g_autoptr(virDomainDef) newdef_migr = NULL; g_autoptr(virDomainDef) newdef = NULL; if (!(newdef = virDomainDefParseString(newxml, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) - goto cleanup; + return NULL; if (!(newdef_migr = qemuDomainDefCopy(driver, NULL, newdef, QEMU_DOMAIN_FORMAT_LIVE_FLAGS | VIR_DOMAIN_XML_MIGRATABLE))) - goto cleanup; + return NULL; if (!virDomainDefCheckABIStability(def, newdef_migr, driver->xmlopt)) { virErrorPtr save_err; @@ -745,16 +744,13 @@ qemuSaveImageUpdateDef(virQEMUDriver *driver, * fails. Snapshots created prior to v1.1.3 have this issue. */ if (!virDomainDefCheckABIStability(def, newdef, driver->xmlopt)) { virErrorRestore(&save_err); - goto cleanup; + return NULL; } virFreeError(save_err); /* use the user provided XML */ - ret = g_steal_pointer(&newdef); - } else { - ret = g_steal_pointer(&newdef_migr); + return g_steal_pointer(&newdef); } - cleanup: - return ret; + return g_steal_pointer(&newdef_migr); } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4d6ee3098e..7ad6e15402 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2552,7 +2552,6 @@ testDomainSaveImageDefineXML(virConnectPtr conn, const char *dxml, unsigned int flags) { - int ret = -1; int fd = -1; g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) newdef = NULL; @@ -2562,20 +2561,17 @@ testDomainSaveImageDefineXML(virConnectPtr conn, VIR_DOMAIN_SAVE_PAUSED, -1); if ((fd = testDomainSaveImageOpen(privconn, path, &def)) < 0) - goto cleanup; + return -1; VIR_FORCE_CLOSE(fd); if ((newdef = virDomainDefParseString(dxml, privconn->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL) - goto cleanup; + return -1; if (!testDomainSaveImageWrite(privconn, path, newdef)) - goto cleanup; + return -1; - ret = 0; - - cleanup: - return ret; + return 0; } diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index ff5f7cb2e7..83ff119dd9 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -2964,12 +2964,11 @@ vzDomainMigratePrepare3Params(virConnectPtr conn, const char *dname = NULL; const char *dom_xml = NULL; g_autoptr(virDomainDef) def = NULL; - int ret = -1; virCheckFlags(VZ_MIGRATION_FLAGS, -1); if (virTypedParamsValidate(params, nparams, VZ_MIGRATION_PARAMETERS) < 0) - goto cleanup; + return -1; if (virTypedParamsGetString(params, nparams, VIR_MIGRATE_PARAM_URI, &miguri) < 0 || @@ -2977,12 +2976,12 @@ vzDomainMigratePrepare3Params(virConnectPtr conn, VIR_MIGRATE_PARAM_DEST_XML, &dom_xml) < 0 || virTypedParamsGetString(params, nparams, VIR_MIGRATE_PARAM_DEST_NAME, &dname) < 0) - goto cleanup; + return -1; /* We must set uri_out if miguri is not set. This is direct * managed migration requirement */ if (!miguri && !(*uri_out = vzMigrationCreateURI())) - goto cleanup; + return -1; /* domain uuid and domain name are for backward compat */ if (vzBakeCookie(privconn->driver, NULL, @@ -2990,12 +2989,12 @@ vzDomainMigratePrepare3Params(virConnectPtr conn, VZ_MIGRATION_COOKIE_SESSION_UUID | VZ_MIGRATION_COOKIE_DOMAIN_UUID | VZ_MIGRATION_COOKIE_DOMAIN_NAME) < 0) - goto cleanup; + return -1; if (!(def = virDomainDefParseString(dom_xml, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) - goto cleanup; + return -1; if (dname) { VIR_FREE(def->name); @@ -3003,12 +3002,9 @@ vzDomainMigratePrepare3Params(virConnectPtr conn, } if (virDomainMigratePrepare3ParamsEnsureACL(conn, def) < 0) - goto cleanup; + return -1; - ret = 0; - - cleanup: - return ret; + return 0; } static int diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 7869b5c94d..5ed33902fd 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1789,10 +1789,10 @@ prlsdkLoadDomain(struct _vzDriver *driver, char uuidstr[VIR_UUID_STRING_BRACED_BUFLEN]; if (!(def = virDomainDefNew(driver->xmlopt))) - goto error; + return NULL; if (!(def->name = prlsdkGetStringParamVar(PrlVmCfg_GetName, sdkdom))) - goto error; + return NULL; pret = prlsdkGetStringParamBuf(PrlVmCfg_GetUuid, sdkdom, uuidstr, sizeof(uuidstr)); @@ -1801,7 +1801,7 @@ prlsdkLoadDomain(struct _vzDriver *driver, if (prlsdkUUIDParse(uuidstr, def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Domain UUID is malformed or empty")); - goto error; + return NULL; } def->virtType = VIR_DOMAIN_VIRT_VZ; @@ -1818,24 +1818,24 @@ prlsdkLoadDomain(struct _vzDriver *driver, def->mem.cur_balloon = ram << 10; if (prlsdkConvertCpuInfo(sdkdom, def, driver->xmlopt) < 0) - goto error; + return NULL; if (prlsdkConvertCpuMode(sdkdom, def) < 0) - goto error; + return NULL; if (prlsdkConvertDomainType(sdkdom, def) < 0) - goto error; + return NULL; if (prlsdkAddVNCInfo(sdkdom, def) < 0) - goto error; + return NULL; /* depends on prlsdkAddVNCInfo */ if (prlsdkAddDomainHardware(driver, sdkdom, def, driver->xmlopt) < 0) - goto error; + return NULL; /* depends on prlsdkAddDomainHardware */ if (!IS_CT(def) && prlsdkConvertBootOrderVm(sdkdom, def) < 0) - goto error; + return NULL; pret = PrlVmCfg_GetEnvId(sdkdom, &envId); prlsdkCheckRetGoto(pret, error); @@ -1846,14 +1846,14 @@ prlsdkLoadDomain(struct _vzDriver *driver, autostart != PAO_VM_START_MANUAL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown autostart mode: %X"), autostart); - goto error; + return NULL; } if (prlsdkGetDomainState(dom, sdkdom, &domainState) < 0) - goto error; + return NULL; if (!IS_CT(def) && virDomainDefAddImplicitDevices(def, driver->xmlopt) < 0) - goto error; + return NULL; if (def->ngraphics > 0) { int bus = IS_CT(def) ? VIR_DOMAIN_INPUT_BUS_PARALLELS : @@ -1862,12 +1862,12 @@ prlsdkLoadDomain(struct _vzDriver *driver, if (virDomainDefMaybeAddInput(def, VIR_DOMAIN_INPUT_TYPE_MOUSE, bus) < 0) - goto error; + return NULL; if (virDomainDefMaybeAddInput(def, VIR_DOMAIN_INPUT_TYPE_KBD, bus) < 0) - goto error; + return NULL; } if (!dom) { @@ -1875,7 +1875,7 @@ prlsdkLoadDomain(struct _vzDriver *driver, job = PrlVm_SubscribeToPerfStats(sdkdom, NULL); if (PRL_FAILED(waitJob(job))) - goto error; + return NULL; virObjectLock(driver); if (!(olddom = virDomainObjListFindByUUID(driver->domains, def->uuid))) @@ -1885,7 +1885,7 @@ prlsdkLoadDomain(struct _vzDriver *driver, if (olddom) { return olddom; } else if (!dom) { - goto error; + return NULL; } pdom = dom->privateData; @@ -1911,9 +1911,6 @@ prlsdkLoadDomain(struct _vzDriver *driver, dom->autostart = 0; return dom; - - error: - return NULL; } int -- 2.32.0