From c4e81d83b248aa356849fc6a31920c177b5df999 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 8 Jun 2022 09:48:11 +0000 Subject: Clean up / homogenize openreadnclose() family Signed-off-by: Laurent Bercot --- src/libunixonacid/openreadnclose_at.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/libunixonacid') 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 - -#include #include #include -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) ; } -- cgit v1.2.3