From 6940b244de7c5048c55fc57ada93501c1be5ab20 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 29 Sep 2024 12:04:57 -0600 Subject: fixes --- lib9p/srv.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib9p') 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; } -- cgit v1.2.3-2-g168b