Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 256151
b: refs/heads/master
c: be0e1e7
h: refs/heads/master
i:
  256149: 31724d2
  256147: 08b94f7
  256143: 5156b8a
v: v3
  • Loading branch information
Ian Abbott authored and David S. Miller committed Jul 7, 2011
1 parent 6cd79a3 commit 9c3e4ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 97bc3633bec7ed0fdfbda6b9cf86c51e4f58f8e2
refs/heads/master: be0e1e788b0973147b6b83cc940676cc26009eb7
13 changes: 5 additions & 8 deletions trunk/lib/checksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static inline unsigned short from32to16(unsigned int x)

static unsigned int do_csum(const unsigned char *buff, int len)
{
int odd, count;
int odd;
unsigned int result = 0;

if (len <= 0)
Expand All @@ -64,25 +64,22 @@ static unsigned int do_csum(const unsigned char *buff, int len)
len--;
buff++;
}
count = len >> 1; /* nr of 16-bit words.. */
if (count) {
if (len >= 2) {
if (2 & (unsigned long) buff) {
result += *(unsigned short *) buff;
count--;
len -= 2;
buff += 2;
}
count >>= 1; /* nr of 32-bit words.. */
if (count) {
if (len >= 4) {
const unsigned char *end = buff + ((unsigned)len & ~3);
unsigned int carry = 0;
do {
unsigned int w = *(unsigned int *) buff;
count--;
buff += 4;
result += carry;
result += w;
carry = (w > result);
} while (count);
} while (buff < end);
result += carry;
result = (result & 0xffff) + (result >> 16);
}
Expand Down

0 comments on commit 9c3e4ad

Please sign in to comment.