lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Strange "always true" conditional in tcp_in.c


From: John Carter
Subject: [lwip-users] Strange "always true" conditional in tcp_in.c
Date: Mon, 01 Mar 2010 13:47:06 +1300 (NZDT)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

On line 883 of core/tcp_in.c is the somewhat strange construct...

883 :                    if (pcb->dupacks + 1 > pcb->dupacks)
884 :                   ++pcb->dupacks;

Where I believe pcb->dupacks is a u8_t.

http://cvs.savannah.gnu.org/viewvc/lwip/src/core/tcp_in.c?view=annotate&root=lwip#l883

If I understand the C standard correctly (and the warnings from
gcc-4.2.3) the expression is first converted to an int (1 is an int)
and then 1 is added to it. ie. The expression is _always_ true.


Perhaps what was meant was...
  if( (u8_t)(pcb->dupacks+1) > ....

Even that is dubious since 1 is an int

So either
  if( (u8_t)(pcb->dupacks+1u) > ....

or
  if( (pcb->dupacks+(u8_t)1 > ....


John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : address@hidden
New Zealand





reply via email to

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