diff mbox

[dpdk-dev,v2,3/3] app/test: fix devargs tests

Message ID 1423839795-29450-4-git-send-email-david.marchand@6wind.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

David Marchand Feb. 13, 2015, 3:03 p.m. UTC
Add missing free for devargs->args and fix tests.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 app/test/test_devargs.c |    6 ++++--
 app/test/test_pci.c     |    2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/app/test/test_devargs.c b/app/test/test_devargs.c
index 3d9f7bc..08fb781 100644
--- a/app/test/test_devargs.c
+++ b/app/test/test_devargs.c
@@ -48,6 +48,8 @@  static void free_devargs_list(void)
 	while (!TAILQ_EMPTY(&devargs_list)) {
 		devargs = TAILQ_FIRST(&devargs_list);
 		TAILQ_REMOVE(&devargs_list, devargs, next);
+		if (devargs->args)
+			free(devargs->args);
 		free(devargs);
 	}
 }
@@ -92,7 +94,7 @@  test_devargs(void)
 	if (strncmp(devargs->virtual.drv_name, "eth_ring1",
 			sizeof(devargs->virtual.drv_name)) != 0)
 		goto fail;
-	if (strncmp(devargs->args, "k1=val,k2=val2", sizeof(devargs->args)) != 0)
+	if (!devargs->args || strcmp(devargs->args, "k1=val,k2=val2") != 0)
 		goto fail;
 	free_devargs_list();
 
@@ -105,7 +107,7 @@  test_devargs(void)
 		devargs->pci.addr.devid != 0 ||
 		devargs->pci.addr.function != 1)
 		goto fail;
-	if (strncmp(devargs->args, "", sizeof(devargs->args)) != 0)
+	if (devargs->args)
 		goto fail;
 	free_devargs_list();
 
diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index 747d8b7..5530d99 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -139,6 +139,8 @@  static void free_devargs_list(void)
 	while (!TAILQ_EMPTY(&devargs_list)) {
 		devargs = TAILQ_FIRST(&devargs_list);
 		TAILQ_REMOVE(&devargs_list, devargs, next);
+		if (devargs->args)
+			free(devargs->args);
 		free(devargs);
 	}
 }