From f971fb921ea5034845329aa338642023ab8a6e29 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 19 Nov 2015 20:59:54 +0800 Subject: [PATCH] Simplify testing minimum priority in tcp_kill_prio() Simplify the code a bit by setting mprio = LWIP_MIN(TCP_PRIO_MAX, prio) before the for loop. Signed-off-by: Axel Lin --- src/core/tcp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/tcp.c b/src/core/tcp.c index 131392c2..02587c62 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -1331,14 +1331,13 @@ tcp_kill_prio(u8_t prio) u32_t inactivity; u8_t mprio; - mprio = TCP_PRIO_MAX; + mprio = LWIP_MIN(TCP_PRIO_MAX, prio); /* We kill the oldest active connection that has lower priority than prio. */ inactivity = 0; inactive = NULL; for (pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { - if (pcb->prio <= prio && - pcb->prio <= mprio && + if (pcb->prio <= mprio && (u32_t)(tcp_ticks - pcb->tmr) >= inactivity) { inactivity = tcp_ticks - pcb->tmr; inactive = pcb;