static unsigned int _poll_setup_pollfds(struct pollfd *pfds, eio_obj_t *map[], List l) { ListIterator i = list_iterator_create(l); eio_obj_t *obj = NULL; unsigned int nfds = 0; bool readable, writable; while ((obj = list_next(i))) { writable = _is_writable(obj); readable = _is_readable(obj); if (writable && readable) { pfds[nfds].fd = obj->fd; pfds[nfds].events = POLLOUT | POLLIN; map[nfds] = obj; nfds++; } else if (readable) { pfds[nfds].fd = obj->fd; pfds[nfds].events = POLLIN; map[nfds] = obj; nfds++; } else if (writable) { pfds[nfds].fd = obj->fd; pfds[nfds].events = POLLOUT; map[nfds] = obj; nfds++; } } list_iterator_destroy(i); return nfds; }
static unsigned int _poll_setup_pollfds(struct pollfd *pfds, eio_obj_t *map[], List l) { ListIterator i = list_iterator_create(l); eio_obj_t *obj = NULL; unsigned int nfds = 0; bool readable, writable; if (!pfds) { /* Fix for CLANG false positive */ fatal("pollfd data structure is null"); return nfds; } while ((obj = list_next(i))) { writable = _is_writable(obj); readable = _is_readable(obj); if (writable && readable) { pfds[nfds].fd = obj->fd; #ifdef POLLRDHUP /* Available since Linux 2.6.17 */ pfds[nfds].events = POLLOUT | POLLIN | POLLHUP | POLLRDHUP; #else pfds[nfds].events = POLLOUT | POLLIN | POLLHUP; #endif map[nfds] = obj; nfds++; } else if (readable) { pfds[nfds].fd = obj->fd; #ifdef POLLRDHUP /* Available since Linux 2.6.17 */ pfds[nfds].events = POLLIN | POLLRDHUP; #else pfds[nfds].events = POLLIN; #endif map[nfds] = obj; nfds++; } else if (writable) { pfds[nfds].fd = obj->fd; pfds[nfds].events = POLLOUT | POLLHUP; map[nfds] = obj; nfds++; } } list_iterator_destroy(i); return nfds; }