summaryrefslogtreecommitdiff
path: root/src/libstddjb
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb')
-rw-r--r--src/libstddjb/coe.c3
-rw-r--r--src/libstddjb/ndelay_off.c2
-rw-r--r--src/libstddjb/ndelay_on.c2
-rw-r--r--src/libstddjb/uncoe.c3
4 files changed, 4 insertions, 6 deletions
diff --git a/src/libstddjb/coe.c b/src/libstddjb/coe.c
index 9f9f184..a32c4ef 100644
--- a/src/libstddjb/coe.c
+++ b/src/libstddjb/coe.c
@@ -6,6 +6,5 @@
int coe (int fd)
{
int flags = fcntl(fd, F_GETFD, 0) ;
- if (flags < 0) return -1 ;
- return fcntl(fd, F_SETFD, flags | FD_CLOEXEC) ;
+ return flags < 0 ? flags : flags & FD_CLOEXEC ? 0 : fcntl(fd, F_SETFD, flags | FD_CLOEXEC) ;
}
diff --git a/src/libstddjb/ndelay_off.c b/src/libstddjb/ndelay_off.c
index 209fd2b..5ea68c6 100644
--- a/src/libstddjb/ndelay_off.c
+++ b/src/libstddjb/ndelay_off.c
@@ -6,5 +6,5 @@
int ndelay_off (int fd)
{
int got = fcntl(fd, F_GETFL) ;
- return (got == -1) ? -1 : fcntl(fd, F_SETFL, got & ~O_NONBLOCK) ;
+ return got < 0 ? got : got & O_NONBLOCK ? fcntl(fd, F_SETFL, got & ~O_NONBLOCK) : 0 ;
}
diff --git a/src/libstddjb/ndelay_on.c b/src/libstddjb/ndelay_on.c
index 63ffa58..1bf9527 100644
--- a/src/libstddjb/ndelay_on.c
+++ b/src/libstddjb/ndelay_on.c
@@ -6,5 +6,5 @@
int ndelay_on (int fd)
{
int got = fcntl(fd, F_GETFL) ;
- return (got == -1) ? -1 : fcntl(fd, F_SETFL, got | O_NONBLOCK) ;
+ return got < 0 ? got : got & O_NONBLOCK ? 0 : fcntl(fd, F_SETFL, got | O_NONBLOCK) ;
}
diff --git a/src/libstddjb/uncoe.c b/src/libstddjb/uncoe.c
index b6bf430..be7b90c 100644
--- a/src/libstddjb/uncoe.c
+++ b/src/libstddjb/uncoe.c
@@ -6,6 +6,5 @@
int uncoe (int fd)
{
int flags = fcntl(fd, F_GETFD, 0) ;
- if (flags < 0) return -1 ;
- return fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) ;
+ return flags < 0 ? flags : flags & FD_CLOEXEC ? fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) : 0 ;
}