summaryrefslogtreecommitdiff
path: root/src/libstddjb/openreadnclose.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/openreadnclose.c')
-rw-r--r--src/libstddjb/openreadnclose.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libstddjb/openreadnclose.c b/src/libstddjb/openreadnclose.c
index 40edea9..fcecedc 100644
--- a/src/libstddjb/openreadnclose.c
+++ b/src/libstddjb/openreadnclose.c
@@ -1,27 +1,28 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/djbunix.h>
-static int readnclose (int fd, char *s, unsigned int n)
+static ssize_t readnclose (int fd, char *s, size_t n)
{
- register int r = allread(fd, s, n) ;
- register int e = errno ;
+ ssize_t r = allread(fd, s, n) ;
+ int e = errno ;
fd_close(fd) ;
- if ((r > 0) && (r < (int)n)) e = EPIPE ;
+ if ((r > 0) && (r < (ssize_t)n)) e = EPIPE ;
errno = e ;
return r ;
}
-int openreadnclose (char const *file, char *s, unsigned int n)
+ssize_t openreadnclose (char const *file, char *s, size_t n)
{
- register int fd = open_readb(file) ;
+ int fd = open_readb(file) ;
return fd < 0 ? fd : readnclose(fd, s, n) ;
}
-int openreadnclose_nb (char const *file, char *s, unsigned int n)
+ssize_t openreadnclose_nb (char const *file, char *s, size_t n)
{
- register int fd = open_read(file) ;
+ int fd = open_read(file) ;
return fd < 0 ? fd : readnclose(fd, s, n) ;
}