[dm-devel] [PATCH 10/14] util/tests: use assert_non_null to ensure malloc, returns non-null pointer

lixiaokeng lixiaokeng at huawei.com
Wed Sep 2 07:22:37 UTC 2020


In tests/util.c, we should use assert_non_null to ensure
malloc() returns non-null pointer in both test_strlcpy_5
and test_strlcpy_6 func.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26 at huawei.com>
Signed-off-by: lixiaokeng <lixiaokeng at huawei.com>
Signed-off-by: Linfeilong <linfeilong at huawei.com>
---
 tests/util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/util.c b/tests/util.c
index 16774dff..455eeee5 100644
--- a/tests/util.c
+++ b/tests/util.c
@@ -523,6 +523,7 @@ static void test_strlcpy_5(void **state)
 	const int sz = sizeof(src_str);

 	tst = malloc(sz);
+	assert_non_null(tst);
 	memset(tst, 'f', sizeof(src_str));

 	rc = strlcpy(tst, src_str, sz);
@@ -540,6 +541,7 @@ static void test_strlcpy_6(void **state)
 	const int sz = sizeof(src_str);

 	tst = malloc(sz + 2);
+	assert_non_null(tst);
 	memset(tst, 'f', sz + 2);

 	rc = strlcpy(tst, src_str, sz + 2);
-- 




More information about the dm-devel mailing list