lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] [bug #27445] PCB hangs in Fast Retransmit due to unchan


From: Alain Mouette
Subject: Re: [lwip-devel] [bug #27445] PCB hangs in Fast Retransmit due to unchanging cwnd
Date: Fri, 23 Oct 2009 16:57:31 -0200
User-agent: Thunderbird 2.0.0.17 (X11/20080914)


Bill Auerbach escreveu:
Follow-up Comment #4, bug #27445 (project lwip):

if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { ... }

From a coding standpoint, the 2 variables are u16_t and the cast has no
effect. From a runtime standpoint, is the cast always correct?
If the addition could overflow, the test fails.  You should then cast to
u32_t.  But I don't think those values can ever cause an overflow.

Maybe I'm picky - when I see a cast I think "we're changing what the compiler
will normally do".  In this case we're not and at worse, could fail on an
overflow.

I allways cast to signed:
 if (( (int16_t)((pcb->cwnd + pcb->mss) - pcb->cwnd) ) >0) { ... }
allways with lots of parentesis just to make sure that no optimyser gets in the way

This should allways work without using 32bits un-nessessarily

Alain




reply via email to

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