summaryrefslogtreecommitdiff
path: root/payloads/libpayload/libc/ipchecksum.c
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2008-03-20 19:54:59 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2008-03-20 19:54:59 +0000
commit6a441bfb46337ed6b59abed56dad35d94802282c (patch)
tree44eb1d67fcbc450907472186bbc0036afe9e380c /payloads/libpayload/libc/ipchecksum.c
parent5f4c8abb6537fa7377969e837dab987abefcf922 (diff)
downloadcoreboot-6a441bfb46337ed6b59abed56dad35d94802282c.tar.xz
Cosmetics, coding style fixes (trivial).
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3180 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/libc/ipchecksum.c')
-rw-r--r--payloads/libpayload/libc/ipchecksum.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/payloads/libpayload/libc/ipchecksum.c b/payloads/libpayload/libc/ipchecksum.c
index caba6aaf34..4f712068e5 100644
--- a/payloads/libpayload/libc/ipchecksum.c
+++ b/payloads/libpayload/libc/ipchecksum.c
@@ -1,5 +1,7 @@
/*
- * This file is part of the libpayload project
+ * This file is part of the libpayload project.
+ *
+ * It has orginally been taken from the FreeBSD project.
*
* Copyright (c) 2001 Charles Mott <cm@linktel.net>
* All rights reserved.
@@ -30,20 +32,20 @@
unsigned short ipchksum(const unsigned short *ptr, unsigned long nbytes)
{
- int sum, oddbyte;
+ int sum, oddbyte;
- sum = 0;
- while (nbytes > 1) {
- sum += *ptr++;
- nbytes -= 2;
- }
- if (nbytes == 1) {
- oddbyte = 0;
- ((u8 *) &oddbyte)[0] = *(u8 *)ptr;
- ((u8 *) &oddbyte)[1] = 0;
- sum += oddbyte;
- }
- sum = (sum >> 16) + (sum & 0xffff);
- sum += (sum >> 16);
- return (~sum);
+ sum = 0;
+ while (nbytes > 1) {
+ sum += *ptr++;
+ nbytes -= 2;
+ }
+ if (nbytes == 1) {
+ oddbyte = 0;
+ ((u8 *) & oddbyte)[0] = *(u8 *) ptr;
+ ((u8 *) & oddbyte)[1] = 0;
+ sum += oddbyte;
+ }
+ sum = (sum >> 16) + (sum & 0xffff);
+ sum += (sum >> 16);
+ return (~sum);
}