summaryrefslogtreecommitdiff
path: root/libhw/w5500.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-21 10:32:09 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-21 10:33:02 -0700
commit6639031e15b23d342efb87cc00fa51233d66b392 (patch)
tree4856b9797d914d76e2df0c524a13a173af87baae /libhw/w5500.c
parent57430f7c8de034ff4bdba5cdd9996316a4767fd7 (diff)
libhw: Allow zero-length TCP reads and writes
Diffstat (limited to 'libhw/w5500.c')
-rw-r--r--libhw/w5500.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libhw/w5500.c b/libhw/w5500.c
index dfe169f..a8777db 100644
--- a/libhw/w5500.c
+++ b/libhw/w5500.c
@@ -589,8 +589,9 @@ static int w5500_tcplist_close(struct _w5500_socket *socket) {
static ssize_t w5500_tcp_write(struct _w5500_socket *socket, void *buf, size_t count) {
debugf("tcp_conn.write(%zu)", count);
ASSERT_SELF(stream_conn, TCP);
- assert(buf);
- assert(count);
+ assert(count == 0 || buf);
+ if (count == 0)
+ return 0;
/* What we really want is to pause until we receive an ACK for
* some data we just queued, so that we can line up some new
@@ -677,8 +678,9 @@ static void w5500_tcp_alarm_handler(void *_arg) {
static ssize_t w5500_tcp_read(struct _w5500_socket *socket, void *buf, size_t count) {
debugf("tcp_conn.read()");
ASSERT_SELF(stream_conn, TCP);
- assert(buf);
- assert(count);
+ assert(count == 0 || buf);
+ if (count == 0)
+ return 0;
struct alarmclock_trigger trigger = {0};
if (socket->read_deadline_ns)