diff options
Diffstat (limited to 'tests/pselect.c')
-rw-r--r-- | tests/pselect.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/pselect.c b/tests/pselect.c index a1eca0c6..54732e5c 100644 --- a/tests/pselect.c +++ b/tests/pselect.c @@ -1,6 +1,6 @@ /* pselect - synchronous I/O multiplexing - Copyright 2011-2022 Free Software Foundation, Inc. + Copyright 2011-2024 Free Software Foundation, Inc. This file is part of gnulib. @@ -45,6 +45,12 @@ pselect (int nfds, fd_set *restrict rfds, sigset_t origmask; struct timeval tv, *tvp; + if (nfds < 0 || nfds > FD_SETSIZE) + { + errno = EINVAL; + return -1; + } + if (timeout) { if (! (0 <= timeout->tv_nsec && timeout->tv_nsec < 1000000000)) @@ -53,8 +59,10 @@ pselect (int nfds, fd_set *restrict rfds, return -1; } - tv.tv_sec = timeout->tv_sec; - tv.tv_usec = (timeout->tv_nsec + 999) / 1000; + tv = (struct timeval) { + .tv_sec = timeout->tv_sec, + .tv_usec = (timeout->tv_nsec + 999) / 1000 + }; tvp = &tv; } else |