bug-inetutils
[Top][All Lists]
Advanced

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

Re: Small patch for libicmp/icmp_cksum.c


From: michael
Subject: Re: Small patch for libicmp/icmp_cksum.c
Date: 4 Dec 2002 21:48:42 -0000

> > Could you point out what exactly I broke?
> [detailed explaination]

*blush* Thanks a lot, of course my code is wrong and only worked, because
PCs are little endian.  I thought a lot about why it works on big endian
machines at all and found that it works entirely different on big
endian machines up to the point where the upper bits are added, thus
propagating the carry bits back.  Amazing.  Sorry for sending a bogus
patch.

> I'm not familiar with the BSD code.  I can say that your patch
> definitely introduces behavior different from that of the current GNU
> code.

The BSD code uses the variable w, not wp.  You are right in that it uses
u_short, too.

> The one at the end is indeed unnecessary; a cast will have the same
> effect as the assignment in that case.  (And the cast is also
> unnecessary, since it is implicit because of the function's return
> type.)  But it may still be worth keeping for the sake of readability;
> that's up to the inetutils maintainers.

The cast is needed, because the function should return a signed result
between 0 and 0xffff, but the complement is most likely negative.

Michael




reply via email to

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