]> Zhao Yanbai Git Server - minix.git/commitdiff
libc: bugfixes for minix's poll(3) wrapper 63/3363/1
authorDavid van Moolenbroek <david@minix3.org>
Wed, 5 Oct 2016 17:37:56 +0000 (17:37 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Tue, 18 Oct 2016 12:18:41 +0000 (14:18 +0200)
- clear "revents" fields even when the call times out;
- do not call FD_ISSET with a negative file descriptor number.

Change-Id: I7aeaae79e73e39aed127a75495ea08256b18c182

minix/lib/libc/sys/poll.c

index 72fe6238e9225dcaac49ce498c9aea1b0d38b6f4..8735833c2c08a235120463442a8f4e8e3e0e09f4 100644 (file)
@@ -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))