Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/conf/cpu_conf.c | 3 +--
src/conf/virnetworkportdef.c | 3 +--
src/conf/virnwfilterbindingdef.c | 3 +--
src/conf/virnwfilterbindingobj.c | 3 +--
src/conf/virsavecookie.c | 3 +--
src/conf/virstorageobj.c | 3 +--
src/esx/esx_vi.c | 4 +---
src/libxl/libxl_migration.c | 3 +--
src/qemu/qemu_capabilities.c | 3 +--
src/qemu/qemu_migration_cookie.c | 3 +--
src/security/virt-aa-helper.c | 3 +--
src/storage/storage_util.c | 3 +--
src/test/test_driver.c | 7 ++-----
src/vbox/vbox_snapshot_conf.c | 9 +++------
src/vz/vz_driver.c | 3 +--
src/vz/vz_sdk.c | 3 +--
tests/cputest.c | 6 ++----
tests/metadatatest.c | 3 +--
tests/qemucaps2xmltest.c | 4 +---
tests/virnetdevbandwidthtest.c | 3 +--
20 files changed, 24 insertions(+), 51 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 44e62712c5..dac7af4bf4 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -282,7 +282,7 @@ virCPUDefParseXMLString(const char *xml,
bool validateXML)
{
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
if (!xml) {
@@ -300,7 +300,6 @@ virCPUDefParseXMLString(const char *xml,
cleanup:
xmlFreeDoc(doc);
- xmlXPathFreeContext(ctxt);
return ret;
}
diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c
index 9c2a6298d2..8da05353b7 100644
--- a/src/conf/virnetworkportdef.c
+++ b/src/conf/virnetworkportdef.c
@@ -268,7 +268,7 @@ virNetworkPortDef *
virNetworkPortDefParseNode(xmlDocPtr xml,
xmlNodePtr root)
{
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
virNetworkPortDef *def = NULL;
if (STRNEQ((const char *)root->name, "networkport")) {
@@ -285,7 +285,6 @@ virNetworkPortDefParseNode(xmlDocPtr xml,
def = virNetworkPortDefParseXML(ctxt);
cleanup:
- xmlXPathFreeContext(ctxt);
return def;
}
diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbindingdef.c
index 4079fcdba4..45fa51a56c 100644
--- a/src/conf/virnwfilterbindingdef.c
+++ b/src/conf/virnwfilterbindingdef.c
@@ -159,7 +159,7 @@ virNWFilterBindingDef *
virNWFilterBindingDefParseNode(xmlDocPtr xml,
xmlNodePtr root)
{
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
virNWFilterBindingDef *def = NULL;
if (STRNEQ((const char *)root->name, "filterbinding")) {
@@ -176,7 +176,6 @@ virNWFilterBindingDefParseNode(xmlDocPtr xml,
def = virNWFilterBindingDefParseXML(ctxt);
cleanup:
- xmlXPathFreeContext(ctxt);
return def;
}
diff --git a/src/conf/virnwfilterbindingobj.c b/src/conf/virnwfilterbindingobj.c
index 11426e0a4d..20f33506fd 100644
--- a/src/conf/virnwfilterbindingobj.c
+++ b/src/conf/virnwfilterbindingobj.c
@@ -236,7 +236,7 @@ static virNWFilterBindingObj *
virNWFilterBindingObjParseNode(xmlDocPtr doc,
xmlNodePtr root)
{
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
virNWFilterBindingObj *obj = NULL;
if (STRNEQ((const char *)root->name, "filterbindingstatus")) {
@@ -253,7 +253,6 @@ virNWFilterBindingObjParseNode(xmlDocPtr doc,
obj = virNWFilterBindingObjParseXML(doc, ctxt);
cleanup:
- xmlXPathFreeContext(ctxt);
return obj;
}
diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c
index 0e67bf1477..b7e1e7df93 100644
--- a/src/conf/virsavecookie.c
+++ b/src/conf/virsavecookie.c
@@ -80,7 +80,7 @@ virSaveCookieParseString(const char *xml,
virSaveCookieCallbacks *saveCookie)
{
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
*obj = NULL;
@@ -96,7 +96,6 @@ virSaveCookieParseString(const char *xml,
ret = virSaveCookieParseNode(ctxt, obj, saveCookie);
cleanup:
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
return ret;
}
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 18a7718de9..91c63b2c45 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -1644,7 +1644,7 @@ virStoragePoolObjLoadState(virStoragePoolObjList *pools,
char *stateFile = NULL;
virStoragePoolObj *obj = NULL;
xmlDocPtr xml = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr node = NULL;
g_autoptr(virStoragePoolDef) def = NULL;
@@ -1688,7 +1688,6 @@ virStoragePoolObjLoadState(virStoragePoolObjList *pools,
cleanup:
VIR_FREE(stateFile);
xmlFreeDoc(xml);
- xmlXPathFreeContext(ctxt);
return obj;
}
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index ebc6d9eb69..6f964cc470 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -1224,7 +1224,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
esxVI_Fault *fault = NULL;
g_autofree char *xpathExpression = NULL;
- xmlXPathContextPtr xpathContext = NULL;
+ g_autoptr(xmlXPathContext) xpathContext = NULL;
xmlNodePtr responseNode = NULL;
if (!request || !response || *response) {
@@ -1385,8 +1385,6 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
esxVI_Fault_Free(&fault);
}
- xmlXPathFreeContext(xpathContext);
-
return result;
}
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 4677f798fc..817252bce9 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -149,7 +149,7 @@ libxlMigrationEatCookie(const char *cookiein,
{
libxlMigrationCookie *mig = NULL;
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
g_autofree char *uuidstr = NULL;
int ret = -1;
@@ -216,7 +216,6 @@ libxlMigrationEatCookie(const char *cookiein,
libxlMigrationCookieFree(mig);
cleanup:
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
return ret;
}
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 9558938866..cecacb051b 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4196,7 +4196,7 @@ virQEMUCapsLoadCache(virArch hostArch,
size_t i;
int n;
xmlNodePtr *nodes = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
char *str = NULL;
long long int l;
unsigned long lu;
@@ -4421,7 +4421,6 @@ virQEMUCapsLoadCache(virArch hostArch,
cleanup:
VIR_FREE(str);
VIR_FREE(nodes);
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
return ret;
}
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 52998ddd1b..b4081b17e2 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -1432,7 +1432,7 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookie *mig,
unsigned int flags)
{
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
VIR_DEBUG("xml=%s", NULLSTR(xml));
@@ -1443,7 +1443,6 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookie *mig,
ret = qemuMigrationCookieXMLParse(mig, driver, qemuCaps, doc, ctxt, flags);
cleanup:
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
return ret;
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index e21557c810..2ba2a4a2b8 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -569,7 +569,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
{
int rc = -1;
xmlDocPtr xml = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
char *arch;
if (!(xml = virXMLParseStringCtxt(xmlStr, _("(domain_definition)"),
@@ -608,7 +608,6 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
cleanup:
xmlFreeDoc(xml);
- xmlXPathFreeContext(ctxt);
return rc;
}
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index a7c9355bf9..1beff7726a 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -2893,7 +2893,7 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
virStoragePoolType pooltype)
{
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
virStoragePoolSource *src = NULL;
size_t i;
int nnodes;
@@ -2940,7 +2940,6 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
ret = nnodes;
cleanup:
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
return ret;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 00cc13511a..6bb52e9302 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1334,7 +1334,7 @@ static int
testOpenFromFile(virConnectPtr conn, const char *file)
{
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
testDriver *privconn;
if (!(privconn = testDriverNew()))
@@ -1355,14 +1355,12 @@ testOpenFromFile(virConnectPtr conn, const char *file)
if (testOpenParse(privconn, file, ctxt) < 0)
goto error;
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
virObjectUnlock(privconn);
return VIR_DRV_OPEN_SUCCESS;
error:
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
virObjectUnref(privconn);
conn->privateData = NULL;
@@ -1378,7 +1376,7 @@ testOpenDefault(virConnectPtr conn)
int ret = VIR_DRV_OPEN_ERROR;
testDriver *privconn = NULL;
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
size_t i;
virMutexLock(&defaultLock);
@@ -1426,7 +1424,6 @@ testOpenDefault(virConnectPtr conn)
ret = VIR_DRV_OPEN_SUCCESS;
cleanup:
virMutexUnlock(&defaultLock);
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
return ret;
diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
index 7fb97d49d9..0f30aef108 100644
--- a/src/vbox/vbox_snapshot_conf.c
+++ b/src/vbox/vbox_snapshot_conf.c
@@ -578,7 +578,7 @@ virVBoxSnapshotConfLoadVboxFile(const char *filePath,
xmlDocPtr xml = NULL;
xmlNodePtr machineNode = NULL;
xmlNodePtr cur = NULL;
- xmlXPathContextPtr xPathContext = NULL;
+ g_autoptr(xmlXPathContext) xPathContext = NULL;
char *currentStateModifiedString = NULL;
char **searchResultTab = NULL;
@@ -716,7 +716,6 @@ virVBoxSnapshotConfLoadVboxFile(const char *filePath,
ret = 0;
cleanup:
- xmlXPathFreeContext(xPathContext);
xmlFreeDoc(xml);
VIR_FREE(currentStateModifiedString);
@@ -1221,7 +1220,7 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char
*filePath,
size_t i = 0;
char **ret = NULL;
xmlDocPtr xml = NULL;
- xmlXPathContextPtr xPathContext = NULL;
+ g_autoptr(xmlXPathContext) xPathContext = NULL;
xmlNodePtr *nodes = NULL;
int nodeSize = 0;
*rwDisksPath = NULL;
@@ -1260,7 +1259,6 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char
*filePath,
cleanup:
xmlFreeDoc(xml);
- xmlXPathFreeContext(xPathContext);
if (result < 0) {
g_strfreev(ret);
nodeSize = -1;
@@ -1284,7 +1282,7 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char
*filePath,
size_t i = 0;
char **ret = NULL;
xmlDocPtr xml = NULL;
- xmlXPathContextPtr xPathContext = NULL;
+ g_autoptr(xmlXPathContext) xPathContext = NULL;
xmlNodePtr *nodes = NULL;
int nodeSize = 0;
if (filePath == NULL) {
@@ -1322,7 +1320,6 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char
*filePath,
cleanup:
xmlFreeDoc(xml);
- xmlXPathFreeContext(xPathContext);
if (result < 0) {
g_strfreev(ret);
nodeSize = -1;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index a9cd3d90c9..edc4327550 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -2790,7 +2790,7 @@ static vzMigrationCookie *
vzEatCookie(const char *cookiein, int cookieinlen, unsigned int flags)
{
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctx = NULL;
+ g_autoptr(xmlXPathContext) ctx = NULL;
vzMigrationCookie *mig = NULL;
mig = g_new0(vzMigrationCookie, 1);
@@ -2838,7 +2838,6 @@ vzEatCookie(const char *cookiein, int cookieinlen, unsigned int
flags)
}
cleanup:
- xmlXPathFreeContext(ctx);
xmlFreeDoc(doc);
return mig;
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 7871b04005..5a747913b5 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -4579,7 +4579,7 @@ prlsdkParseSnapshotTree(const char *treexml)
{
virDomainSnapshotObjList *ret = NULL;
xmlDocPtr xml = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr root;
xmlNodePtr *nodes = NULL;
virDomainSnapshotDef *def = NULL;
@@ -4696,7 +4696,6 @@ prlsdkParseSnapshotTree(const char *treexml)
virDomainSnapshotObjListFree(snapshots);
VIR_FREE(nodes);
VIR_FREE(xmlstr);
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
VIR_FREE(def);
diff --git a/tests/cputest.c b/tests/cputest.c
index 18de84e050..34d9e8ddb0 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -72,7 +72,7 @@ cpuTestLoadXML(virArch arch, const char *name)
{
char *xml = NULL;
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
virCPUDef *cpu = NULL;
xml = g_strdup_printf("%s/cputestdata/%s-%s.xml", abs_srcdir,
@@ -84,7 +84,6 @@ cpuTestLoadXML(virArch arch, const char *name)
virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, false);
cleanup:
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
VIR_FREE(xml);
return cpu;
@@ -98,7 +97,7 @@ cpuTestLoadMultiXML(virArch arch,
{
char *xml = NULL;
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr *nodes = NULL;
virCPUDef **cpus = NULL;
int n;
@@ -130,7 +129,6 @@ cpuTestLoadMultiXML(virArch arch,
cleanup:
VIR_FREE(xml);
VIR_FREE(nodes);
- xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
return cpus;
diff --git a/tests/metadatatest.c b/tests/metadatatest.c
index a9080b32d7..ceb683028c 100644
--- a/tests/metadatatest.c
+++ b/tests/metadatatest.c
@@ -57,7 +57,7 @@ static char *
getMetadataFromXML(virDomainPtr dom)
{
xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr node;
char *xml = NULL;
@@ -77,7 +77,6 @@ getMetadataFromXML(virDomainPtr dom)
cleanup:
VIR_FREE(xml);
xmlFreeDoc(doc);
- xmlXPathFreeContext(ctxt);
return ret;
}
diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c
index 68bbf07ec2..35eb27c1fb 100644
--- a/tests/qemucaps2xmltest.c
+++ b/tests/qemucaps2xmltest.c
@@ -52,7 +52,7 @@ testQemuGetCaps(char *caps)
{
virQEMUCaps *qemuCaps = NULL;
xmlDocPtr xml;
- xmlXPathContextPtr ctxt = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
ssize_t i, n;
g_autofree xmlNodePtr *nodes = NULL;
@@ -80,13 +80,11 @@ testQemuGetCaps(char *caps)
}
xmlFreeDoc(xml);
- xmlXPathFreeContext(ctxt);
return qemuCaps;
error:
virObjectUnref(qemuCaps);
xmlFreeDoc(xml);
- xmlXPathFreeContext(ctxt);
return NULL;
}
diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c
index f399c95da0..51ceae5a6a 100644
--- a/tests/virnetdevbandwidthtest.c
+++ b/tests/virnetdevbandwidthtest.c
@@ -43,7 +43,7 @@ struct testSetStruct {
do { \
int rc; \
xmlDocPtr doc; \
- xmlXPathContextPtr ctxt = NULL; \
+ g_autoptr(xmlXPathContext) ctxt = NULL; \
\
if (!xml) \
break; \
@@ -58,7 +58,6 @@ struct testSetStruct {
ctxt->node, \
true); \
xmlFreeDoc(doc); \
- xmlXPathFreeContext(ctxt); \
if (rc < 0) \
goto cleanup; \
} while (0)
--
2.31.1