From 555c5a76be8bd96d704f1d0b4c5c425e6a6a6618 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Wed, 9 Sep 2026 15:53:44 -0300 Subject: [PATCH] fix C89 and be tests --- mongoose.c | 2 +- src/net_builtin.c | 2 +- test/mip_test.c | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mongoose.c b/mongoose.c index db675f79..d3f36346 100644 --- a/mongoose.c +++ b/mongoose.c @@ -9691,9 +9691,9 @@ static size_t txq_next(struct connstate *s, uint8_t **buf) { } static bool txq_add(struct connstate *s, const void *buf, size_t len) { - assert(len > 0); uint32_t n = (uint32_t) len; size_t off = s->txq.len, total = sizeof(n) + len; + assert(len > 0); if (mg_iobuf_add(&s->txq, off, NULL, total) != total) return false; memcpy(s->txq.buf + off, &n, sizeof(n)); memcpy(s->txq.buf + off + sizeof(n), buf, len); diff --git a/src/net_builtin.c b/src/net_builtin.c index beb29a38..2c7cad14 100644 --- a/src/net_builtin.c +++ b/src/net_builtin.c @@ -1433,9 +1433,9 @@ static size_t txq_next(struct connstate *s, uint8_t **buf) { } static bool txq_add(struct connstate *s, const void *buf, size_t len) { - assert(len > 0); uint32_t n = (uint32_t) len; size_t off = s->txq.len, total = sizeof(n) + len; + assert(len > 0); if (mg_iobuf_add(&s->txq, off, NULL, total) != total) return false; memcpy(s->txq.buf + off, &n, sizeof(n)); memcpy(s->txq.buf + off + sizeof(n), buf, len); diff --git a/test/mip_test.c b/test/mip_test.c index 29b2660a..ebcc041f 100644 --- a/test/mip_test.c +++ b/test/mip_test.c @@ -981,8 +981,9 @@ static void test_tcp_retransmit_queue(void) { struct ipp ipp; struct tcp *t = (struct tcp *) (s_driver_data.buf + sizeof(e) + sizeof(ip)); struct connstate *s; - size_t i, first, off, len = 0, retired; + size_t i, first, off, retired; uint8_t *data; + uint32_t qlen = 0; struct mg_tcpip_driver driver; struct mg_tcpip_if mif; @@ -1075,12 +1076,12 @@ static void test_tcp_retransmit_queue(void) { while (s->seq - s->txq_una < s_rtx_len) { while (!received_response(&s_driver_data)) mg_mgr_poll(&mgr, 0); } - for (off = 0; off < s->txq.len; off += sizeof(uint32_t) + len) { - memcpy(&len, s->txq.buf + off, sizeof(uint32_t)); + for (off = 0; off < s->txq.len; off += sizeof(qlen) + qlen) { + memcpy(&qlen, s->txq.buf + off, sizeof(qlen)); } ASSERT(off == s->txq.len); - ASSERT(len == first); - ASSERT(memcmp(s->txq.buf + off - len, s_rtx_data + first, len) == 0); + ASSERT(qlen == first); + ASSERT(memcmp(s->txq.buf + off - qlen, s_rtx_data + first, qlen) == 0); // Draining waits for the rebuilt flight to be acknowledged before FIN mgr.conns->is_draining = 1;