[v2] dma-buf: heaps: bugfix for selftest failure

xiaolong he hexiaolong2008 at gmail.com
Wed Mar 18 02:47:15 UTC 2020


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


More information about the dri-devel mailing list