[Top][All Lists]

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

RE: [lwip-devel] Possibly falsely triggered LWIP_ASSERT?

From: Kieran Mansley
Subject: RE: [lwip-devel] Possibly falsely triggered LWIP_ASSERT?
Date: Wed, 30 Sep 2009 09:17:52 +0100

On Tue, 2009-09-29 at 11:02 -0400, Bill Auerbach wrote:
> Because tot_len and grow (via casting) are u16_t, there is no problem here -
> no sign extension can occur.  If tot_len were larger, this would be a bug.
> In order to be "righter" this should be a cast to s_16t.  The compiler
> output will be unchanged by this change.

I think I follow - a small negative value will be changed to a large
positive value when doing the cast, which when added to tot_len in
unsigned arithmetic will wrap the value and you'll end up with something
that is slightly smaller than you started with - i.e. the correct
result.  I might change this line anyway just to make it clearer what
it's actually doing.


reply via email to

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