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

Benjamin Marzinski bmarzins at redhat.com
Fri Sep 4 21:31:29 UTC 2020


On Wed, Sep 02, 2020 at 03:22:37PM +0800, lixiaokeng wrote:
> 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.
> 
Reviewed-by: Benjamin Marzinski <bmarzins at redhat.com>
> 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