diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2022-06-08 09:48:11 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2022-06-08 09:48:11 +0000 |
commit | c4e81d83b248aa356849fc6a31920c177b5df999 (patch) | |
tree | 7b7516686db13bfb3643c0965fded313ea7240a9 /src/libstddjb/openreadnclose.c | |
parent | 6d419ff3e5a0e645e8fe9635d6ca139d5b7e3e7a (diff) | |
download | skalibs-c4e81d83b248aa356849fc6a31920c177b5df999.tar.xz |
Clean up / homogenize openreadnclose() family
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/openreadnclose.c')
-rw-r--r-- | src/libstddjb/openreadnclose.c | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/src/libstddjb/openreadnclose.c b/src/libstddjb/openreadnclose.c index 4466796..5f39c43 100644 --- a/src/libstddjb/openreadnclose.c +++ b/src/libstddjb/openreadnclose.c @@ -1,33 +1,9 @@ /* ISC license. */ -#include <sys/types.h> -#include <errno.h> -#include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> -static ssize_t readnclose (int fd, char *s, size_t n) -{ - size_t r ; - errno = 0 ; - r = allread(fd, s, n) ; - if (errno) - { - fd_close(fd) ; - return -1 ; - } - fd_close(fd) ; - if (r < n) errno = EPIPE ; - return r ; -} - ssize_t openreadnclose (char const *file, char *s, size_t n) { int fd = openbc_read(file) ; - return fd < 0 ? fd : readnclose(fd, s, n) ; -} - -ssize_t openreadnclose_nb (char const *file, char *s, size_t n) -{ - int fd = openc_read(file) ; - return fd < 0 ? fd : readnclose(fd, s, n) ; + return fd == -1 ? fd : readnclose(fd, s, n) ; } |