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(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL; g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
if (!xml) { if (!xml) {
virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing CPU definition")); virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing CPU definition"));
goto cleanup; return -1;
} }
if (!(doc = virXMLParseStringCtxt(xml, _("(CPU_definition)"), &ctxt))) if (!(doc = virXMLParseStringCtxt(xml, _("(CPU_definition)"), &ctxt)))
goto cleanup; return -1;
if (virCPUDefParseXML(ctxt, NULL, type, cpu, validateXML) < 0) if (virCPUDefParseXML(ctxt, NULL, type, cpu, validateXML) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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