lkml.org 
[lkml]   [2020]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [v2] dma-buf: heaps: bugfix for selftest failure
Dear Shuah:

> > @@ -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.
>

I don't agree with you about this comment. Initializing ret to 0 can
not solve this problem.
Because the ret value will be override by the following
dmabuf_heap_alloc() calls.

static int test_alloc_errors(char *heap_name)
{
int ret;

ret = dmabuf_heap_alloc(...);
...
ret = dmabuf_heap_alloc(...);
...
ret = dmabuf_heap_alloc_fdflags(...);
...

return ret;
}

The purpose for test_alloc_errors() is to pass some invalid parameters
to dmabuf_heap_alloc()
and wish it return some errors. So -1 is what we expect from
test_alloc_errors(). But the code
in main() will break the loop when the ret value is -1. So I reversed
the return value in test_alloc_errors().

int main(void)
{
while(...) {
...
ret = test_alloc_errors(dir->d_name);
if (ret)
break;
}
}

thanks,
-- Leon

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