From: David van Moolenbroek Date: Wed, 5 Oct 2016 17:37:56 +0000 (+0000) Subject: libc: bugfixes for minix's poll(3) wrapper X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/nslookup.html?a=commitdiff_plain;h=6956dd2b516c6d226afb5b4ae854532a02fcbd3d;p=minix.git libc: bugfixes for minix's poll(3) wrapper - clear "revents" fields even when the call times out; - do not call FD_ISSET with a negative file descriptor number. Change-Id: I7aeaae79e73e39aed127a75495ea08256b18c182 --- diff --git a/minix/lib/libc/sys/poll.c b/minix/lib/libc/sys/poll.c index 72fe6238e..8735833c2 100644 --- a/minix/lib/libc/sys/poll.c +++ b/minix/lib/libc/sys/poll.c @@ -57,6 +57,7 @@ poll(struct pollfd *p, nfds_t nfds, int timout) highfd = -1; for (i = 0; i < nfds; i++) { + p[i].revents = 0; if (p[i].fd < 0) continue; if (p[i].fd >= FD_SETSIZE) { @@ -83,7 +84,8 @@ poll(struct pollfd *p, nfds_t nfds, int timout) rval = 0; for (i = 0; i < nfds; i++) { - p[i].revents = 0; + if (p[i].fd < 0) + continue; if (FD_ISSET(p[i].fd, &rd)) p[i].revents |= POLLIN|POLLRDNORM|POLLRDBAND|POLLPRI; if (FD_ISSET(p[i].fd, &wr))