summaryrefslogtreecommitdiff
path: root/lib9p
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-09-29 12:04:57 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-09-29 12:04:57 -0600
commit6940b244de7c5048c55fc57ada93501c1be5ab20 (patch)
tree42734faad626d97f45fce0725031896824924701 /lib9p
parent7b34cb7741c683dc623ece652032f1bf09d34140 (diff)
fixes
Diffstat (limited to 'lib9p')
-rw-r--r--lib9p/srv.c12
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;
}