Merge pull request #3688 from cesanta/nits

fix C89 and be tests
This commit is contained in:
Sergio R. Caprile authored and GitHub committed 2026-09-09 15:55:00 -03:00
commit c13d5d7a56
3 files changed
+8 -7

No files matched your search

+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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);
+6 -5
View File
@@ -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;