From: Benjamin Marzinski Subject: Re: [PATCH 10/14] util/tests: use assert_non_null to ensure malloc, returns non-null pointer Date: Fri, 4 Sep 2020 16:31:29 -0500 Message-ID: <20200904213129.GF11108@octiron.msp.redhat.com> 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Content-Disposition: inline To: lixiaokeng Cc: linfeilong , dm-devel mailing list , Martin Wilck , "liuzhiqiang (I)" List-Id: dm-devel.ids 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 > 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); > --