[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Small patch for libicmp/icmp_cksum.c
From: |
michael |
Subject: |
Small patch for libicmp/icmp_cksum.c |
Date: |
4 Dec 2002 13:33:52 -0000 |
Hello,
I just noticed that the answer variable is not really needed. How
about this patch?
Michael
----------------------------------------------------------------------
--- icmp_cksum.c.orig 2002-12-04 14:29:52.000000000 +0100
+++ icmp_cksum.c 2002-12-04 14:31:02.000000000 +0100
@@ -28,7 +28,6 @@
icmp_cksum (u_char *addr, int len)
{
register int sum = 0;
- u_short answer = 0;
u_short *wp;
for (wp = (u_short*)addr; len > 1; wp++, len -= 2)
@@ -36,13 +35,9 @@
/* Take in an odd byte if present */
if (len == 1)
- {
- *(u_char *)&answer = *(u_char*)wp;
- sum += answer;
- }
+ sum += (unsigned short)*(u_char *)w;
sum = (sum >> 16) + (sum & 0xffff); /* add high 16 to low 16 */
sum += (sum >> 16); /* add carry */
- answer = ~sum; /* truncate to 16 bits */
- return answer;
+ return((unsigned short)~sum); /* truncate to 16 bits */
}
- Small patch for libicmp/icmp_cksum.c,
michael <=