diff options
Diffstat (limited to 'lib9p')
-rw-r--r-- | lib9p/srv.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c index 997d137..af713e2 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -53,7 +53,7 @@ struct lib9p_req { /* base utilities *************************************************************/ -#define nonrespond_errorf(...) fprintf(stderr, "error: " __VA_ARGS__) +#define nonrespond_errorf(fmt, ...) fprintf(stderr, "error: " fmt "\n" __VA_OPT__(,) __VA_ARGS__) static uint32_t rerror_overhead_for_version(enum lib9p_version version, uint8_t *scratch) { struct lib9p_ctx empty_ctx = { @@ -99,18 +99,20 @@ static void respond_error(struct lib9p_req *req) { /* read coroutine *************************************************************/ static bool read_at_least(int fd, uint8_t *buf, size_t goal, size_t *done) { + assert(buf); + assert(goal); + assert(done); while (*done < goal) { ssize_t r = netio_read(fd, &buf[*done], CONFIG_9P_MAX_MSG_SIZE - *done); if (r < 0) { nonrespond_errorf("read: %s", strerror(-r)); return true; } else if (r == 0) { - if (*done != 0) { + if (*done != 0) nonrespond_errorf("read: unexpected EOF"); - return true; - } - *done += r; + return true; } + *done += r; } return false; } |