From b03688bfbb072f42970747bc2e6362c24b4b7ee8 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Thu, 2 Jan 2020 15:39:12 -0300 Subject: Linux: Fix clock_nanosleep time64 check The result of INTERNAL_SYSCALL_CANCEL should be checked with macros INTERNAL_SYSCALL_ERROR_P and INTERNAL_SYSCALL_ERRNO instead of comparing the result directly. Checked on powerpc-linux-gnu. --- sysdeps/unix/sysv/linux/clock_nanosleep.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index 993c3cc8a6..728137aa56 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -52,9 +52,10 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, err, clock_id, flags, req, rem); - if (r != -ENOSYS) - return (INTERNAL_SYSCALL_ERROR_P (r, err) - ? INTERNAL_SYSCALL_ERRNO (r, err) : 0); + if (! INTERNAL_SYSCALL_ERROR_P (r, err)) + return 0; + if (INTERNAL_SYSCALL_ERRNO (r, err) != ENOSYS) + return INTERNAL_SYSCALL_ERRNO (r, err); # endif /* __NR_clock_nanosleep_time64 */ if (! in_time_t_range (req->tv_sec)) @@ -65,11 +66,14 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec struct timespec tr32; struct timespec ts32 = valid_timespec64_to_timespec (*req); - r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, clock_id, flags, - &ts32, &tr32); - - if (r == -EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0) - *rem = valid_timespec_to_timespec64 (tr32); + r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, clock_id, flags, + &ts32, &tr32); + if (INTERNAL_SYSCALL_ERROR_P (r, err)) + { + if (INTERNAL_SYSCALL_ERRNO (r, err) == EINTR && rem != NULL + && (flags & TIMER_ABSTIME) == 0) + *rem = valid_timespec_to_timespec64 (tr32); + } #endif /* __ASSUME_TIME64_SYSCALLS */ return (INTERNAL_SYSCALL_ERROR_P (r, err) -- cgit v1.2.3