diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-01-07 21:43:42 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-01-07 21:43:42 +0000 |
commit | 1ddf95240c77ae0786dd29e14acdf3549be9094c (patch) | |
tree | ebff87b299cb9fec7a841c03ac13e54a9f165952 /src/skaembutils/s6-head.c | |
parent | 1a5f11e0cf9e5287a50f032838e787c38003a1a4 (diff) | |
download | s6-portable-utils-1ddf95240c77ae0786dd29e14acdf3549be9094c.tar.xz |
Types fix: first pass
Preparation for the skalibs size_t API change.
Diffstat (limited to 'src/skaembutils/s6-head.c')
-rw-r--r-- | src/skaembutils/s6-head.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/skaembutils/s6-head.c b/src/skaembutils/s6-head.c index 1ef24c0..589ff45 100644 --- a/src/skaembutils/s6-head.c +++ b/src/skaembutils/s6-head.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/sgetopt.h> @@ -13,10 +14,10 @@ #define USAGE "s6-head [ -S ] [ -1..9 | -n lines | -c chars ] [ file... ]" #define dieusage() strerr_dieusage(100, USAGE) -typedef int headfunc_t (int, unsigned int) ; +typedef int headfunc_t (int, size_t) ; typedef headfunc_t *headfunc_t_ref ; -static int dolines (int fd, unsigned int lines) +static int dolines (int fd, size_t lines) { char buf[BUFFER_INSIZE] ; buffer in = BUFFER_INIT(&buffer_read, fd, buf, BUFFER_INSIZE) ; @@ -24,15 +25,15 @@ static int dolines (int fd, unsigned int lines) siovec_t v[2] ; while (lines) { - unsigned int w = 0 ; - register int r = buffer_fill(&in) ; + size_t w = 0 ; + ssize_t r = buffer_fill(&in) ; if (r <= 0) return !r ; out.c.n = in.c.n ; out.c.p = in.c.p ; buffer_rpeek(&in, v) ; for (;;) { - unsigned int n = siovec_len(v, 2) ; - register unsigned int i ; + size_t n = siovec_len(v, 2) ; + size_t i ; if (!n) break ; i = siovec_bytechr(v, 2, '\n') ; if (i < n) @@ -53,12 +54,12 @@ static int dolines (int fd, unsigned int lines) return 1 ; } -static int safedolines (int fd, unsigned int lines) +static int safedolines (int fd, size_t lines) { char tmp[lines] ; while (lines) { - unsigned int r = allread(fd, tmp, lines) ; + size_t r = allread(fd, tmp, lines) ; if ((r < lines) && (errno != EPIPE)) return 0 ; lines -= byte_count(tmp, r, '\n') ; if (buffer_put(buffer_1, tmp, r) < (int)r) return 0 ; @@ -67,7 +68,7 @@ static int safedolines (int fd, unsigned int lines) return 1 ; } -static int safedochars (int fd, unsigned int chars) +static int safedochars (int fd, size_t chars) { return (fd_catn(fd, 1, chars) >= chars) ; } |