summaryrefslogtreecommitdiff
path: root/src/libstddjb/fd_ensure_open.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-07-06 14:54:18 +0000
committerLaurent Bercot <ska@appnovation.com>2023-07-06 14:54:18 +0000
commit9964840c291e46a0e001d930e2dd2fb0e1b16967 (patch)
tree4a3d455d89f1eb26ed17485dcde45596136bf6aa /src/libstddjb/fd_ensure_open.c
parent4f0ff15709ee9f0f025858ac85ec21a9d955e88e (diff)
downloadskalibs-9964840c291e46a0e001d930e2dd2fb0e1b16967.tar.xz
More jjk fixes
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/fd_ensure_open.c')
-rw-r--r--src/libstddjb/fd_ensure_open.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libstddjb/fd_ensure_open.c b/src/libstddjb/fd_ensure_open.c
index c42c90e..4c1b63c 100644
--- a/src/libstddjb/fd_ensure_open.c
+++ b/src/libstddjb/fd_ensure_open.c
@@ -2,18 +2,19 @@
#include <errno.h>
#include <fcntl.h>
+
#include <skalibs/djbunix.h>
int fd_ensure_open (int fd, int w)
{
int dummy ;
- if (fcntl(fd, F_GETFD, &dummy) < 0)
+ if (fcntl(fd, F_GETFD, &dummy) == -1)
{
int newfd ;
if (errno != EBADF) return 0 ;
newfd = open2("/dev/null", w ? O_WRONLY : O_RDONLY) ;
- if (newfd < 0) return 0 ;
- if (fd_move(fd, newfd) < 0)
+ if (newfd == -1) return 0 ;
+ if (fd_move(fd, newfd) == -1)
{
fd_close(newfd) ;
return 0 ;