From: Paul Eggert Date: Sun, 23 Apr 2017 01:48:39 +0000 (-0700) Subject: poll: improve fast check for out-of-range NFD X-Git-Tag: v1.0~6251 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=4082963953caf69f053dd553eb9cb0148d56e968;p=gnulib.git poll: improve fast check for out-of-range NFD * lib/poll.c: Do not include intprops.h. (poll): Compare NFD to INT_MAX, not to TYPE_MAXIMUM (nfds_t) / 2. * modules/poll (Depends-on): Remove intprops. --- diff --git a/ChangeLog b/ChangeLog index ad436a76a7..43dd861784 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2017-04-22 Paul Eggert + poll: improve fast check for out-of-range NFD + * lib/poll.c: Do not include intprops.h. + (poll): Compare NFD to INT_MAX, not to TYPE_MAXIMUM (nfds_t) / 2. + * modules/poll (Depends-on): Remove intprops. + ftoastr: cite a newer paper * lib/ftoastr.c (FTOASTR): In comment, cite Andrysco et al. 2016 instead of Loitsch 2010. diff --git a/lib/poll.c b/lib/poll.c index 69b3672f75..078b1bab41 100644 --- a/lib/poll.c +++ b/lib/poll.c @@ -60,7 +60,6 @@ #include #include "assure.h" -#include "intprops.h" #ifndef INFTIM # define INFTIM (-1) @@ -336,13 +335,13 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout) int maxfd, rc; nfds_t i; - if (nfd > TYPE_MAXIMUM (nfds_t) / 2) + if (nfd > INT_MAX) { errno = EINVAL; return -1; } - /* Don't check directly for NFD too large. Any practical use of a - too-large NFD is caught by one of the other checks below, and + /* Don't check directly for NFD greater than OPEN_MAX. Any practical use + of a too-large NFD is caught by one of the other checks below, and checking directly for getdtablesize is too much of a portability and/or performance and/or correctness hassle. */ @@ -434,7 +433,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout) int rc = 0; nfds_t i; - if (nfd > TYPE_MAXIMUM (nfds_t) / 2 || timeout < -1) + if (nfd > INT_MAX || timeout < -1) { errno = EINVAL; return -1; diff --git a/modules/poll b/modules/poll index a7d117f532..57f0631e72 100644 --- a/modules/poll +++ b/modules/poll @@ -9,7 +9,6 @@ Depends-on: poll-h alloca [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1] assure [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1] -intprops [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1] select [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1] sockets [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1] sys_select [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]