commit 66a94e3ce6d7c193d13d0bad4b1b8f7ecd51f5d2
parent 83276cee93b10e5def83fa4ea7400accb9272566
Author: sin <sin@2f30.org>
Date: Fri, 22 Feb 2019 15:34:19 +0000
Simplify fill_chunker()
Juse use the utility function we have.
Diffstat:
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/chunker.c b/chunker.c
@@ -99,16 +99,9 @@ fill_chunker(struct chunker *chunker)
uint8_t *bp;
ssize_t n;
- while (chunker->cap != chunker->wpos) {
- bp = &chunker->buf[chunker->wpos];
- n = read(chunker->fd, bp, chunker->cap - chunker->wpos);
- if (n < 0)
- err(1, "read");
- else if (n == 0)
- break;
- chunker->wpos += n;
- }
-
+ bp = &chunker->buf[chunker->wpos];
+ n = xread(chunker->fd, bp, chunker->cap - chunker->wpos);
+ chunker->wpos += n;
return chunker->wpos;
}