Remove redundant labels

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Ján Tomko 2021-08-17 12:17:31 +02:00
parent 9302e249db
commit 5590fbf8d6
13 changed files with 49 additions and 101 deletions

View File

@ -283,23 +283,19 @@ virCPUDefParseXMLString(const char *xml,
{
g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
if (!xml) {
virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing CPU definition"));
goto cleanup;
return -1;
}
if (!(doc = virXMLParseStringCtxt(xml, _("(CPU_definition)"), &ctxt)))
goto cleanup;
return -1;
if (virCPUDefParseXML(ctxt, NULL, type, cpu, validateXML) < 0)
goto cleanup;
return -1;
ret = 0;
cleanup:
return ret;
return 0;
}

View File

@ -269,23 +269,19 @@ virNetworkPortDefParseNode(xmlDocPtr xml,
xmlNodePtr root)
{
g_autoptr(xmlXPathContext) ctxt = NULL;
virNetworkPortDef *def = NULL;
if (STRNEQ((const char *)root->name, "networkport")) {
virReportError(VIR_ERR_XML_ERROR,
"%s",
_("unknown root element for network port"));
goto cleanup;
return NULL;
}
if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
return NULL;
ctxt->node = root;
def = virNetworkPortDefParseXML(ctxt);
cleanup:
return def;
return virNetworkPortDefParseXML(ctxt);
}

View File

@ -160,23 +160,19 @@ virNWFilterBindingDefParseNode(xmlDocPtr xml,
xmlNodePtr root)
{
g_autoptr(xmlXPathContext) ctxt = NULL;
virNWFilterBindingDef *def = NULL;
if (STRNEQ((const char *)root->name, "filterbinding")) {
virReportError(VIR_ERR_XML_ERROR,
"%s",
_("unknown root element for nwfilter binding"));
goto cleanup;
return NULL;
}
if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
return NULL;
ctxt->node = root;
def = virNWFilterBindingDefParseXML(ctxt);
cleanup:
return def;
return virNWFilterBindingDefParseXML(ctxt);
}

View File

@ -237,23 +237,19 @@ virNWFilterBindingObjParseNode(xmlDocPtr doc,
xmlNodePtr root)
{
g_autoptr(xmlXPathContext) ctxt = NULL;
virNWFilterBindingObj *obj = NULL;
if (STRNEQ((const char *)root->name, "filterbindingstatus")) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown root element '%s' for filter binding"),
root->name);
goto cleanup;
return NULL;
}
if (!(ctxt = virXMLXPathContextNew(doc)))
goto cleanup;
return NULL;
ctxt->node = root;
obj = virNWFilterBindingObjParseXML(doc, ctxt);
cleanup:
return obj;
return virNWFilterBindingObjParseXML(doc, ctxt);
}

View File

@ -81,22 +81,16 @@ virSaveCookieParseString(const char *xml,
{
g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
*obj = NULL;
if (!xml) {
ret = 0;
goto cleanup;
}
if (!xml)
return 0;
if (!(doc = virXMLParseStringCtxt(xml, _("(save cookie)"), &ctxt)))
goto cleanup;
return -1;
ret = virSaveCookieParseNode(ctxt, obj, saveCookie);
cleanup:
return ret;
return virSaveCookieParseNode(ctxt, obj, saveCookie);
}

View File

@ -1652,30 +1652,30 @@ virStoragePoolObjLoadState(virStoragePoolObjList *pools,
return NULL;
if (!(xml = virXMLParseCtxt(stateFile, NULL, _("(pool state)"), &ctxt)))
goto cleanup;
return NULL;
if (!(node = virXPathNode("//pool", ctxt))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not find any 'pool' element in state file"));
goto cleanup;
return NULL;
}
ctxt->node = node;
if (!(def = virStoragePoolDefParseXML(ctxt)))
goto cleanup;
return NULL;
if (STRNEQ(name, def->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Storage pool state file '%s' does not match "
"pool name '%s'"),
stateFile, def->name);
goto cleanup;
return NULL;
}
/* create the object */
if (!(obj = virStoragePoolObjListAdd(pools, def,
VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE)))
goto cleanup;
return NULL;
def = NULL;
/* XXX: future handling of some additional useful status data,
@ -1684,8 +1684,6 @@ virStoragePoolObjLoadState(virStoragePoolObjList *pools,
*/
obj->active = true;
cleanup:
return obj;
}

View File

@ -151,7 +151,6 @@ libxlMigrationEatCookie(const char *cookiein,
g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
g_autofree char *uuidstr = NULL;
int ret = -1;
/*
* Assume a legacy (V1) migration stream if request came from a
@ -209,14 +208,11 @@ libxlMigrationEatCookie(const char *cookiein,
}
*migout = mig;
ret = 0;
goto cleanup;
return 0;
error:
libxlMigrationCookieFree(mig);
cleanup:
return ret;
return -1;
}
static void

View File

@ -1433,18 +1433,13 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookie *mig,
{
g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
VIR_DEBUG("xml=%s", NULLSTR(xml));
if (!(doc = virXMLParseStringCtxt(xml, _("(qemu_migration_cookie)"), &ctxt)))
goto cleanup;
return -1;
ret = qemuMigrationCookieXMLParse(mig, driver, qemuCaps, doc, ctxt, flags);
cleanup:
return ret;
return qemuMigrationCookieXMLParse(mig, driver, qemuCaps, doc, ctxt, flags);
}

View File

@ -567,34 +567,33 @@ verify_xpath_context(xmlXPathContextPtr ctxt)
static int
caps_mockup(vahControl * ctl, const char *xmlStr)
{
int rc = -1;
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
char *arch;
if (!(xml = virXMLParseStringCtxt(xmlStr, _("(domain_definition)"),
&ctxt))) {
goto cleanup;
return -1;
}
if (!virXMLNodeNameEqual(ctxt->node, "domain")) {
vah_error(NULL, 0, _("unexpected root element, expecting <domain>"));
goto cleanup;
return -1;
}
/* Quick sanity check for some required elements */
if (verify_xpath_context(ctxt) != 0)
goto cleanup;
return -1;
ctl->virtType = virXPathString("string(./@type)", ctxt);
if (!ctl->virtType) {
vah_error(ctl, 0, _("domain type is not defined"));
goto cleanup;
return -1;
}
ctl->os = virXPathString("string(./os/type[1])", ctxt);
if (!ctl->os) {
vah_error(ctl, 0, _("os.type is not defined"));
goto cleanup;
return -1;
}
arch = virXPathString("string(./os/type[1]/@arch)", ctxt);
if (!arch) {
@ -604,11 +603,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
VIR_FREE(arch);
}
rc = 0;
cleanup:
return rc;
return 0;
}
virDomainDefParserConfig virAAHelperDomainDefParserConfig = {

View File

@ -2897,26 +2897,25 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
virStoragePoolSource *src = NULL;
size_t i;
int nnodes;
int ret = -1;
g_autofree xmlNodePtr *nodes = NULL;
g_autofree char *volname = NULL;
if (!(doc = virXMLParseStringCtxt(xml, _("(gluster_cli_output)"), &ctxt)))
goto cleanup;
return -1;
if ((nnodes = virXPathNodeSet("//volumes/volume", ctxt, &nodes)) < 0)
goto cleanup;
return -1;
for (i = 0; i < nnodes; i++) {
ctxt->node = nodes[i];
if (!(src = virStoragePoolSourceListNewSource(list)))
goto cleanup;
return -1;
if (!(volname = virXPathString("string(./name)", ctxt))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to extract gluster volume name"));
goto cleanup;
return -1;
}
if (pooltype == VIR_STORAGE_POOL_NETFS) {
@ -2928,7 +2927,7 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
} else {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unsupported gluster lookup"));
goto cleanup;
return -1;
}
src->hosts = g_new0(virStoragePoolSourceHost, 1);
@ -2937,11 +2936,7 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
src->hosts[0].name = g_strdup(host);
}
ret = nnodes;
cleanup:
return ret;
return nnodes;
}

View File

@ -2837,13 +2837,11 @@ vzEatCookie(const char *cookiein, int cookieinlen, unsigned int flags)
goto error;
}
cleanup:
return mig;
error:
vzMigrationCookieFree(mig);
mig = NULL;
goto cleanup;
return NULL;
}
#define VZ_MIGRATION_FLAGS (VIR_MIGRATE_PAUSED | \

View File

@ -79,11 +79,10 @@ cpuTestLoadXML(virArch arch, const char *name)
virArchToString(arch), name);
if (!(doc = virXMLParseFileCtxt(xml, &ctxt)))
goto cleanup;
return NULL;
virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, false);
cleanup:
return cpu;
}
@ -105,12 +104,12 @@ cpuTestLoadMultiXML(virArch arch,
virArchToString(arch), name);
if (!(doc = virXMLParseFileCtxt(xml, &ctxt)))
goto cleanup;
return NULL;
n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes);
if (n <= 0) {
fprintf(stderr, "\nNo /cpuTest/cpu elements found in %s\n", xml);
goto cleanup;
return NULL;
}
cpus = g_new0(virCPUDef *, n);
@ -119,19 +118,18 @@ cpuTestLoadMultiXML(virArch arch,
ctxt->node = nodes[i];
if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i],
false) < 0)
goto cleanup_cpus;
goto error;
}
*count = n;
cleanup:
return cpus;
cleanup_cpus:
error:
for (i = 0; i < n; i++)
virCPUDefFree(cpus[i]);
VIR_FREE(cpus);
goto cleanup;
return NULL;
}

View File

@ -61,22 +61,17 @@ getMetadataFromXML(virDomainPtr dom)
xmlNodePtr node;
g_autofree char *xml = NULL;
char *ret = NULL;
if (!(xml = virDomainGetXMLDesc(dom, 0)))
goto cleanup;
return NULL;
if (!(doc = virXMLParseStringCtxt(xml, "(domain_definition)", &ctxt)))
goto cleanup;
return NULL;
if (!(node = virXPathNode("//metadata/*", ctxt)))
goto cleanup;
return NULL;
ret = virXMLNodeToString(node->doc, node);
cleanup:
return ret;
return virXMLNodeToString(node->doc, node);
}