lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] Bug in Checksum implementation and ARP fix


From: Kenneth Porter
Subject: Re: [lwip-devel] Bug in Checksum implementation and ARP fix
Date: Mon, 20 Oct 2003 15:53:45 -0700

--On Thursday, September 25, 2003 12:02 PM +0100 Paul Riley <address@hidden> wrote:

There is a bug in the implementation of lwip_chksum. Basically it assumes
that you can perform 16 bit access on non 16 bit aligned address

The offending line is

    acc += *(u16_t *)dataptr;

As a general rule, I would favor removing all casts from the code. One of the nice features of C++ is "new style casts" which replaces a C-style cast with a number of different kinds of casts, such as static, dynamic, const, and reinterpret. These serve to make it more clear *why* the cast is being done, and make it easier to grep for different flavors of casts.

With that in mind, I'd propose that naked casts be replaced with macros named for the operation they're trying to achieve, similar in principle to the h2n macros/functions. This allows the cast macro to be tuned to different architectures in one place, or to be replaced with a function as needed.




reply via email to

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