lkml.org 
[lkml]   [1999]   [Apr]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [OFFTOPIC?] Re: 2.2.x kernels missend odd-sized ICMP pa
From
Date
Horst von Brand <vonbrand@sleipnir.valparaiso.cl> writes:

|> (This is an excerpt from ping.c:in_cksum in netkit-0.10, sent to me by Petr
|> Vandrovec):
|>
|> register u_short *w = addr;
|> register int sum = 0;
|> u_short answer = 0;
|> ....
|> *(u_char*)(&answer) = *(u_char*)w;
|> sum += answer;
|>
|> This is a dumb way to write this.
|>
|> egcs-19990405 generates code that gets the right value, others (including
|> egcs-1.0.3 used to build RedHat-5.2, AFAIKS) break, as they don't respect
|> the initialization and put a random byte in the higher half.
|>
|> A better way to write the above is just:
|>
|> sum += *(u_char*)w;

This is not the same.

|> I can see no endianess issues here.

Think big (-endian).

--
Andreas Schwab "And now for something
schwab@issan.cs.uni-dortmund.de completely different"
schwab@gnu.org

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.041 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site