diff options
author | Lee Leahy <leroy.p.leahy@intel.com> | 2017-03-08 17:37:06 -0800 |
---|---|---|
committer | Lee Leahy <leroy.p.leahy@intel.com> | 2017-03-09 17:29:33 +0100 |
commit | 2f919ec4765e4484d79b866332fa19ec338db5c0 (patch) | |
tree | 1ddb3a7eba06bdd40657c5f63bc8dce322c530a6 /src/lib/compute_ip_checksum.c | |
parent | b2d834a93afe129851f9aa7400f3fb2f42be20a4 (diff) | |
download | coreboot-2f919ec4765e4484d79b866332fa19ec338db5c0.tar.xz |
src/lib: Remove braces for single statements
Fix the following warning detected by checkpatch.pl:
WARNING: braces {} are not necessary for single statement blocks
TEST=Build and run on Galileo Gen2
Change-Id: Ie4b41f6fb75142ddd75103a55e0347ed85e7e873
Signed-off-by: Lee Leahy <Leroy.P.Leahy@intel.com>
Reviewed-on: https://review.coreboot.org/18697
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/lib/compute_ip_checksum.c')
-rw-r--r-- | src/lib/compute_ip_checksum.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/lib/compute_ip_checksum.c b/src/lib/compute_ip_checksum.c index 347b83f220..9bd3e0a2cb 100644 --- a/src/lib/compute_ip_checksum.c +++ b/src/lib/compute_ip_checksum.c @@ -18,15 +18,13 @@ unsigned long compute_ip_checksum(const void *addr, unsigned long length) for(i = 0; i < length; i++) { unsigned long v; v = ptr[i]; - if (i & 1) { + if (i & 1) v <<= 8; - } /* Add the new value */ sum += v; /* Wrap around the carry */ - if (sum > 0xFFFF) { + if (sum > 0xFFFF) sum = (sum + (sum >> 16)) & 0xFFFF; - } } value.byte[0] = sum & 0xff; value.byte[1] = (sum >> 8) & 0xff; @@ -46,8 +44,7 @@ unsigned long add_ip_checksums(unsigned long offset, unsigned long sum, unsigned new = ((new >> 8) & 0xff) | ((new << 8) & 0xff00); } checksum = sum + new; - if (checksum > 0xFFFF) { + if (checksum > 0xFFFF) checksum -= 0xFFFF; - } return (~checksum) & 0xFFFF; } |