[Top][All Lists]

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

Re: [lwip-users] Shadow declaration in tcp_in.c (LwIP 1.3.2)

From: David Empson
Subject: Re: [lwip-users] Shadow declaration in tcp_in.c (LwIP 1.3.2)
Date: Thu, 07 Jan 2010 16:05:15 +1300

"Mykola Kyrylenko" <address@hidden> wrote:
I have transferred my LwIP stack to 1.3.2.  All seems to be going well
(with minimal testing), except I am getting this compiler warning:

   Building ...........\tcp_in.c
   Running: GCC
N:\DEV\DSP\software\ControlSS (st2)\controller\eth\core\tcp_in.c: In function 'tcp_receive': N:\DEV\DSP\software\ControlSS (st2)\controller\eth\core\tcp_in.c:1182: warning: declaration of 'next' shadows a previous local N:\DEV\DSP\software\ControlSS (st2)\controller\eth\core\tcp_in.c:793: warning: shadowed declaration is here

As indicated, the variable 'next' declaration is defined twice in
function 'tcp_receive()'.
Is this going to be an issue?

From looking through the code, this is only a cosmetic issue. The 'next'
variable on line 793 is only used within several self-contained while loops and its usage doesn't overlap the nested block containing line 1182.

In addition, the declaration on line 1182 is for the same type, so the same variable can be re-used.

This patch will get rid of the warning. (I assume I've done this right - first time I've used diff. I created it with diff -u as that seems to match other examples I've seen here, except for the date format.)

--- tcp_in.c Thu Dec 24 15:38:20 2009
+++ tcp_in1.c Thu Jan 07 15:58:33 2010
@@ -1179,12 +1179,12 @@
          else {
-            struct tcp_seg* next = pcb->ooseq;
            struct tcp_seg *old_seg;
            /* rcv_nxt
             * .    |--ooseq--|
             * .==seg============|
+            next = pcb->ooseq;
            while (next &&
                   TCP_SEQ_GEQ(seqno + tcplen,
                               next->tcphdr->seqno + next->len)) {

reply via email to

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