From 0c99a8d8aa8ebfabe4d72d092a8c0d8298a233ba Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 14 May 2021 23:17:52 +0000 Subject: Cosmetic fixes --- src/libstddjb/fd_islocked.c | 2 +- src/libstddjb/fd_lock.c | 4 ++-- src/libstddjb/sysclock_set.c | 13 ++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src/libstddjb') diff --git a/src/libstddjb/fd_islocked.c b/src/libstddjb/fd_islocked.c index 8d5ef78..50603c0 100644 --- a/src/libstddjb/fd_islocked.c +++ b/src/libstddjb/fd_islocked.c @@ -14,5 +14,5 @@ int fd_islocked (int fd) .l_start = 0, .l_len = 0 } ; - return fcntl(fd, F_GETLK, &fl) < 0 ? -1 : fl.l_type != F_UNLCK ; + return fcntl(fd, F_GETLK, &fl) == -1 ? -1 : fl.l_type != F_UNLCK ; } diff --git a/src/libstddjb/fd_lock.c b/src/libstddjb/fd_lock.c index e9d1a62..a4ebaa5 100644 --- a/src/libstddjb/fd_lock.c +++ b/src/libstddjb/fd_lock.c @@ -19,8 +19,8 @@ int fd_lock (int fd, int w, int nb) int e = errno ; int r ; do r = fcntl(fd, nb ? F_SETLK : F_SETLKW, &fl) ; - while (r < 0 && errno == EINTR) ; - return r >= 0 ? 1 : + while (r == -1 && errno == EINTR) ; + return r != -1 ? 1 : errno == EACCES || error_isagain(errno) ? (errno = e, 0) : -1 ; } diff --git a/src/libstddjb/sysclock_set.c b/src/libstddjb/sysclock_set.c index 57e2abe..76917af 100644 --- a/src/libstddjb/sysclock_set.c +++ b/src/libstddjb/sysclock_set.c @@ -4,13 +4,6 @@ #include -#ifndef SKALIBS_HASCLOCKRT -# ifndef SKALIBS_HASSETTIMEOFDAY -# error "neither clockrt nor settimeofday sysdeps are present. How do your set your system clock?" -# endif -#endif - - #ifdef SKALIBS_HASCLOCKRT #include @@ -27,6 +20,7 @@ int sysclock_set (tain_t const *a) } #else +#ifdef SKALIBS_HASSETTIMEOFDAY #include #include @@ -42,4 +36,9 @@ int sysclock_set (tain_t const *a) return 1 ; } +#else + +#error "neither clockrt nor settimeofday sysdeps are present. How do your set your system clock?" + +#endif #endif -- cgit v1.2.3