[Top][All Lists]

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

RE: [lwip-users] [PATCH] fix warning for gcc and possible unaligned acce

From: Curt McDowell
Subject: RE: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access
Date: Tue, 25 Apr 2006 12:33:18 -0700

Timmy Brolin wrote:
> There is a very good reason why ip_addr2 was introduced. 
> ip_addr2 is in fact a decent solution. It is generates close 
> optimal machine code, it is not compiler dependent, and it 
> makes the code nice and easy to read.
> I would suggest that it remains unless someone comes up with 
> a better solution which does not break compatibility with any 
> compilers.

I disagree that ip_addr2 is in any way elegant, self-explanatory, easy to read
(being defined elsewhere but not used elsewhere), or that it necessarily
compiles to two half-word transfers, or that performance is remotely critical
here.  Worse, it's not acceptable code in C99.  People are changing it to
trivial memcpy because:

etharp.c:493: warning: dereferencing type-punned pointer will break
strict-aliasing rules
*(struct ip_addr2 *)&sipaddr = hdr->sipaddr;

Curt McDowell
Broadcom Corp.

reply via email to

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