Cygwin: clock.h: add valid_timespec() to check timespec for validity

Use throughout, drop local timespec_bad() in timer.cc.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2019-01-18 14:31:01 +01:00
parent 7f983079d4
commit 397526dee8
6 changed files with 19 additions and 23 deletions

View File

@@ -69,7 +69,7 @@ clock_nanosleep (clockid_t clk_id, int flags, const struct timespec *rqtp,
__try
{
if (rqtp->tv_sec < 0 || rqtp->tv_nsec < 0 || rqtp->tv_nsec >= NSPERSEC)
if (!valid_timespec (*rqtp))
return EINVAL;
}
__except (NO_ERROR)
@@ -654,8 +654,7 @@ sigtimedwait (const sigset_t *set, siginfo_t *info, const timespec *timeout)
if (timeout)
{
if (timeout->tv_sec < 0
|| timeout->tv_nsec < 0 || timeout->tv_nsec > NSPERSEC)
if (!valid_timespec (*timeout))
{
set_errno (EINVAL);
return -1;