From d43f393134fc8c948c81c1bf86376d337d9604a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 28 Jul 2020 23:17:02 +0200 Subject: [PATCH] tests: qemu: remove unnecessary labels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ján Tomko Reviewed-by: Laine Stump --- tests/qemucapabilitiestest.c | 14 ++++------- tests/qemucaps2xmltest.c | 13 ++++------ tests/qemudomainsnapshotxml2xmltest.c | 20 +++++++--------- tests/qemuhotplugtest.c | 14 ++++------- tests/qemumemlocktest.c | 9 ++----- tests/qemumigparamstest.c | 14 ++++------- tests/qemumonitortestutils.c | 34 ++++++++++----------------- 7 files changed, 43 insertions(+), 75 deletions(-) diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index 81f29c6493..82309b44bb 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -141,7 +141,6 @@ testQemuCaps(const void *opaque) static int testQemuCapsCopy(const void *opaque) { - int ret = -1; const testQemuData *data = opaque; g_autofree char *capsFile = NULL; g_autoptr(virQEMUCaps) orig = NULL; @@ -154,21 +153,18 @@ testQemuCapsCopy(const void *opaque) if (!(orig = qemuTestParseCapabilitiesArch( virArchFromString(data->archName), capsFile))) - goto cleanup; + return -1; if (!(copy = virQEMUCapsNewCopy(orig))) - goto cleanup; + return -1; if (!(actual = virQEMUCapsFormatCache(copy))) - goto cleanup; + return -1; if (virTestCompareToFile(actual, capsFile) < 0) - goto cleanup; + return -1; - ret = 0; - - cleanup: - return ret; + return 0; } diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c index 5316a221ff..af4c96cb69 100644 --- a/tests/qemucaps2xmltest.c +++ b/tests/qemucaps2xmltest.c @@ -129,7 +129,6 @@ testGetCaps(char *capsData, const testQemuData *data) static int testQemuCapsXML(const void *opaque) { - int ret = -1; const testQemuData *data = opaque; g_autofree char *capsFile = NULL; g_autofree char *xmlFile = NULL; @@ -144,21 +143,19 @@ testQemuCapsXML(const void *opaque) data->archName, data->suffix); if (virTestLoadFile(capsFile, &capsData) < 0) - goto cleanup; + return -1; if (!(capsProvided = testGetCaps(capsData, data))) - goto cleanup; + return -1; capsXml = virCapabilitiesFormatXML(capsProvided); if (!capsXml) - goto cleanup; + return -1; if (virTestCompareToFile(capsXml, xmlFile) < 0) - goto cleanup; + return -1; - ret = 0; - cleanup: - return ret; + return 0; } static int diff --git a/tests/qemudomainsnapshotxml2xmltest.c b/tests/qemudomainsnapshotxml2xmltest.c index 6c10f3e953..4b92967339 100644 --- a/tests/qemudomainsnapshotxml2xmltest.c +++ b/tests/qemudomainsnapshotxml2xmltest.c @@ -34,7 +34,6 @@ testCompareXMLToXMLFiles(const char *inxml, g_autofree char *inXmlData = NULL; g_autofree char *outXmlData = NULL; g_autofree char *actual = NULL; - int ret = -1; unsigned int parseflags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; unsigned int formatflags = VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE; bool cur = false; @@ -49,40 +48,37 @@ testCompareXMLToXMLFiles(const char *inxml, parseflags |= VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE; if (virTestLoadFile(inxml, &inXmlData) < 0) - goto cleanup; + return -1; if (virTestLoadFile(outxml, &outXmlData) < 0) - goto cleanup; + return -1; if (!(def = virDomainSnapshotDefParseString(inXmlData, driver.xmlopt, NULL, &cur, parseflags))) - goto cleanup; + return -1; if (cur) { if (!(flags & TEST_INTERNAL)) - goto cleanup; + return -1; formatflags |= VIR_DOMAIN_SNAPSHOT_FORMAT_CURRENT; } if (flags & TEST_RUNNING) { if (def->state) - goto cleanup; + return -1; def->state = VIR_DOMAIN_RUNNING; } if (!(actual = virDomainSnapshotDefFormat(uuid, def, driver.xmlopt, formatflags))) - goto cleanup; + return -1; if (STRNEQ(outXmlData, actual)) { virTestDifferenceFull(stderr, outXmlData, outxml, actual, inxml); - goto cleanup; + return -1; } - ret = 0; - - cleanup: - return ret; + return 0; } struct testInfo { diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index ba644abe8a..1e18820a2b 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -472,33 +472,29 @@ testQemuHotplugCpuPrepare(const char *test, static int testQemuHotplugCpuFinalize(struct testQemuHotplugCpuData *data) { - int ret = -1; g_autofree char *activeXML = NULL; g_autofree char *configXML = NULL; if (data->file_xml_res_live) { if (!(activeXML = virDomainDefFormat(data->vm->def, driver.xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE))) - goto cleanup; + return -1; if (virTestCompareToFile(activeXML, data->file_xml_res_live) < 0) - goto cleanup; + return -1; } if (data->file_xml_res_conf) { if (!(configXML = virDomainDefFormat(data->vm->newDef, driver.xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE | VIR_DOMAIN_DEF_FORMAT_INACTIVE))) - goto cleanup; + return -1; if (virTestCompareToFile(configXML, data->file_xml_res_conf) < 0) - goto cleanup; + return -1; } - ret = 0; - - cleanup: - return ret; + return 0; } diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c index 68e446ba7b..86057e9a3a 100644 --- a/tests/qemumemlocktest.c +++ b/tests/qemumemlocktest.c @@ -32,21 +32,16 @@ testCompareMemLock(const void *data) const struct testInfo *info = data; g_autoptr(virDomainDef) def = NULL; g_autofree char *xml = NULL; - int ret = -1; xml = g_strdup_printf("%s/qemumemlockdata/qemumemlock-%s.xml", abs_srcdir, info->name); if (!(def = virDomainDefParseFile(xml, driver.xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) { - goto cleanup; + return -1; } - ret = virTestCompareToULL(info->memlock, qemuDomainGetMemLockLimitBytes(def, false)); - - cleanup: - - return ret; + return virTestCompareToULL(info->memlock, qemuDomainGetMemLockLimitBytes(def, false)); } # define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c index e6e6bf7138..0f7809d763 100644 --- a/tests/qemumigparamstest.c +++ b/tests/qemumigparamstest.c @@ -64,29 +64,25 @@ qemuMigParamsTestXML2XML(const void *opaque) g_autoptr(xmlXPathContext) ctxt = NULL; g_autoptr(qemuMigrationParams) migParams = NULL; g_autofree char *actualXML = NULL; - int ret = -1; xmlFile = g_strdup_printf("%s/qemumigparamsdata/%s.xml", abs_srcdir, data->name); if (!(doc = virXMLParseFileCtxt(xmlFile, &ctxt))) - goto cleanup; + return -1; if (qemuMigrationParamsParse(ctxt, &migParams) < 0) - goto cleanup; + return -1; qemuMigParamsTestFormatXML(&buf, migParams); if (!(actualXML = virBufferContentAndReset(&buf))) - goto cleanup; + return -1; if (virTestCompareToFile(actualXML, xmlFile) < 0) - goto cleanup; + return -1; - ret = 0; - - cleanup: - return ret; + return 0; } diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 7fa5ad6a9a..d74df15966 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -787,26 +787,25 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test, virJSONValuePtr argobj; const char *cmdname; size_t i; - int ret = -1; if (!(val = virJSONValueFromString(cmdstr))) return -1; if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) { qemuMonitorTestError("Missing command name in %s", cmdstr); - goto cleanup; + return -1; } if (data->command_name && STRNEQ(data->command_name, cmdname)) { qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname); - goto cleanup; + return -1; } if (!(args = virJSONValueObjectGet(val, "arguments"))) { qemuMonitorTestError("Missing arguments section for command '%s'", NULLSTR(data->command_name)); - goto cleanup; + return -1; } /* validate the args */ @@ -818,12 +817,12 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test, qemuMonitorTestError("Missing argument '%s' for command '%s'", arg->argname, NULLSTR(data->command_name)); - goto cleanup; + return -1; } /* convert the argument to string */ if (!(argstr = virJSONValueToString(argobj, false))) - goto cleanup; + return -1; /* verify that the argument value is expected */ if (STRNEQ(argstr, arg->argval)) { @@ -832,15 +831,12 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test, arg->argname, NULLSTR(data->command_name), arg->argval, argstr); - goto cleanup; + return -1; } } /* arguments checked out, return the response */ - ret = qemuMonitorTestAddResponse(test, data->response); - - cleanup: - return ret; + return qemuMonitorTestAddResponse(test, data->response); } @@ -907,44 +903,40 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test, virJSONValuePtr args; g_autofree char *argstr = NULL; const char *cmdname; - int ret = -1; if (!(val = virJSONValueFromString(cmdstr))) return -1; if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) { qemuMonitorTestError("Missing command name in %s", cmdstr); - goto cleanup; + return -1; } if (STRNEQ(data->command_name, cmdname)) { qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname); - goto cleanup; + return -1; } if (!(args = virJSONValueObjectGet(val, "arguments"))) { qemuMonitorTestError("Missing arguments section for command '%s'", data->command_name); - goto cleanup; + return -1; } /* convert the arguments to string */ if (!(argstr = virJSONValueToString(args, false))) - goto cleanup; + return -1; /* verify that the argument value is expected */ if (STRNEQ(argstr, data->expectArgs)) { qemuMonitorTestError("%s: expected arguments: '%s', got: '%s'", data->command_name, data->expectArgs, argstr); - goto cleanup; + return -1; } /* arguments checked out, return the response */ - ret = qemuMonitorTestAddResponse(test, data->response); - - cleanup: - return ret; + return qemuMonitorTestAddResponse(test, data->response); }