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

Rémi Denis-Courmont remi at remlab.net
Fri Oct 21 17:17:59 CEST 2011


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.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis



More information about the vlc-devel mailing list