[libvirt] [PATCH 0/2] Coverity/Valgrind issues

One new Coverity defect was discovered from existing code in this mornings run. Also recent changes seem to have adjusted tests and provoked valgrind to find/display potential leaks. That path had already been vetted previously in a shorter stack trace - just adjust the trace to allow inclusion of more traces. John Ferlan (2): tests: Coverity found new NULL_RETURNS valgrind: Adjust filter for _dl_allocate_tls tests/.valgrind.supp | 6 ++++-- tests/jsontest.c | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) -- 1.8.1.4

Coverity reported the existing missing check of the return value and subsequent use from a call to virJSONValueFromString() in testJSONAddRemove(). --- tests/jsontest.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/jsontest.c b/tests/jsontest.c index a37a980..1d385d4 100644 --- a/tests/jsontest.c +++ b/tests/jsontest.c @@ -60,11 +60,17 @@ testJSONAddRemove(const void *data) { const struct testInfo *info = data; virJSONValuePtr json; - virJSONValuePtr name; + virJSONValuePtr name = NULL; char *result = NULL; int ret = -1; json = virJSONValueFromString(info->doc); + if (!json) { + if (virTestGetVerbose()) + fprintf(stderr, "Fail to parse %s\n", info->doc); + ret = -1; + goto cleanup; + } switch (virJSONValueObjectRemoveKey(json, "name", &name)) { case 1: -- 1.8.1.4

On 08/01/2013 02:06 PM, John Ferlan wrote:
Coverity reported the existing missing check of the return value and subsequent use from a call to virJSONValueFromString() in testJSONAddRemove(). --- tests/jsontest.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
ACK.
diff --git a/tests/jsontest.c b/tests/jsontest.c index a37a980..1d385d4 100644 --- a/tests/jsontest.c +++ b/tests/jsontest.c @@ -60,11 +60,17 @@ testJSONAddRemove(const void *data) { const struct testInfo *info = data; virJSONValuePtr json; - virJSONValuePtr name; + virJSONValuePtr name = NULL; char *result = NULL; int ret = -1;
json = virJSONValueFromString(info->doc); + if (!json) { + if (virTestGetVerbose()) + fprintf(stderr, "Fail to parse %s\n", info->doc); + ret = -1; + goto cleanup; + }
switch (virJSONValueObjectRemoveKey(json, "name", &name)) { case 1:
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

More tests are now using the path - adjust the filter to include any path from a test through ptrhread_create to _dl_allocate_tls --- tests/.valgrind.supp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/.valgrind.supp b/tests/.valgrind.supp index f04912d..d4fef85 100644 --- a/tests/.valgrind.supp +++ b/tests/.valgrind.supp @@ -62,14 +62,16 @@ obj:*/lib*/libc-2.*so* } # -# Failure seen in eventtest +# Failure seen in eventtest, qemumonitorjsontest, qemuhotplugtest, +# qemuagenttest # { - eventtestMemoryLeak + dlAllocateTlsMemoryLeak Memcheck:Leak fun:calloc fun:_dl_allocate_tls fun:pthread_create* + ... fun:mymain fun:virtTestMain ... -- 1.8.1.4

On 08/01/2013 02:06 PM, John Ferlan wrote:
More tests are now using the path - adjust the filter to include any path from a test through ptrhread_create to _dl_allocate_tls
s/ptrhread/pthread/ ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/01/2013 04:06 PM, John Ferlan wrote:
One new Coverity defect was discovered from existing code in this mornings run. Also recent changes seem to have adjusted tests and provoked valgrind to find/display potential leaks. That path had already been vetted previously in a shorter stack trace - just adjust the trace to allow inclusion of more traces. John Ferlan (2): tests: Coverity found new NULL_RETURNS valgrind: Adjust filter for _dl_allocate_tls
tests/.valgrind.supp | 6 ++++-- tests/jsontest.c | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-)
Pushed w/ fixed typo in commit message (bad fingers doing what they want again ;-)) Tks, John
participants (2)
-
Eric Blake
-
John Ferlan