tcp: remove extra seg == NULL checks

In tcp_output() there were a number of blocks of code performing
duplicate checks of 'if (seg == NULL)'.  This combines them together
to reduce duplicate checks

TCP_OUTPUT_DEBUG and TCP_CWND_DEBUG also don't need to be guarded
by #if/#endif since the LWIP_DEBUGF infrastructure already compiles them
out when LWIP_DEBUG is not defined
This commit is contained in:
Joel Cunningham 2017-08-03 10:37:16 -05:00
parent 5ea7f507c3
commit 6fa5d02435

View File

@ -1139,18 +1139,15 @@ tcp_output(struct tcp_pcb *pcb)
return tcp_send_empty_ack(pcb);
}
#if TCP_OUTPUT_DEBUG
if (seg == NULL) {
LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n",
(void*)pcb->unsent));
}
#endif /* TCP_OUTPUT_DEBUG */
#if TCP_CWND_DEBUG
if (seg == NULL) {
LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"TCPWNDSIZE_F
", cwnd %"TCPWNDSIZE_F", wnd %"U32_F
", seg == NULL, ack %"U32_F"\n",
pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack));
/* nothing to send: shortcut out of here */
goto output_done;
} else {
LWIP_DEBUGF(TCP_CWND_DEBUG,
("tcp_output: snd_wnd %"TCPWNDSIZE_F", cwnd %"TCPWNDSIZE_F", wnd %"U32_F
@ -1159,12 +1156,6 @@ tcp_output(struct tcp_pcb *pcb)
lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len,
lwip_ntohl(seg->tcphdr->seqno), pcb->lastack));
}
#endif /* TCP_CWND_DEBUG */
if (seg == NULL) {
/* nothing to send: shortcut out of here */
goto output_done;
}
/* useg should point to last segment on unacked queue */
useg = pcb->unacked;
@ -1194,8 +1185,7 @@ tcp_output(struct tcp_pcb *pcb)
* subsequent window update is reliably received. With the goal of being lightweight,
* we avoid splitting the unsent segment and treat the window as already zero.
*/
if (seg != NULL &&
lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd &&
if (lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd &&
wnd > 0 && wnd == pcb->snd_wnd && pcb->unacked == NULL) {
/* Start the persist timer */
if (pcb->persist_backoff == 0) {