[libvirt] [PATCH 0/2] Couple of small fixes

*** SOME BLURB HERE *** Michal Privoznik (2): nsstest: Drop useless @data check testutils: Adapt to highly unlikely case tests/nsstest.c | 3 --- tests/testutils.c | 13 ++++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) -- 2.7.3

The variable is dereferenced prior its check for NULL. The check itself does not make much sense anyway - it's our test, we know we are not passing NULL. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/nsstest.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/nsstest.c b/tests/nsstest.c index 9d7bc40..7399d9a 100644 --- a/tests/nsstest.c +++ b/tests/nsstest.c @@ -51,9 +51,6 @@ testGetHostByName(const void *opaque) int rv, tmp_errno = 0, tmp_herrno = 0; size_t i = 0, j = 0; - if (!data) - goto cleanup; - memset(&resolved, 0, sizeof(resolved)); rv = _nss_libvirt_gethostbyname2_r(data->hostname, -- 2.7.3

Coverity pointed out that getenv("PATH") may return NULL. Well, we check for that in virFindFileInPath() too. If this happens, we will pass NULL into strstr(). Ouch. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/testutils.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index 2df4250..d6cd193 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -813,9 +813,16 @@ virTestSetEnvPath(void) const char *path = getenv("PATH"); char *new_path = NULL; - if (strstr(path, abs_builddir) != path && - (virAsprintf(&new_path, "%s:%s", abs_builddir, path) < 0 || - setenv("PATH", new_path, 1) < 0)) + if (path) { + if (strstr(path, abs_builddir) != path && + virAsprintf(&new_path, "%s:%s", abs_builddir, path) < 0) + goto cleanup; + } else { + if (VIR_STRDUP(new_path, abs_builddir) < 0) + goto cleanup; + } + + if (setenv("PATH", new_path, 1) < 0) goto cleanup; ret = 0; -- 2.7.3

On Thu, Mar 24, 2016 at 03:18:49PM +0100, Michal Privoznik wrote:
*** SOME BLURB HERE ***
<BLURB/> ACK series
Michal Privoznik (2): nsstest: Drop useless @data check testutils: Adapt to highly unlikely case
tests/nsstest.c | 3 --- tests/testutils.c | 13 ++++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-)
-- 2.7.3
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (2)
-
Martin Kletzander
-
Michal Privoznik