Signed-off-by: Ján Tomko
---
tests/commandtest.c | 7 +++
tests/domaincapstest.c | 3 +--
tests/fdstreamtest.c | 10 --
tests/qemuxml2argvtest.c | 3 +--
tests/securityselinuxlabeltest.c | 3 +--
tests/securityselinuxtest.c | 3 +--
tests/testutils.c| 8 ++--
tests/testutilsqemu.c| 6 ++
tests/vircgrouptest.c| 3 +--
tests/vircryptotest.c| 5 ++---
tests/virhostcputest.c | 3 +--
tests/virnetmessagetest.c| 6 ++
tests/virnetsockettest.c | 6 +-
tests/virnettlshelpers.c | 3 +--
tests/virstringtest.c| 3 +--
tests/xlconfigtest.c | 3 +--
tests/xmconfigtest.c | 3 +--
17 files changed, 26 insertions(+), 52 deletions(-)
diff --git a/tests/commandtest.c b/tests/commandtest.c
index cbbcda4e5f..df86725f0e 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -1057,10 +1057,9 @@ static int test27(const void *unused G_GNUC_UNUSED)
"%s%s%s" \
"END STDERR\n"
-if (VIR_ALLOC_N(buffer0, buflen) < 0 ||
-VIR_ALLOC_N(buffer1, buflen) < 0 ||
-VIR_ALLOC_N(buffer2, buflen) < 0)
-goto cleanup;
+buffer0 = g_new0(char, buflen);
+buffer1 = g_new0(char, buflen);
+buffer2 = g_new0(char, buflen);
memset(buffer0, 'H', buflen - 2);
buffer0[buflen - 2] = '\n';
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index d2ed820cf9..b3d36f55fc 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -147,8 +147,7 @@ fillXenCaps(virDomainCapsPtr domCaps)
virFirmwarePtr *firmwares;
int ret = -1;
-if (VIR_ALLOC_N(firmwares, 2) < 0)
-return ret;
+firmwares = g_new0(virFirmwarePtr, 2);
if (VIR_ALLOC(firmwares[0]) < 0 || VIR_ALLOC(firmwares[1]) < 0)
goto cleanup;
diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c
index 83973137e7..7a2fe27477 100644
--- a/tests/fdstreamtest.c
+++ b/tests/fdstreamtest.c
@@ -54,9 +54,8 @@ static int testFDStreamReadCommon(const char *scratchdir,
bool blocking)
if (!(conn = virConnectOpen("test:///default")))
goto cleanup;
-if (VIR_ALLOC_N(pattern, PATTERN_LEN) < 0 ||
-VIR_ALLOC_N(buf, PATTERN_LEN) < 0)
-goto cleanup;
+pattern = g_new0(char, PATTERN_LEN);
+buf = g_new0(char, PATTERN_LEN);
for (i = 0; i < PATTERN_LEN; i++)
pattern[i] = i;
@@ -185,9 +184,8 @@ static int testFDStreamWriteCommon(const char *scratchdir,
bool blocking)
if (!(conn = virConnectOpen("test:///default")))
goto cleanup;
-if (VIR_ALLOC_N(pattern, PATTERN_LEN) < 0 ||
-VIR_ALLOC_N(buf, PATTERN_LEN) < 0)
-goto cleanup;
+pattern = g_new0(char, PATTERN_LEN);
+buf = g_new0(char, PATTERN_LEN);
for (i = 0; i < PATTERN_LEN; i++)
pattern[i] = i;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e93948e3fc..463e4c003d 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -753,8 +753,7 @@ mymain(void)
driver.config->nbdTLSx509certdir =
g_strdup("/etc/pki/libvirt-nbd/dummy,path");
VIR_FREE(driver.config->hugetlbfs);
-if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0)
-return EXIT_FAILURE;
+driver.config->hugetlbfs = g_new0(virHugeTLBFS, 2);
driver.config->nhugetlbfs = 2;
driver.config->hugetlbfs[0].mnt_dir = g_strdup("/dev/hugepages2M");
driver.config->hugetlbfs[1].mnt_dir = g_strdup("/dev/hugepages1G");
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index 2989a668b7..168acc2bdf 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -114,8 +114,7 @@ testSELinuxLoadFileList(const char *testname,
if (!(fp = fopen(path, "r")))
goto cleanup;
-if (VIR_ALLOC_N(line, 1024) < 0)
-goto cleanup;
+line = g_new0(char, 1024);
while (!feof(fp)) {
char *file = NULL, *context = NULL, *tmp;
diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c
index ae4b08b9d8..fd746d1ca1 100644
--- a/tests/securityselinuxtest.c
+++ b/tests/securityselinuxtest.c
@@ -71,8 +71,7 @@ testBuildDomainDef(bool dynamic,
goto error;
def->virtType = VIR_DOMAIN_VIRT_KVM;
-if (VIR_ALLOC_N(def->seclabels, 1) < 0)
-goto error;
+def->seclabels = g_new0(char, 1);
if (VIR_ALLOC(secdef) < 0)
goto error;
diff --git a/tests/testutils.c b/tests/testutils.c
index 3f53f635fc..b747f65eea 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -211,10 +211,7 @@ virTestLoadFile(const char *file, char **buf)
tmplen = buflen = st.st_size + 1;
-if (VIR_ALLOC_N(*buf, buflen) < 0) {
-VIR_FORCE_FCLOSE(fp);
-return -1;
-}
+*buf = g_new0(char, buflen);
tmp = *buf;
(*buf)[0] = '\0';
@@ -977,8 +974,7 @@ virTestCapsBuildNUMATopology(int