From 2144eea46f31c288fb0b978764e62f1e2ff19807 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 30 May 2026 02:12:47 +0300 Subject: [PATCH] fix compiler warnings: C23 label+declaration, uint16_t overflow check --- src/etcp.c | 4 ++-- src/lwip_tcp/lwip_tcp.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/etcp.c b/src/etcp.c index c68d08cc..4a3be3c3 100644 --- a/src/etcp.c +++ b/src/etcp.c @@ -71,8 +71,8 @@ static void feed_dgram_to_asm(struct ETCP_CONN* etcp, struct PKTNORM* pn, uint8_t* dgram, uint16_t dgram_len, uint8_t** asm_buf, uint16_t* asm_len, uint16_t* asm_cap, uint32_t* returned) { - uint16_t need = *asm_len + dgram_len; - if (need > ASM_BUF_MAX_SIZE) { + uint32_t need = (uint32_t)*asm_len + dgram_len; + if (need >= ASM_BUF_MAX_SIZE) { DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[%s] assembly buffer would exceed max size %d", etcp->log_name, ASM_BUF_MAX_SIZE); return; } diff --git a/src/lwip_tcp/lwip_tcp.c b/src/lwip_tcp/lwip_tcp.c index 4e75307f..6cf92dc3 100644 --- a/src/lwip_tcp/lwip_tcp.c +++ b/src/lwip_tcp/lwip_tcp.c @@ -543,6 +543,8 @@ static uint16_t tcp_new_port(struct tcp_pcb *pcb) { struct lwip_tcp_ctx *ctx = pcb->ctx; uint16_t n = 0; + struct tcp_pcb *lists[4]; + int i; ctx->port_seed++; if (ctx->port_seed < TCP_LOCAL_PORT_RANGE_START || ctx->port_seed >= TCP_LOCAL_PORT_RANGE_END) { @@ -550,8 +552,8 @@ static uint16_t tcp_new_port(struct tcp_pcb *pcb) } again: - struct tcp_pcb *lists[4] = { ctx->listen_pcbs, ctx->bound_pcbs, ctx->active_pcbs, ctx->tw_pcbs }; - int i; + lists[0] = ctx->listen_pcbs; lists[1] = ctx->bound_pcbs; + lists[2] = ctx->active_pcbs; lists[3] = ctx->tw_pcbs; for (i = 0; i < 4; i++) { struct tcp_pcb *cpcb; for (cpcb = lists[i]; cpcb != NULL; cpcb = cpcb->next) {