Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/conf/cpu_conf.c | 12 ++++--------
src/conf/virnetworkportdef.c | 10 +++-------
src/conf/virnwfilterbindingdef.c | 10 +++-------
src/conf/virnwfilterbindingobj.c | 10 +++-------
src/conf/virsavecookie.c | 14 ++++----------
src/conf/virstorageobj.c | 12 +++++-------
src/libxl/libxl_migration.c | 8 ++------
src/qemu/qemu_migration_cookie.c | 9 ++-------
src/security/virt-aa-helper.c | 17 ++++++-----------
src/storage/storage_util.c | 17 ++++++-----------
src/vz/vz_driver.c | 4 +---
tests/cputest.c | 14 ++++++--------
tests/metadatatest.c | 13 ++++---------
13 files changed, 49 insertions(+), 101 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 4434120557..1674cd6957 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -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;
}
diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c
index 5e916ab2b8..c1749eebe0 100644
--- a/src/conf/virnetworkportdef.c
+++ b/src/conf/virnetworkportdef.c
@@ -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);
}
diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbindingdef.c
index 3428b05841..5f671030bb 100644
--- a/src/conf/virnwfilterbindingdef.c
+++ b/src/conf/virnwfilterbindingdef.c
@@ -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);
}
diff --git a/src/conf/virnwfilterbindingobj.c b/src/conf/virnwfilterbindingobj.c
index 279e334d3f..29fbb63b5f 100644
--- a/src/conf/virnwfilterbindingobj.c
+++ b/src/conf/virnwfilterbindingobj.c
@@ -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);
}
diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c
index 3bb97246af..6cb7fafb1f 100644
--- a/src/conf/virsavecookie.c
+++ b/src/conf/virsavecookie.c
@@ -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);
}
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 1f6fedba13..f906c5b141 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -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;
}
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index a2c2b6dbde..aa719a19d2 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -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
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 106897cacd..b67728f9c0 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -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);
}
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index c0bbd7414a..77b2307594 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -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 = {
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 7ee736535c..53792765ff 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -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;
}
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 9eba9d47fb..a1d05f834b 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -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 | \
diff --git a/tests/cputest.c b/tests/cputest.c
index 14606f5864..7816de87f7 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -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;
}
diff --git a/tests/metadatatest.c b/tests/metadatatest.c
index 2c560c27c1..e565383ce2 100644
--- a/tests/metadatatest.c
+++ b/tests/metadatatest.c
@@ -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);
}
--
2.31.1