[vlc-devel] [PATCH 13/18] Implement vlc_poll() on OS/2

KO Myung-Hun komh78 at gmail.com
Fri Oct 21 18:04:05 CEST 2011



Rémi Denis-Courmont wrote:
> Le vendredi 21 octobre 2011 16:15:06 KO Myung-Hun, vous avez écrit :
>>> Either you need this...
>>>
>>>> +    if (nfds > FD_SETSIZE)
>>>> +    {
>>>> +        errno = EINVAL;
>>>> +        return -1;
>>>> +    }
>>>> +
>>>> +resume:
>>>> +    val = -1;
>>>> +    vlc_testcancel ();
>>>> +
>>>> +    FD_ZERO (&rdset);
>>>> +    FD_ZERO (&wrset);
>>>> +    FD_ZERO (&exset);
>>>> +    for (unsigned i = 0; i < nfds; i++)
>>>> +    {
>>>> +        int fd = fds[i].fd;
>>>> +
>>>> +        if (fds[i].fd >= FD_SETSIZE)
>>>> +        {
>>>> +            errno = EINVAL;
>>>> +            return -1;
>>>> +        }
>>>
>>> ...or you need that, depending how FD_SET() and FD_ISSET() are
>>> implemented. But I don't see why you'd need both checks.
>>
>> I think, it's possible that nfds is less than fd of fds, logically.
>>
>> For examples, FD_SETSIZE is 2048, fds[ 0 ].fd = 2049 and nfds = 1.
> 
> I don't know how fd_set is implemented on OS/2. If fd_set is a BSD-style bits 
> field (or equivalent), then you need the second check (fd >= FD_SETSIZE). If 
> fd_set is a table of file descriptors (or equivalent), then you might need to 
> check that you do not overflow the table size (nfds > FD_SETSIZE).
> 
> But I see no reasons why you would need to write both checks.
> 

I know, OS/2(kLIBC) uses a BSD-style bits field.

But, let's think about this case, nfds = FD_SETSIZE + 1.

In this case, one of fds.fd should be equal to or greater than FD_SETSIZE.

In addition, they are in the ascendant in the worst case.

The check for fd of fds fails at the end element.

If nfds is checked at first, we can save this time.

So, I think both checks have enough meaning.

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.0.14
Under OS/2 Warp 4 for Korean with FixPak #15
On AMD ThunderBird 1GHz with 512 MB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr




More information about the vlc-devel mailing list