From mboxrd@z Thu Jan 1 00:00:00 1970 From: lixiaokeng Subject: [PATCH 10/14] util/tests: use assert_non_null to ensure malloc, returns non-null pointer Date: Wed, 2 Sep 2020 15:22:37 +0800 Message-ID: References: <37544d4c-950f-4281-3b66-e4d1884c5167@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <37544d4c-950f-4281-3b66-e4d1884c5167@huawei.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Content-Language: en-GB To: Martin Wilck , Benjamin Marzinski , Christophe Varoqui , dm-devel mailing list Cc: linfeilong , "liuzhiqiang (I)" List-Id: dm-devel.ids 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 Signed-off-by: lixiaokeng Signed-off-by: Linfeilong --- 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); --