ok?

Index: rthread_rwlock_compat.c
===================================================================
RCS file: /cvs/src/lib/librthread/rthread_rwlock_compat.c,v
retrieving revision 1.1
diff -u -p -r1.1 rthread_rwlock_compat.c
--- rthread_rwlock_compat.c     13 Feb 2019 13:15:39 -0000      1.1
+++ rthread_rwlock_compat.c     14 May 2022 14:29:27 -0000
@@ -143,8 +143,7 @@ int
 pthread_rwlock_timedrdlock(pthread_rwlock_t *lockp,
     const struct timespec *abstime)
 {
-       if (abstime == NULL || abstime->tv_nsec < 0 ||
-           abstime->tv_nsec >= 1000000000)
+       if (abstime == NULL || !timespecisvalid(abstime))
                return (EINVAL);
        return (_rthread_rwlock_rdlock(lockp, abstime, 0));
 }
@@ -210,8 +209,7 @@ int
 pthread_rwlock_timedwrlock(pthread_rwlock_t *lockp,
     const struct timespec *abstime)
 {
-       if (abstime == NULL || abstime->tv_nsec < 0 ||
-           abstime->tv_nsec >= 1000000000)
+       if (abstime == NULL || !timespecisvalid(abstime))
                return (EINVAL);
        return (_rthread_rwlock_wrlock(lockp, abstime, 0));
 }
Index: rthread_sem.c
===================================================================
RCS file: /cvs/src/lib/librthread/rthread_sem.c,v
retrieving revision 1.32
diff -u -p -r1.32 rthread_sem.c
--- rthread_sem.c       6 Apr 2020 00:01:08 -0000       1.32
+++ rthread_sem.c       14 May 2022 14:29:27 -0000
@@ -254,8 +254,7 @@ sem_timedwait(sem_t *semp, const struct 
        int error;
        PREP_CANCEL_POINT(tib);
 
-       if (!semp || !(sem = *semp) || abstime == NULL ||
-          abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) {
+       if (!semp || !(sem = *semp) || !abstime || !timespecisvalid(abstime)) {
                errno = EINVAL;
                return (-1);
        }
Index: rthread_sem_compat.c
===================================================================
RCS file: /cvs/src/lib/librthread/rthread_sem_compat.c,v
retrieving revision 1.1
diff -u -p -r1.1 rthread_sem_compat.c
--- rthread_sem_compat.c        8 Jun 2018 13:53:01 -0000       1.1
+++ rthread_sem_compat.c        14 May 2022 14:29:27 -0000
@@ -19,6 +19,7 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 
 #include <errno.h>
 #include <fcntl.h>
@@ -266,8 +267,7 @@ sem_timedwait(sem_t *semp, const struct 
        int r;
        PREP_CANCEL_POINT(tib);
 
-       if (!semp || !(sem = *semp) || abstime == NULL ||
-           abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) {
+       if (!semp || !(sem = *semp) || !abstime || !timespecisvalid(abstime)) {
                errno = EINVAL;
                return (-1);
        }

Reply via email to