lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [PATCH] tcp: fix unused variables when checksum offloading


From: Richard Cochran
Subject: [lwip-devel] [PATCH] tcp: fix unused variables when checksum offloading is configured.
Date: Thu, 25 Sep 2014 20:59:38 +0200

When offloading TCP checksum generation to hardware, one sets the macro
CHECKSUM_GEN_TCP to zero. As a side effect, a local variable becomes
orphaned in two functions in the TCP code. This in turn cause compiler
warnings about unused variables.

This patch fixes the issue by placing the appropriate ifdefs, and it
applies to the 1.4.1 branch.

Signed-off-by: Richard Cochran <address@hidden>
---
 src/core/tcp_out.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
index ee19fe0..0645142 100644
--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -842,7 +842,9 @@ err_t
 tcp_send_empty_ack(struct tcp_pcb *pcb)
 {
   struct pbuf *p;
+#if CHECKSUM_GEN_TCP || LWIP_TCP_TIMESTAMPS
   struct tcp_hdr *tcphdr;
+#endif
   u8_t optlen = 0;
 
 #if LWIP_TCP_TIMESTAMPS
@@ -856,7 +858,9 @@ tcp_send_empty_ack(struct tcp_pcb *pcb)
     LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: (ACK) could not allocate 
pbuf\n"));
     return ERR_BUF;
   }
+#if CHECKSUM_GEN_TCP || LWIP_TCP_TIMESTAMPS
   tcphdr = (struct tcp_hdr *)p->payload;
+#endif
   LWIP_DEBUGF(TCP_OUTPUT_DEBUG, 
               ("tcp_output: sending ACK for %"U32_F"\n", pcb->rcv_nxt));
   /* remove ACK flags from the PCB, as we send an empty ACK now */
@@ -1364,7 +1368,9 @@ void
 tcp_keepalive(struct tcp_pcb *pcb)
 {
   struct pbuf *p;
+#if CHECKSUM_GEN_TCP
   struct tcp_hdr *tcphdr;
+#endif
 
   LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: sending KEEPALIVE probe to 
%"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
                           ip4_addr1_16(&pcb->remote_ip), 
ip4_addr2_16(&pcb->remote_ip),
@@ -1379,9 +1385,8 @@ tcp_keepalive(struct tcp_pcb *pcb)
                 ("tcp_keepalive: could not allocate memory for pbuf\n"));
     return;
   }
-  tcphdr = (struct tcp_hdr *)p->payload;
-
 #if CHECKSUM_GEN_TCP
+  tcphdr = (struct tcp_hdr *)p->payload;
   tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip,
                                       IP_PROTO_TCP, p->tot_len);
 #endif
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]