Browse Source

fix compiler warnings: C23 label+declaration, uint16_t overflow check

congestion
Evgeny 4 months ago
parent
commit
2144eea46f
  1. 4
      src/etcp.c
  2. 6
      src/lwip_tcp/lwip_tcp.c

4
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;
}

6
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) {

Loading…
Cancel
Save