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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Signed-off-by: lixiaokeng <lixiaokeng@xxxxxxxxxx>
Signed-off-by: Linfeilong <linfeilong@xxxxxxxxxx>
---
 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);
-- 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux