The bulk of this patch was done with:
sed -i 's/\(\bfree *(/VIR_FREE(/g' tests/*.c
followed by fixing the few compile errors that resulted.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_raw_allocation):
Remove tests from exemption.
* tests/testutils.h: Add common header.
* tests/commandhelper.c: Fix offenders.
* tests/cputest.c: Likewise.
* tests/domainsnapshotxml2xmltest.c: Likewise.
* tests/interfacexml2xmltest.c: Likewise.
* tests/networkxml2argvtest.c: Likewise.
* tests/networkxml2xmltest.c: Likewise.
* tests/nodedevxml2xmltest.c: Likewise.
* tests/nodeinfotest.c: Likewise.
* tests/nwfilterxml2xmltest.c: Likewise.
* tests/qemuargv2xmltest.c: Likewise.
* tests/qemuxml2argvtest.c: Likewise.
* tests/qemuxml2xmltest.c: Likewise.
* tests/qemuxmlnstest.c: Likewise.
* tests/qparamtest.c: Likewise.
* tests/sexpr2xmltest.c: Likewise.
* tests/storagepoolxml2xmltest.c: Likewise.
* tests/storagevolxml2xmltest.c: Likewise.
* tests/testutils.c: Likewise.
* tests/virshtest.c: Likewise.
* tests/xencapstest.c: Likewise.
* tests/xmconfigtest.c: Likewise.
* tests/xml2sexprtest.c: Likewise.
---
cfg.mk | 2 +-
tests/commandhelper.c | 6 +++---
tests/cputest.c | 36 +++++++++++++++++++-----------------
tests/domainsnapshotxml2xmltest.c | 6 +++---
tests/interfacexml2xmltest.c | 6 +++---
tests/networkxml2argvtest.c | 10 +++++-----
tests/networkxml2xmltest.c | 10 +++++-----
tests/nodedevxml2xmltest.c | 6 +++---
tests/nodeinfotest.c | 10 +++++-----
tests/nwfilterxml2xmltest.c | 10 +++++-----
tests/qemuargv2xmltest.c | 20 ++++++++++----------
tests/qemuxml2argvtest.c | 28 ++++++++++++++--------------
tests/qemuxml2xmltest.c | 10 +++++-----
tests/qemuxmlnstest.c | 23 ++++++++++++-----------
tests/qparamtest.c | 2 +-
tests/sexpr2xmltest.c | 10 +++++-----
tests/storagepoolxml2xmltest.c | 10 +++++-----
tests/storagevolxml2xmltest.c | 14 +++++++-------
tests/testutils.c | 9 ++++-----
tests/testutils.h | 3 ++-
tests/virshtest.c | 4 ++--
tests/xencapstest.c | 10 +++++-----
tests/xmconfigtest.c | 10 +++++-----
tests/xml2sexprtest.c | 10 +++++-----
24 files changed, 134 insertions(+), 131 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index f91c90c..f9c1558 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -744,7 +744,7 @@ exclude_file_name_regexp--sc_prohibit_nonreentrant = \
^((po|tests)/|docs/.*py$$|tools/(virsh|console)\.c$$)
exclude_file_name_regexp--sc_prohibit_raw_allocation = \
- ^(src/util/memory\.[ch]|(examples|python|tests)/.*)$$
+ ^(src/util/memory\.[ch]|(examples|python)/.*)$$
exclude_file_name_regexp--sc_prohibit_readlink = ^src/util/util\.c$$
diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index cba208a..71d93be 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -1,7 +1,7 @@
/*
* commandhelper.c: Auxiliary program for commandtest
*
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -42,8 +42,8 @@ static int envsort(const void *a, const void *b) {
char *akey = strndup(astr, aeq - astr);
char *bkey = strndup(bstr, beq - bstr);
int ret = strcmp(akey, bkey);
- free(akey);
- free(bkey);
+ VIR_FREE(akey);
+ VIR_FREE(bkey);
return ret;
}
diff --git a/tests/cputest.c b/tests/cputest.c
index 17e14f7..15614a7 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -104,7 +104,7 @@ cpuTestLoadXML(const char *arch, const char *name)
cleanup:
xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
- free(xml);
+ VIR_FREE(xml);
return cpu;
}
@@ -129,7 +129,7 @@ cpuTestLoadMultiXML(const char *arch,
goto error;
n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes);
- if (n <= 0 || !(cpus = calloc(n, sizeof(virCPUDefPtr))))
+ if (n <= 0 || (VIR_ALLOC_N(cpus, n) < 0))
goto error;
for (i = 0; i < n; i++) {
@@ -142,8 +142,8 @@ cpuTestLoadMultiXML(const char *arch,
*count = n;
cleanup:
- free(xml);
- free(nodes);
+ VIR_FREE(xml);
+ VIR_FREE(nodes);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
return cpus;
@@ -152,7 +152,7 @@ error:
if (cpus) {
for (i = 0; i < n; i++)
virCPUDefFree(cpus[i]);
- free(cpus);
+ VIR_FREE(cpus);
cpus = NULL;
}
goto cleanup;
@@ -190,9 +190,9 @@ cpuTestCompareXML(const char *arch,
ret = 0;
cleanup:
- free(xml);
- free(expected);
- free(actual);
+ VIR_FREE(xml);
+ VIR_FREE(expected);
+ VIR_FREE(actual);
return ret;
}
@@ -381,10 +381,10 @@ cleanup:
if (cpus) {
for (i = 0; i < ncpus; i++)
virCPUDefFree(cpus[i]);
- free(cpus);
+ VIR_FREE(cpus);
}
virCPUDefFree(baseline);
- free(result);
+ VIR_FREE(result);
return ret;
}
@@ -414,7 +414,7 @@ cpuTestUpdate(const void *arg)
cleanup:
virCPUDefFree(host);
virCPUDefFree(cpu);
- free(result);
+ VIR_FREE(result);
return ret;
}
@@ -473,11 +473,13 @@ static int
cpuTestRun(const char *name, const struct data *data)
{
char *label = NULL;
+ char *tmp;
if (virAsprintf(&label, "CPU %s(%s): %s", apis[data->api],
data->arch, name) < 0)
return -1;
- free(virtTestLogContentAndReset());
+ tmp = virtTestLogContentAndReset();
+ VIR_FREE(tmp);
if (virtTestRun(label, 1, cpuTest[data->api], data) < 0) {
if (virTestGetDebug()) {
@@ -485,14 +487,14 @@ cpuTestRun(const char *name, const struct data *data)
if ((log = virtTestLogContentAndReset()) &&
strlen(log) > 0)
fprintf(stderr, "\n%s\n", log);
- free(log);
+ VIR_FREE(log);
}
- free(label);
+ VIR_FREE(label);
return -1;
}
- free(label);
+ VIR_FREE(label);
return 0;
}
@@ -513,7 +515,7 @@ mymain(void)
if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0
||
cpuMapOverride(map) < 0) {
- free(map);
+ VIR_FREE(map);
return EXIT_FAILURE;
}
@@ -632,7 +634,7 @@ mymain(void)
DO_TEST_GUESTDATA("x86", "host",
"host+host-model-nofallback",
models, "Penryn", -1);
- free(map);
+ VIR_FREE(map);
return (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index 5c2e670..978a2d4 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -51,8 +51,8 @@ testCompareXMLToXMLFiles(const char *inxml, const char *uuid, int
internal)
ret = 0;
fail:
- free(inXmlData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(actual);
virDomainSnapshotDefFree(def);
return ret;
}
@@ -77,7 +77,7 @@ testCompareXMLToXMLHelper(const void *data)
ret = testCompareXMLToXMLFiles(xml_in, info->uuid, info->internal);
cleanup:
- free(xml_in);
+ VIR_FREE(xml_in);
return ret;
}
diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c
index dc08ea7..c5c5415 100644
--- a/tests/interfacexml2xmltest.c
+++ b/tests/interfacexml2xmltest.c
@@ -39,8 +39,8 @@ testCompareXMLToXMLFiles(const char *xml)
ret = 0;
fail:
- free(xmlData);
- free(actual);
+ VIR_FREE(xmlData);
+ VIR_FREE(actual);
virInterfaceDefFree(dev);
return ret;
}
@@ -57,7 +57,7 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(xml);
- free (xml);
+ VIR_FREE(xml);
return result;
}
diff --git a/tests/networkxml2argvtest.c b/tests/networkxml2argvtest.c
index 5c6e29d..e000be9 100644
--- a/tests/networkxml2argvtest.c
+++ b/tests/networkxml2argvtest.c
@@ -91,9 +91,9 @@ static int testCompareXMLToArgvFiles(const char *inxml, const char
*outargv) {
ret = 0;
fail:
- free(inXmlData);
- free(outArgvData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outArgvData);
+ VIR_FREE(actual);
VIR_FREE(pidfile);
virCommandFree(cmd);
virNetworkObjFree(obj);
@@ -118,8 +118,8 @@ testCompareXMLToArgvHelper(const void *data)
result = testCompareXMLToArgvFiles(inxml, outxml);
cleanup:
- free(inxml);
- free(outxml);
+ VIR_FREE(inxml);
+ VIR_FREE(outxml);
return result;
}
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
index 6cb9d90..77528a8 100644
--- a/tests/networkxml2xmltest.c
+++ b/tests/networkxml2xmltest.c
@@ -42,9 +42,9 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
ret = 0;
fail:
- free(inXmlData);
- free(outXmlData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
virNetworkDefFree(dev);
return ret;
}
@@ -72,8 +72,8 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(inxml, outxml, info->flags);
cleanup:
- free(inxml);
- free(outxml);
+ VIR_FREE(inxml);
+ VIR_FREE(outxml);
return result;
}
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index d0deaeb..ad93161 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -38,8 +38,8 @@ testCompareXMLToXMLFiles(const char *xml)
ret = 0;
fail:
- free(xmlData);
- free(actual);
+ VIR_FREE(xmlData);
+ VIR_FREE(actual);
virNodeDeviceDefFree(dev);
return ret;
}
@@ -56,7 +56,7 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(xml);
- free(xml);
+ VIR_FREE(xml);
return result;
}
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index 0952a6b..32d964e 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -81,8 +81,8 @@ linuxTestCompareFiles(const char *cpuinfofile,
ret = 0;
fail:
- free(expectData);
- free(actualData);
+ VIR_FREE(expectData);
+ VIR_FREE(actualData);
return ret;
}
@@ -117,9 +117,9 @@ linuxTestNodeInfo(const void *data)
result = linuxTestCompareFiles(cpuinfo, sysfs_cpuinfo, output);
cleanup:
- free(cpuinfo);
- free(output);
- free(sysfs_cpuinfo);
+ VIR_FREE(cpuinfo);
+ VIR_FREE(output);
+ VIR_FREE(sysfs_cpuinfo);
return result;
}
diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c
index 39afa5c..db7fe78 100644
--- a/tests/nwfilterxml2xmltest.c
+++ b/tests/nwfilterxml2xmltest.c
@@ -55,9 +55,9 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
ret = 0;
fail:
- free(inXmlData);
- free(outXmlData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
virNWFilterDefFree(dev);
return ret;
}
@@ -85,8 +85,8 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(inxml, outxml, tp->expect_warning);
cleanup:
- free(inxml);
- free(outxml);
+ VIR_FREE(inxml);
+ VIR_FREE(outxml);
return result;
}
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 28434ff..51f5aed 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -52,10 +52,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
if ((log = virtTestLogContentAndReset()) == NULL)
goto fail;
if ((*log != '\0') != expect_warning) {
- free(log);
+ VIR_FREE(log);
goto fail;
}
- free(log);
+ VIR_FREE(log);
if (!(actualxml = virDomainDefFormat(vmdef, 0)))
goto fail;
@@ -72,9 +72,9 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0;
fail:
- free(expectxml);
- free(actualxml);
- free(cmd);
+ VIR_FREE(expectxml);
+ VIR_FREE(actualxml);
+ VIR_FREE(cmd);
virDomainDefFree(vmdef);
return ret;
}
@@ -103,8 +103,8 @@ testCompareXMLToArgvHelper(const void *data)
result = testCompareXMLToArgvFiles(xml, args, !!info->extraFlags);
cleanup:
- free(xml);
- free(args);
+ VIR_FREE(xml);
+ VIR_FREE(args);
return result;
}
@@ -192,8 +192,8 @@ mymain(void)
driver.vncTLSx509certdir = strdup("/etc/pki/tls/qemu");
DO_TEST("graphics-vnc-tls");
driver.vncSASL = driver.vncTLSx509verify = driver.vncTLS = 0;
- free(driver.vncSASLdir);
- free(driver.vncTLSx509certdir);
+ VIR_FREE(driver.vncSASLdir);
+ VIR_FREE(driver.vncTLSx509certdir);
driver.vncSASLdir = driver.vncTLSx509certdir = NULL;
DO_TEST("graphics-sdl");
@@ -238,7 +238,7 @@ mymain(void)
DO_TEST_FULL("qemu-ns-no-env", 1, NULL);
- free(driver.stateDir);
+ VIR_FREE(driver.stateDir);
virCapabilitiesFree(driver.caps);
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 23234f2..c8ce77f 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -120,7 +120,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (vmdef->emulator && STRPREFIX(vmdef->emulator, "/.")) {
if (!(emulator = strdup(vmdef->emulator + 1)))
goto out;
- free(vmdef->emulator);
+ VIR_FREE(vmdef->emulator);
vmdef->emulator = NULL;
if (virAsprintf(&vmdef->emulator, "%s/qemuxml2argvdata/%s",
abs_srcdir, emulator) < 0)
@@ -164,8 +164,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
qemuDomainPCIAddressSetFree(pciaddrs);
}
-
- free(virtTestLogContentAndReset());
+ log = virtTestLogContentAndReset();
+ VIR_FREE(log);
virResetLastError();
/* We do not call qemuCapsExtractVersionInfo() before calling
@@ -233,10 +233,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0;
out:
- free(log);
- free(emulator);
- free(expectargv);
- free(actualargv);
+ VIR_FREE(log);
+ VIR_FREE(emulator);
+ VIR_FREE(expectargv);
+ VIR_FREE(actualargv);
virCommandFree(cmd);
virDomainDefFree(vmdef);
virUnrefConnect(conn);
@@ -275,8 +275,8 @@ testCompareXMLToArgvHelper(const void *data)
info->expectFailure);
cleanup:
- free(xml);
- free(args);
+ VIR_FREE(xml);
+ VIR_FREE(args);
return result;
}
@@ -307,7 +307,7 @@ mymain(void)
return EXIT_FAILURE;
if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0
||
cpuMapOverride(map) < 0) {
- free(map);
+ VIR_FREE(map);
return EXIT_FAILURE;
}
@@ -499,8 +499,8 @@ mymain(void)
driver.vncTLSx509certdir = strdup("/etc/pki/tls/qemu");
DO_TEST("graphics-vnc-tls", false, NONE);
driver.vncSASL = driver.vncTLSx509verify = driver.vncTLS = 0;
- free(driver.vncSASLdir);
- free(driver.vncTLSx509certdir);
+ VIR_FREE(driver.vncSASLdir);
+ VIR_FREE(driver.vncTLSx509certdir);
driver.vncSASLdir = driver.vncTLSx509certdir = NULL;
DO_TEST("graphics-sdl", false, NONE);
@@ -738,9 +738,9 @@ mymain(void)
DO_TEST("pseries-vio-address-clash", true, QEMU_CAPS_DRIVE,
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
- free(driver.stateDir);
+ VIR_FREE(driver.stateDir);
virCapabilitiesFree(driver.caps);
- free(map);
+ VIR_FREE(map);
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 346e310..b0f80d3 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -48,9 +48,9 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
ret = 0;
fail:
- free(inXmlData);
- free(outXmlData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
virDomainDefFree(def);
return ret;
}
@@ -81,8 +81,8 @@ testCompareXMLToXMLHelper(const void *data)
}
cleanup:
- free(xml_in);
- free(xml_out);
+ VIR_FREE(xml_in);
+ VIR_FREE(xml_out);
return ret;
}
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index 0432cc4..6ae5880 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -69,7 +69,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (vmdef->emulator && STRPREFIX(vmdef->emulator, "/.")) {
if (!(emulator = strdup(vmdef->emulator + 1)))
goto fail;
- free(vmdef->emulator);
+ VIR_FREE(vmdef->emulator);
vmdef->emulator = NULL;
if (virAsprintf(&vmdef->emulator, "%s/qemuxml2argvdata/%s",
abs_srcdir, emulator) < 0)
@@ -107,7 +107,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
}
- free(virtTestLogContentAndReset());
+ log = virtTestLogContentAndReset();
+ VIR_FREE(log);
virResetLastError();
/* We do not call qemuCapsExtractVersionInfo() before calling
@@ -159,10 +160,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0;
fail:
- free(log);
- free(emulator);
- free(expectargv);
- free(actualargv);
+ VIR_FREE(log);
+ VIR_FREE(emulator);
+ VIR_FREE(expectargv);
+ VIR_FREE(actualargv);
virCommandFree(cmd);
virDomainDefFree(vmdef);
virUnrefConnect(conn);
@@ -198,8 +199,8 @@ testCompareXMLToArgvHelper(const void *data)
info->json, info->expectError);
cleanup:
- free(xml);
- free(args);
+ VIR_FREE(xml);
+ VIR_FREE(args);
return result;
}
@@ -231,7 +232,7 @@ mymain(void)
return EXIT_FAILURE;
if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0
||
cpuMapOverride(map) < 0) {
- free(map);
+ VIR_FREE(map);
return EXIT_FAILURE;
}
@@ -275,9 +276,9 @@ mymain(void)
DO_TEST("qemu-ns-commandline-ns0", false, NONE);
DO_TEST("qemu-ns-commandline-ns1", false, NONE);
- free(driver.stateDir);
+ VIR_FREE(driver.stateDir);
virCapabilitiesFree(driver.caps);
- free(map);
+ VIR_FREE(map);
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
diff --git a/tests/qparamtest.c b/tests/qparamtest.c
index 6dfac43..78551c6 100644
--- a/tests/qparamtest.c
+++ b/tests/qparamtest.c
@@ -71,7 +71,7 @@ qparamFormatTest(const void *data)
ret = 0;
fail:
- free(output);
+ VIR_FREE(output);
free_qparam_set(actual);
return ret;
}
diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c
index 126a78c..12d9086 100644
--- a/tests/sexpr2xmltest.c
+++ b/tests/sexpr2xmltest.c
@@ -67,9 +67,9 @@ testCompareFiles(const char *xml, const char *sexpr, int
xendConfigVersion)
ret = 0;
fail:
- free(xmlData);
- free(sexprData);
- free(gotxml);
+ VIR_FREE(xmlData);
+ VIR_FREE(sexprData);
+ VIR_FREE(gotxml);
virDomainDefFree(def);
if (conn)
virUnrefConnect(conn);
@@ -101,8 +101,8 @@ testCompareHelper(const void *data)
result = testCompareFiles(xml, args, info->version);
cleanup:
- free(xml);
- free(args);
+ VIR_FREE(xml);
+ VIR_FREE(args);
return result;
}
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index f2c1780..886f310 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -41,9 +41,9 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
ret = 0;
fail:
- free(inXmlData);
- free(outXmlData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
virStoragePoolDefFree(dev);
return ret;
}
@@ -65,8 +65,8 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(inxml, outxml);
cleanup:
- free(inxml);
- free(outxml);
+ VIR_FREE(inxml);
+ VIR_FREE(outxml);
return result;
}
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
index c8dddbb..742a02c 100644
--- a/tests/storagevolxml2xmltest.c
+++ b/tests/storagevolxml2xmltest.c
@@ -49,10 +49,10 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
ret = 0;
fail:
- free(poolXmlData);
- free(inXmlData);
- free(outXmlData);
- free(actual);
+ VIR_FREE(poolXmlData);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
virStoragePoolDefFree(pool);
virStorageVolDefFree(dev);
return ret;
@@ -84,9 +84,9 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(poolxml, inxml, outxml);
cleanup:
- free(poolxml);
- free(inxml);
- free(outxml);
+ VIR_FREE(poolxml);
+ VIR_FREE(inxml);
+ VIR_FREE(outxml);
return result;
}
diff --git a/tests/testutils.c b/tests/testutils.c
index fccea17..8678546 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -128,8 +128,7 @@ virtTestRun(const char *title, int nloops, int (*body)(const void
*data), const
fprintf(stderr, "%2d) %-65s ... ", testCounter, title);
}
- if (nloops > 1 && (ts = calloc(nloops,
- sizeof(double)))==NULL)
+ if (nloops > 1 && (VIR_ALLOC_N(ts, nloops) < 0))
return -1;
for (i=0; i < nloops; i++) {
@@ -181,7 +180,7 @@ virtTestRun(const char *title, int nloops, int (*body)(const void
*data), const
}
}
- free(ts);
+ VIR_FREE(ts);
return ret;
}
@@ -236,7 +235,7 @@ virtTestLoadFile(const char *file, char **buf)
if (ferror(fp)) {
fprintf (stderr, "%s: read failed: %s\n", file, strerror(errno));
VIR_FORCE_FCLOSE(fp);
- free(*buf);
+ VIR_FREE(*buf);
return -1;
}
}
@@ -512,7 +511,7 @@ virtTestErrorHook(int n, void *data ATTRIBUTE_UNUSED)
if (symbols[i])
fprintf(stderr, " TRACE: %s\n", symbols[i]);
}
- free(symbols);
+ VIR_FREE(symbols);
}
}
#endif
diff --git a/tests/testutils.h b/tests/testutils.h
index 03d8dc6..2fde1b5 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -1,7 +1,7 @@
/*
* utils.c: test utils
*
- * Copyright (C) 2005, 2008-2011 Red Hat, Inc.
+ * Copyright (C) 2005, 2008-2012 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -12,6 +12,7 @@
# define __VIT_TEST_UTILS_H__
# include <stdio.h>
+# include "memory.h"
# define EXIT_AM_SKIP 77 /* tell Automake we're skipping a test */
# define EXIT_AM_HARDFAIL 99 /* tell Automake that the framework is broken */
diff --git a/tests/virshtest.c b/tests/virshtest.c
index 9a39d46..6474c19 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -76,7 +76,7 @@ testCompareOutputLit(const char *expectData,
result = 0;
cleanup:
- free(actualData);
+ VIR_FREE(actualData);
return result;
}
@@ -388,7 +388,7 @@ mymain(void)
# undef DO_TEST
- free(custom_uri);
+ VIR_FREE(custom_uri);
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
diff --git a/tests/xencapstest.c b/tests/xencapstest.c
index ca93857..321f38a 100644
--- a/tests/xencapstest.c
+++ b/tests/xencapstest.c
@@ -54,11 +54,11 @@ testCompareFiles(const char *hostmachine, const char *xml_rel,
ret = 0;
fail:
- free(expectxml);
- free(actualxml);
- free(xml);
- free(cpuinfo);
- free(capabilities);
+ VIR_FREE(expectxml);
+ VIR_FREE(actualxml);
+ VIR_FREE(xml);
+ VIR_FREE(cpuinfo);
+ VIR_FREE(capabilities);
VIR_FORCE_FCLOSE(fp1);
VIR_FORCE_FCLOSE(fp2);
diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
index c184b8d..f1e028a 100644
--- a/tests/xmconfigtest.c
+++ b/tests/xmconfigtest.c
@@ -87,9 +87,9 @@ testCompareParseXML(const char *xmcfg, const char *xml, int
xendConfigVersion)
ret = 0;
fail:
- free(xmlData);
- free(xmcfgData);
- free(gotxmcfgData);
+ VIR_FREE(xmlData);
+ VIR_FREE(xmcfgData);
+ VIR_FREE(gotxmcfgData);
if (conf)
virConfFree(conf);
virDomainDefFree(def);
@@ -179,8 +179,8 @@ testCompareHelper(const void *data)
result = testCompareFormatXML(cfg, xml, info->version);
cleanup:
- free(xml);
- free(cfg);
+ VIR_FREE(xml);
+ VIR_FREE(cfg);
return result;
}
diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c
index 41712d3..12d63b6 100644
--- a/tests/xml2sexprtest.c
+++ b/tests/xml2sexprtest.c
@@ -46,9 +46,9 @@ testCompareFiles(const char *xml, const char *sexpr, int
xendConfigVersion)
ret = 0;
fail:
- free(xmlData);
- free(sexprData);
- free(gotsexpr);
+ VIR_FREE(xmlData);
+ VIR_FREE(sexprData);
+ VIR_FREE(gotsexpr);
virDomainDefFree(def);
return ret;
@@ -79,8 +79,8 @@ testCompareHelper(const void *data)
result = testCompareFiles(xml, args, info->version);
cleanup:
- free(xml);
- free(args);
+ VIR_FREE(xml);
+ VIR_FREE(args);
return result;
}
--
1.7.7.6