Make last commit bde-compliant:
- correct indentation - change data types for consistency with the rest of ping.c - create new variable separate from "answer" for clarity
This commit is contained in:
parent
4add59312e
commit
09333e7833
@ -930,9 +930,10 @@ in_cksum(addr, len)
|
||||
register u_short *w = addr;
|
||||
register int sum = 0;
|
||||
union {
|
||||
u_int16_t us;
|
||||
u_int8_t uc[2];
|
||||
} answer;
|
||||
u_short us;
|
||||
u_char uc[2];
|
||||
} last;
|
||||
u_short answer;
|
||||
|
||||
/*
|
||||
* Our algorithm is simple, using a 32 bit accumulator (sum), we add
|
||||
@ -946,16 +947,16 @@ in_cksum(addr, len)
|
||||
|
||||
/* mop up an odd byte, if necessary */
|
||||
if (nleft == 1) {
|
||||
answer.uc[0] = *(u_char *)w;
|
||||
answer.uc[1] = 0;
|
||||
sum += answer.us;
|
||||
last.uc[0] = *(u_char *)w;
|
||||
last.uc[1] = 0;
|
||||
sum += last.us;
|
||||
}
|
||||
|
||||
/* add back carry outs from top 16 bits to low 16 bits */
|
||||
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
|
||||
sum += (sum >> 16); /* add carry */
|
||||
answer.us = ~sum; /* truncate to 16 bits */
|
||||
return(answer.us);
|
||||
answer = ~sum; /* truncate to 16 bits */
|
||||
return(answer);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user