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/libunixonacid | |
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/libunixonacid')
-rw-r--r-- | src/libunixonacid/openreadnclose_at.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/libunixonacid/openreadnclose_at.c b/src/libunixonacid/openreadnclose_at.c index 8100997..4858a69 100644 --- a/src/libunixonacid/openreadnclose_at.c +++ b/src/libunixonacid/openreadnclose_at.c @@ -1,20 +1,10 @@ /* ISC license. */ -#include <errno.h> - -#include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> -size_t openreadnclose_at (int dirfd, char const *file, char *s, size_t n) +ssize_t openreadnclose_at (int dirfd, char const *file, char *s, size_t n) { - size_t r ; - int e ; int fd = openc_readatb(dirfd, file) ; - if (fd < 0) return 0 ; - r = allread(fd, s, n) ; - e = errno ; - fd_close(fd) ; - errno = e ; - return r ; + return fd == -1 ? -1 : readnclose(fd, s, n) ; } |