Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/conf/checkpoint_conf.c | 3 +--
src/conf/cpu_conf.c | 3 +--
src/conf/domain_conf.c | 6 ++----
src/conf/interface_conf.c | 3 +--
src/conf/node_device_conf.c | 3 +--
src/conf/nwfilter_conf.c | 3 +--
src/conf/secret_conf.c | 3 +--
src/conf/snapshot_conf.c | 3 +--
src/conf/storage_conf.c | 6 ++----
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/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 | 10 +++-------
src/util/virxml.c | 3 +--
src/vbox/vbox_snapshot_conf.c | 12 ++++--------
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 +--
28 files changed, 36 insertions(+), 74 deletions(-)
diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
index d2041dd0ac..4731f21aba 100644
--- a/src/conf/checkpoint_conf.c
+++ b/src/conf/checkpoint_conf.c
@@ -213,7 +213,7 @@ virDomainCheckpointDefParseString(const char *xmlStr,
unsigned int flags)
{
virDomainCheckpointDef *ret = NULL;
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
if ((xml = virXMLParse(NULL, xmlStr, _("(domain_checkpoint)"),
@@ -221,7 +221,6 @@ virDomainCheckpointDefParseString(const char *xmlStr,
xmlKeepBlanksDefault(keepBlanksDefault);
ret = virDomainCheckpointDefParseNode(xml, xmlDocGetRootElement(xml),
xmlopt, parseOpaque, flags);
- xmlFreeDoc(xml);
}
xmlKeepBlanksDefault(keepBlanksDefault);
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index dac7af4bf4..4434120557 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -281,7 +281,7 @@ virCPUDefParseXMLString(const char *xml,
virCPUDef **cpu,
bool validateXML)
{
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
@@ -299,7 +299,6 @@ virCPUDefParseXMLString(const char *xml,
ret = 0;
cleanup:
- xmlFreeDoc(doc);
return ret;
}
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 926f831073..10effdce69 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20377,7 +20377,7 @@ virDomainDefParse(const char *xmlStr,
void *parseOpaque,
unsigned int flags)
{
- xmlDocPtr xml = NULL;
+ g_autoptr(xmlDoc) xml = NULL;
virDomainDef *def = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
xmlNodePtr root;
@@ -20397,7 +20397,6 @@ virDomainDefParse(const char *xmlStr,
def = virDomainDefParseNode(xml, root, xmlopt, parseOpaque, flags);
cleanup:
- xmlFreeDoc(xml);
xmlKeepBlanksDefault(keepBlanksDefault);
return def;
}
@@ -20480,14 +20479,13 @@ virDomainObjParseFile(const char *filename,
virDomainXMLOption *xmlopt,
unsigned int flags)
{
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
virDomainObj *obj = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
if ((xml = virXMLParseFile(filename))) {
obj = virDomainObjParseNode(xml, xmlDocGetRootElement(xml),
xmlopt, flags);
- xmlFreeDoc(xml);
}
xmlKeepBlanksDefault(keepBlanksDefault);
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index c4b763d0de..c371a252a8 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -821,12 +821,11 @@ static virInterfaceDef *
virInterfaceDefParse(const char *xmlStr,
const char *filename)
{
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
virInterfaceDef *def = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(interface_definition)"), NULL,
false))) {
def = virInterfaceDefParseNode(xml, xmlDocGetRootElement(xml));
- xmlFreeDoc(xml);
}
return def;
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index bda1a11b37..b4c1acb6a5 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2174,13 +2174,12 @@ virNodeDeviceDefParse(const char *str,
virNodeDeviceDefParserCallbacks *parserCallbacks,
void *opaque)
{
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
g_autoptr(virNodeDeviceDef) def = NULL;
if ((xml = virXMLParse(filename, str, _("(node_device_definition)"), NULL,
false))) {
def = virNodeDeviceDefParseNode(xml, xmlDocGetRootElement(xml),
create, virt_type);
- xmlFreeDoc(xml);
}
if (parserCallbacks) {
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index b7adae7161..7d491e27b1 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2742,11 +2742,10 @@ virNWFilterDefParse(const char *xmlStr,
const char *filename)
{
virNWFilterDef *def = NULL;
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(nwfilter_definition)"), NULL,
false))) {
def = virNWFilterDefParseNode(xml, xmlDocGetRootElement(xml));
- xmlFreeDoc(xml);
}
return def;
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index 5968b4365c..ef6a4b606e 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -193,12 +193,11 @@ static virSecretDef *
virSecretDefParse(const char *xmlStr,
const char *filename)
{
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
virSecretDef *ret = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(definition_of_secret)"), NULL,
false))) {
ret = secretXMLParseNode(xml, xmlDocGetRootElement(xml));
- xmlFreeDoc(xml);
}
return ret;
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 6d3c59f98e..c765e4c815 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -447,7 +447,7 @@ virDomainSnapshotDefParseString(const char *xmlStr,
unsigned int flags)
{
virDomainSnapshotDef *ret = NULL;
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
if ((xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"),
"domainsnapshot.rng",
@@ -456,7 +456,6 @@ virDomainSnapshotDefParseString(const char *xmlStr,
ret = virDomainSnapshotDefParseNode(xml, xmlDocGetRootElement(xml),
xmlopt, parseOpaque,
current, flags);
- xmlFreeDoc(xml);
}
xmlKeepBlanksDefault(keepBlanksDefault);
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index e72e8d0ade..040a413d0f 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1007,11 +1007,10 @@ virStoragePoolDefParse(const char *xmlStr,
const char *filename)
{
virStoragePoolDef *ret = NULL;
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(storage_pool_definition)"),
NULL, false))) {
ret = virStoragePoolDefParseNode(xml, xmlDocGetRootElement(xml));
- xmlFreeDoc(xml);
}
return ret;
@@ -1476,11 +1475,10 @@ virStorageVolDefParse(virStoragePoolDef *pool,
unsigned int flags)
{
virStorageVolDef *ret = NULL;
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(storage_volume_definition)"),
NULL, false))) {
ret = virStorageVolDefParseNode(pool, xml, xmlDocGetRootElement(xml), flags);
- xmlFreeDoc(xml);
}
return ret;
diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c
index 8da05353b7..5e916ab2b8 100644
--- a/src/conf/virnetworkportdef.c
+++ b/src/conf/virnetworkportdef.c
@@ -294,11 +294,10 @@ virNetworkPortDefParse(const char *xmlStr,
const char *filename)
{
virNetworkPortDef *def = NULL;
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(networkport_definition)"),
NULL, false))) {
def = virNetworkPortDefParseNode(xml, xmlDocGetRootElement(xml));
- xmlFreeDoc(xml);
}
return def;
diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbindingdef.c
index 45fa51a56c..3428b05841 100644
--- a/src/conf/virnwfilterbindingdef.c
+++ b/src/conf/virnwfilterbindingdef.c
@@ -185,11 +185,10 @@ virNWFilterBindingDefParse(const char *xmlStr,
const char *filename)
{
virNWFilterBindingDef *def = NULL;
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(nwfilterbinding_definition)"),
NULL, false))) {
def = virNWFilterBindingDefParseNode(xml, xmlDocGetRootElement(xml));
- xmlFreeDoc(xml);
}
return def;
diff --git a/src/conf/virnwfilterbindingobj.c b/src/conf/virnwfilterbindingobj.c
index 20f33506fd..279e334d3f 100644
--- a/src/conf/virnwfilterbindingobj.c
+++ b/src/conf/virnwfilterbindingobj.c
@@ -262,11 +262,10 @@ virNWFilterBindingObjParse(const char *xmlStr,
const char *filename)
{
virNWFilterBindingObj *obj = NULL;
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(nwfilterbinding_status)"),
NULL, false))) {
obj = virNWFilterBindingObjParseNode(xml, xmlDocGetRootElement(xml));
- xmlFreeDoc(xml);
}
return obj;
diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c
index b7e1e7df93..3bb97246af 100644
--- a/src/conf/virsavecookie.c
+++ b/src/conf/virsavecookie.c
@@ -79,7 +79,7 @@ virSaveCookieParseString(const char *xml,
virObject **obj,
virSaveCookieCallbacks *saveCookie)
{
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
@@ -96,7 +96,6 @@ virSaveCookieParseString(const char *xml,
ret = virSaveCookieParseNode(ctxt, obj, saveCookie);
cleanup:
- xmlFreeDoc(doc);
return ret;
}
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 91c63b2c45..f8b85494c0 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -1643,7 +1643,7 @@ virStoragePoolObjLoadState(virStoragePoolObjList *pools,
{
char *stateFile = NULL;
virStoragePoolObj *obj = NULL;
- xmlDocPtr xml = NULL;
+ g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr node = NULL;
g_autoptr(virStoragePoolDef) def = NULL;
@@ -1687,7 +1687,6 @@ virStoragePoolObjLoadState(virStoragePoolObjList *pools,
cleanup:
VIR_FREE(stateFile);
- xmlFreeDoc(xml);
return obj;
}
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 817252bce9..a2c2b6dbde 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -148,7 +148,7 @@ libxlMigrationEatCookie(const char *cookiein,
libxlMigrationCookie **migout)
{
libxlMigrationCookie *mig = NULL;
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = 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:
- xmlFreeDoc(doc);
return ret;
}
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index cecacb051b..535550754c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4191,7 +4191,7 @@ virQEMUCapsLoadCache(virArch hostArch,
const char *filename,
bool skipInvalidation)
{
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
int ret = -1;
size_t i;
int n;
@@ -4421,7 +4421,6 @@ virQEMUCapsLoadCache(virArch hostArch,
cleanup:
VIR_FREE(str);
VIR_FREE(nodes);
- xmlFreeDoc(doc);
return ret;
}
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index b4081b17e2..106897cacd 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -1431,7 +1431,7 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookie *mig,
const char *xml,
unsigned int flags)
{
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int ret = -1;
@@ -1443,7 +1443,6 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookie *mig,
ret = qemuMigrationCookieXMLParse(mig, driver, qemuCaps, doc, ctxt, flags);
cleanup:
- xmlFreeDoc(doc);
return ret;
}
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 2ba2a4a2b8..c0bbd7414a 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -568,7 +568,7 @@ static int
caps_mockup(vahControl * ctl, const char *xmlStr)
{
int rc = -1;
- xmlDocPtr xml = NULL;
+ g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
char *arch;
@@ -607,7 +607,6 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
rc = 0;
cleanup:
- xmlFreeDoc(xml);
return rc;
}
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 1beff7726a..7ee736535c 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -2892,7 +2892,7 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
virStoragePoolSourceList *list,
virStoragePoolType pooltype)
{
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
virStoragePoolSource *src = NULL;
size_t i;
@@ -2940,7 +2940,6 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
ret = nnodes;
cleanup:
- xmlFreeDoc(doc);
return ret;
}
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 6bb52e9302..b096d49ac6 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -825,7 +825,7 @@ static xmlNodePtr
testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char *type)
{
xmlNodePtr ret = NULL;
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autofree char *absFile = NULL;
g_autofree char *relFile = NULL;
@@ -848,7 +848,6 @@ testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char
*type)
}
error:
- xmlFreeDoc(doc);
return ret;
}
@@ -1333,7 +1332,7 @@ testOpenParse(testDriver *privconn,
static int
testOpenFromFile(virConnectPtr conn, const char *file)
{
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
testDriver *privconn;
@@ -1355,13 +1354,11 @@ testOpenFromFile(virConnectPtr conn, const char *file)
if (testOpenParse(privconn, file, ctxt) < 0)
goto error;
- xmlFreeDoc(doc);
virObjectUnlock(privconn);
return VIR_DRV_OPEN_SUCCESS;
error:
- xmlFreeDoc(doc);
virObjectUnref(privconn);
conn->privateData = NULL;
return VIR_DRV_OPEN_ERROR;
@@ -1375,7 +1372,7 @@ testOpenDefault(virConnectPtr conn)
{
int ret = VIR_DRV_OPEN_ERROR;
testDriver *privconn = NULL;
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
size_t i;
@@ -1424,7 +1421,6 @@ testOpenDefault(virConnectPtr conn)
ret = VIR_DRV_OPEN_SUCCESS;
cleanup:
virMutexUnlock(&defaultLock);
- xmlFreeDoc(doc);
return ret;
error:
diff --git a/src/util/virxml.c b/src/util/virxml.c
index 61e3d91640..b736d59d9c 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -1619,12 +1619,11 @@ int
virXMLValidateNodeAgainstSchema(const char *schemafile, xmlNodePtr node)
{
int ret;
- xmlDocPtr copy = xmlNewDoc(NULL);
+ g_autoptr(xmlDoc) copy = xmlNewDoc(NULL);
xmlDocSetRootElement(copy, xmlCopyNode(node, true));
ret = virXMLValidateAgainstSchema(schemafile, copy);
- xmlFreeDoc(copy);
return ret;
}
diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
index 0f30aef108..65546b785e 100644
--- a/src/vbox/vbox_snapshot_conf.c
+++ b/src/vbox/vbox_snapshot_conf.c
@@ -575,7 +575,7 @@ virVBoxSnapshotConfLoadVboxFile(const char *filePath,
{
int ret = -1;
virVBoxSnapshotConfMachine *machineDescription = NULL;
- xmlDocPtr xml = NULL;
+ g_autoptr(xmlDoc) xml = NULL;
xmlNodePtr machineNode = NULL;
xmlNodePtr cur = NULL;
g_autoptr(xmlXPathContext) xPathContext = NULL;
@@ -716,7 +716,6 @@ virVBoxSnapshotConfLoadVboxFile(const char *filePath,
ret = 0;
cleanup:
- xmlFreeDoc(xml);
VIR_FREE(currentStateModifiedString);
VIR_FREE(currentSnapshotAttribute);
@@ -954,7 +953,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
{
int ret = -1;
size_t i = 0;
- xmlDocPtr xml = NULL;
+ g_autoptr(xmlDoc) xml = NULL;
xmlNodePtr mediaRegistryNode = NULL;
xmlNodePtr snapshotNode = NULL;
xmlNodePtr machineNode = NULL;
@@ -1172,7 +1171,6 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine
*machine,
xmlUnlinkNode(machineNode);
xmlFreeNode(machineNode);
- xmlFreeDoc(xml);
g_strfreev(firstRegex);
g_strfreev(secondRegex);
@@ -1219,7 +1217,7 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char
*filePath,
int result = -1;
size_t i = 0;
char **ret = NULL;
- xmlDocPtr xml = NULL;
+ g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) xPathContext = NULL;
xmlNodePtr *nodes = NULL;
int nodeSize = 0;
@@ -1258,7 +1256,6 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char
*filePath,
result = 0;
cleanup:
- xmlFreeDoc(xml);
if (result < 0) {
g_strfreev(ret);
nodeSize = -1;
@@ -1281,7 +1278,7 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char
*filePath,
int result = -1;
size_t i = 0;
char **ret = NULL;
- xmlDocPtr xml = NULL;
+ g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) xPathContext = NULL;
xmlNodePtr *nodes = NULL;
int nodeSize = 0;
@@ -1319,7 +1316,6 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char
*filePath,
result = 0;
cleanup:
- xmlFreeDoc(xml);
if (result < 0) {
g_strfreev(ret);
nodeSize = -1;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index edc4327550..9eba9d47fb 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -2789,7 +2789,7 @@ vzBakeCookie(struct _vzDriver *driver,
static vzMigrationCookie *
vzEatCookie(const char *cookiein, int cookieinlen, unsigned int flags)
{
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctx = NULL;
vzMigrationCookie *mig = NULL;
@@ -2838,7 +2838,6 @@ vzEatCookie(const char *cookiein, int cookieinlen, unsigned int
flags)
}
cleanup:
- xmlFreeDoc(doc);
return mig;
error:
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 5a747913b5..2ba48134b0 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -4578,7 +4578,7 @@ static virDomainSnapshotObjList *
prlsdkParseSnapshotTree(const char *treexml)
{
virDomainSnapshotObjList *ret = NULL;
- xmlDocPtr xml = NULL;
+ g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr root;
xmlNodePtr *nodes = NULL;
@@ -4696,7 +4696,6 @@ prlsdkParseSnapshotTree(const char *treexml)
virDomainSnapshotObjListFree(snapshots);
VIR_FREE(nodes);
VIR_FREE(xmlstr);
- xmlFreeDoc(xml);
VIR_FREE(def);
return ret;
diff --git a/tests/cputest.c b/tests/cputest.c
index 34d9e8ddb0..d19ded4b40 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -71,7 +71,7 @@ static virCPUDef *
cpuTestLoadXML(virArch arch, const char *name)
{
char *xml = NULL;
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
virCPUDef *cpu = NULL;
@@ -84,7 +84,6 @@ cpuTestLoadXML(virArch arch, const char *name)
virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, false);
cleanup:
- xmlFreeDoc(doc);
VIR_FREE(xml);
return cpu;
}
@@ -96,7 +95,7 @@ cpuTestLoadMultiXML(virArch arch,
unsigned int *count)
{
char *xml = NULL;
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr *nodes = NULL;
virCPUDef **cpus = NULL;
@@ -129,7 +128,6 @@ cpuTestLoadMultiXML(virArch arch,
cleanup:
VIR_FREE(xml);
VIR_FREE(nodes);
- xmlFreeDoc(doc);
return cpus;
cleanup_cpus:
diff --git a/tests/metadatatest.c b/tests/metadatatest.c
index ceb683028c..2bcb0a1225 100644
--- a/tests/metadatatest.c
+++ b/tests/metadatatest.c
@@ -56,7 +56,7 @@ static const char metadata2_ns[] =
static char *
getMetadataFromXML(virDomainPtr dom)
{
- xmlDocPtr doc = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr node;
@@ -76,7 +76,6 @@ getMetadataFromXML(virDomainPtr dom)
cleanup:
VIR_FREE(xml);
- xmlFreeDoc(doc);
return ret;
}
diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c
index 35eb27c1fb..ce1116b792 100644
--- a/tests/qemucaps2xmltest.c
+++ b/tests/qemucaps2xmltest.c
@@ -51,7 +51,7 @@ static virQEMUCaps *
testQemuGetCaps(char *caps)
{
virQEMUCaps *qemuCaps = NULL;
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
ssize_t i, n;
g_autofree xmlNodePtr *nodes = NULL;
@@ -79,12 +79,10 @@ testQemuGetCaps(char *caps)
}
}
- xmlFreeDoc(xml);
return qemuCaps;
error:
virObjectUnref(qemuCaps);
- xmlFreeDoc(xml);
return NULL;
}
diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c
index 51ceae5a6a..83e7b2089f 100644
--- a/tests/virnetdevbandwidthtest.c
+++ b/tests/virnetdevbandwidthtest.c
@@ -42,7 +42,7 @@ struct testSetStruct {
#define PARSE(xml, var) \
do { \
int rc; \
- xmlDocPtr doc; \
+ g_autoptr(xmlDoc) doc = NULL; \
g_autoptr(xmlXPathContext) ctxt = NULL; \
\
if (!xml) \
@@ -57,7 +57,6 @@ struct testSetStruct {
NULL, \
ctxt->node, \
true); \
- xmlFreeDoc(doc); \
if (rc < 0) \
goto cleanup; \
} while (0)
--
2.31.1