lkml.org 
[lkml]   [2020]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [v2] dma-buf: heaps: bugfix for selftest failure
From
Date
On 3/7/20 7:02 AM, Leon He wrote:
> From: Leon He <leon.he@unisoc.com>
>
> There are two errors in the dmabuf-heap selftest:
> 1. The 'char name[5]' was not initialized to zero, which will cause
> strcmp(name, "vgem") failed in check_vgem().
> 2. The return value of test_alloc_errors() should be reversed, other-
> wise the while loop in main() will be broken.
>
> Signed-off-by: Leon He <leon.he@unisoc.com>
> ---
> tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> index cd5e1f6..836b185 100644
> --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> @@ -22,7 +22,7 @@
> static int check_vgem(int fd)
> {
> drm_version_t version = { 0 };
> - char name[5];
> + char name[5] = { 0 };
> int ret;
>
> version.name_len = 4;

Please see my comment on v1 for this.

> @@ -357,7 +357,7 @@ static int test_alloc_errors(char *heap_name)
> if (heap_fd >= 0)
> close(heap_fd);
>
> - return ret;
> + return !ret;

This change doesn't make sense. Initializing ret to 0 is a better
way to go.

thanks,
-- Shuah

\
 
 \ /
  Last update: 2020-03-13 18:16    [W:0.046 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site