[Mesa-dev] [v4 10/10] egl: dri2: support for creating images out of dma buffers
Chad Versace
chad.versace at linux.intel.com
Fri May 24 06:49:54 PDT 2013
On 05/23/2013 10:15 PM, Pohjolainen, Topi wrote:
> On Thu, May 23, 2013 at 09:39:30PM -0700, Chad Versace wrote:
>> When touching the src/egl/drivers/dri2 directory, use a commit subject
>> that looks like "egl/dri2: STUFF", not "egl: dri2: STUFF".
[snip]
>>> +/**
>>> + * The spec says:
>>> + *
>>> + * "If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT target,
>>> + * the EGL takes ownership of the file descriptor and is responsible for
>>> + * closing it, which it may do at any time while the EGLDisplay is
>>> + * initialized."
>>> + */
>>> +static void
>>> +dri2_take_dma_buf_ownership(const int *fds, unsigned num_fds)
>>> +{
>>> + int already_closed[num_fds];
>>> + unsigned num_closed = 0;
>>> + unsigned i, j;
>>> +
>>> + for (i = 0; i < num_fds; ++i) {
>>> + /**
>>> + * The same file descriptor can be referenced multiple times in case more
>>> + * than one plane is found in the same buffer, just with a different
>>> + * offset.
>>> + */
>>> + for (j = 0; j < num_closed; ++j) {
>>> + if (already_closed[j] == fds[i])
>>
>> The condition above has undefined behavior, ...
> There is the explicit counter 'num_closed' telling how many valid elements there
> are in 'already_closed'.
My mistake.
More information about the mesa-dev
mailing list