mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
Use g_auto for xmlXPathContext everywhere
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:
parent
4a8ce37bf1
commit
5dae71ee8c
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user