--- tests/commandhelper.c | 2 +- tests/commandtest.c | 8 ++------ tests/libvirtdconftest.c | 4 +--- tests/qemumonitortestutils.c | 17 +++++------------ tests/securityselinuxlabeltest.c | 24 ++++++------------------ tests/securityselinuxtest.c | 8 +++----- tests/testutils.c | 2 +- tests/virhashtest.c | 2 +- tests/virnetmessagetest.c | 20 +++++--------------- tests/virstoragetest.c | 5 +---- 10 files changed, 26 insertions(+), 66 deletions(-) diff --git a/tests/commandhelper.c b/tests/commandhelper.c index d492c70..10d2046 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -77,7 +77,7 @@ int main(int argc, char **argv) { origenv++; } - if (VIR_ALLOC_N(newenv, n) < 0) + if (VIR_ALLOC_N_QUIET(newenv, n) < 0) return EXIT_FAILURE; origenv = environ; diff --git a/tests/commandtest.c b/tests/commandtest.c index ec69dbd..62f0277 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -820,10 +820,8 @@ static int test20(const void *unused ATTRIBUTE_UNUSED) sigaction(SIGPIPE, &sig_action, NULL); - if (virAsprintf(&buf, "1\n%100000d\n", 2) < 0) { - virReportOOMError(); + if (virAsprintf(&buf, "1\n%100000d\n", 2) < 0) goto cleanup; - } virCommandSetInputBuffer(cmd, buf); if (virCommandRun(cmd, NULL) < 0) { @@ -996,10 +994,8 @@ mymain(void) return EXIT_FAILURE; virEventRegisterDefaultImpl(); - if (VIR_ALLOC(test) < 0) { - virReportOOMError(); + if (VIR_ALLOC(test) < 0) goto cleanup; - } if (virMutexInit(&test->lock) < 0) { printf("Unable to init mutex: %d\n", errno); diff --git a/tests/libvirtdconftest.c b/tests/libvirtdconftest.c index d45c31a..ba61a0f 100644 --- a/tests/libvirtdconftest.c +++ b/tests/libvirtdconftest.c @@ -78,10 +78,8 @@ munge_param(const char *datain, strlen(replace) + strlen(eol) + 1; - if (VIR_ALLOC_N(dataout, dataoutlen) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(dataout, dataoutlen) < 0) return NULL; - } memcpy(dataout, datain, (eq - datain) + 1); memcpy(dataout + (eq - datain) + 1, replace, strlen(replace)); diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 1a4bb88..56368a2 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -87,10 +87,8 @@ static int qemuMonitorTestAddReponse(qemuMonitorTestPtr test, if (have < want) { size_t need = want - have; - if (VIR_EXPAND_N(test->outgoing, test->outgoingCapacity, need) < 0) { - virReportOOMError(); + if (VIR_EXPAND_N(test->outgoing, test->outgoingCapacity, need) < 0) return -1; - } } want -= 2; @@ -403,7 +401,7 @@ qemuMonitorTestAddItem(qemuMonitorTestPtr test, qemuMonitorTestItemPtr item; if (VIR_ALLOC(item) < 0) - goto no_memory; + goto error; if (VIR_STRDUP(item->command_name, command_name) < 0 || VIR_STRDUP(item->response, response) < 0) @@ -412,7 +410,7 @@ qemuMonitorTestAddItem(qemuMonitorTestPtr test, virMutexLock(&test->lock); if (VIR_EXPAND_N(test->items, test->nitems, 1) < 0) { virMutexUnlock(&test->lock); - goto no_memory; + goto error; } test->items[test->nitems - 1] = item; @@ -420,8 +418,6 @@ qemuMonitorTestAddItem(qemuMonitorTestPtr test, return 0; -no_memory: - virReportOOMError(); error: qemuMonitorTestItemFree(item); return -1; @@ -457,7 +453,7 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virDomainXMLOptionPtr xmlopt) char *tmpdir_template = NULL; if (VIR_ALLOC(test) < 0) - goto no_memory; + goto error; if (virMutexInit(&test->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -478,7 +474,7 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virDomainXMLOptionPtr xmlopt) tmpdir_template = NULL; if (virAsprintf(&path, "%s/qemumonitorjsontest.sock", test->tmpdir) < 0) - goto no_memory; + goto error; test->json = json; if (!(test->vm = virDomainObjNew(xmlopt))) @@ -538,9 +534,6 @@ cleanup: VIR_FREE(path); return test; -no_memory: - virReportOOMError(); - error: VIR_FREE(tmpdir_template); qemuMonitorTestFree(test); diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index d2ba49b..efe825a 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -61,10 +61,8 @@ testSELinuxMungePath(char **path) char *tmp; if (virAsprintf(&tmp, "%s/securityselinuxlabeldata%s", - abs_builddir, *path) < 0) { - virReportOOMError(); + abs_builddir, *path) < 0) return -1; - } VIR_FREE(*path); *path = tmp; @@ -85,19 +83,15 @@ testSELinuxLoadFileList(const char *testname, *nfiles = 0; if (virAsprintf(&path, "%s/securityselinuxlabeldata/%s.txt", - abs_srcdir, testname) < 0) { - virReportOOMError(); + abs_srcdir, testname) < 0) goto cleanup; - } if (!(fp = fopen(path, "r"))) { goto cleanup; } - if (VIR_ALLOC_N(line, 1024) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(line, 1024) < 0) goto cleanup; - } while (!feof(fp)) { char *file, *context, *tmp; @@ -118,10 +112,8 @@ testSELinuxLoadFileList(const char *testname, tmp++; if (virAsprintf(&file, "%s/securityselinuxlabeldata%s", - abs_builddir, line) < 0) { - virReportOOMError(); + abs_builddir, line) < 0) goto cleanup; - } if (*tmp != '\0' && *tmp != '\n') { if (VIR_STRDUP(context, tmp) < 0) { VIR_FREE(file); @@ -135,10 +127,8 @@ testSELinuxLoadFileList(const char *testname, context = NULL; } - if (VIR_EXPAND_N(*files, *nfiles, 1) < 0) { - virReportOOMError(); + if (VIR_EXPAND_N(*files, *nfiles, 1) < 0) goto cleanup; - } (*files)[(*nfiles)-1].file = file; (*files)[(*nfiles)-1].context = context; @@ -163,10 +153,8 @@ testSELinuxLoadDef(const char *testname) size_t i; if (virAsprintf(&xmlfile, "%s/securityselinuxlabeldata/%s.xml", - abs_srcdir, testname) < 0) { - virReportOOMError(); + abs_srcdir, testname) < 0) goto cleanup; - } if (virFileReadAll(xmlfile, 1024*1024, &xmlstr) < 0) { goto cleanup; diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c index 8d85c68..e2806c1 100644 --- a/tests/securityselinuxtest.c +++ b/tests/securityselinuxtest.c @@ -69,13 +69,13 @@ testBuildDomainDef(bool dynamic, virSecurityLabelDefPtr secdef; if (VIR_ALLOC(def) < 0) - goto no_memory; + goto error; if (VIR_ALLOC_N(def->seclabels, 1) < 0) - goto no_memory; + goto error; if (VIR_ALLOC(secdef) < 0) - goto no_memory; + goto error; def->virtType = VIR_DOMAIN_VIRT_KVM; def->seclabels[0] = secdef; @@ -91,8 +91,6 @@ testBuildDomainDef(bool dynamic, return def; -no_memory: - virReportOOMError(); error: virDomainDefFree(def); return NULL; diff --git a/tests/testutils.c b/tests/testutils.c index 528e432..5fc2a9c 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -103,7 +103,7 @@ void virtTestResult(const char *name, int ret, const char *msg, ...) fprintf(stderr, "FAILED\n"); if (msg) { char *str; - if (virVasprintf(&str, msg, vargs) == 0) { + if (virVasprintfQuiet(&str, msg, vargs) == 0) { fprintf(stderr, "%s", str); VIR_FREE(str); } diff --git a/tests/virhashtest.c b/tests/virhashtest.c index 9b7fcbb..b028ead 100644 --- a/tests/virhashtest.c +++ b/tests/virhashtest.c @@ -18,7 +18,7 @@ #define testError(...) \ do { \ char *str; \ - if (virAsprintf(&str, __VA_ARGS__) == 0) { \ + if (virAsprintfQuiet(&str, __VA_ARGS__) == 0) { \ fprintf(stderr, "%s", str); \ VIR_FREE(str); \ } \ diff --git a/tests/virnetmessagetest.c b/tests/virnetmessagetest.c index 062c3ff..1aa4c25 100644 --- a/tests/virnetmessagetest.c +++ b/tests/virnetmessagetest.c @@ -49,10 +49,8 @@ static int testMessageHeaderEncode(const void *args ATTRIBUTE_UNUSED) unsigned long msg_buf_size = VIR_NET_MESSAGE_INITIAL + VIR_NET_MESSAGE_LEN_MAX; int ret = -1; - if (!msg) { - virReportOOMError(); + if (!msg) return -1; - } msg->header.prog = 0x11223344; msg->header.vers = 0x01; @@ -101,16 +99,12 @@ static int testMessageHeaderDecode(const void *args ATTRIBUTE_UNUSED) }; int ret = -1; - if (!msg) { - virReportOOMError(); + if (!msg) return -1; - } msg->bufferLength = 4; - if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) goto cleanup; - } memcpy(msg->buffer, input_buf, msg->bufferLength); msg->header.prog = 0x11223344; @@ -225,10 +219,8 @@ static int testMessagePayloadEncode(const void *args ATTRIBUTE_UNUSED) 0x00, 0x00, 0x00, 0x00, /* Error network pointer */ }; - if (!msg) { - virReportOOMError(); + if (!msg) return -1; - } memset(&err, 0, sizeof(err)); @@ -336,10 +328,8 @@ static int testMessagePayloadDecode(const void *args ATTRIBUTE_UNUSED) int ret = -1; msg->bufferLength = 4; - if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) goto cleanup; - } memcpy(msg->buffer, input_buffer, msg->bufferLength); memset(&err, 0, sizeof(err)); diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index fef4b37..61d36f7 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -98,10 +98,8 @@ testPrepImages(void) virAsprintf(&absqcow2, "%s/qcow2", datadir) < 0 || virAsprintf(&abswrap, "%s/wrap", datadir) < 0 || virAsprintf(&absqed, "%s/qed", datadir) < 0 || - virAsprintf(&abslink2, "%s/sub/link2", datadir) < 0) { - virReportOOMError(); + virAsprintf(&abslink2, "%s/sub/link2", datadir) < 0) goto cleanup; - } if (virFileMakePath(datadir "/sub") < 0) { fprintf(stderr, "unable to create directory %s\n", datadir "/sub"); @@ -271,7 +269,6 @@ testStorageChain(const void *args) NULLSTR(elt->directory), elt->backingStoreFormat, elt->backingStoreIsFile, elt->capacity, elt->encrypted) < 0) { - virReportOOMError(); VIR_FREE(expect); VIR_FREE(actual); goto cleanup; -- 1.8.1.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list