summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Tjernlund <Joakim.Tjernlund@transmode.se>2008-11-17 11:22:25 +0100
committerPaul Jakma <paul@quagga.net>2008-11-29 18:04:11 +0000
commit6e907dd4abdff9c52c809ea49c76d789b11c0e12 (patch)
treefc63d6c0699cc626a316ae3662f045f7de8e90fe
parent4768061ad5d7c762f2272436a89e62d4e41676a2 (diff)
[lib] Move type cast in Fletcher checksum
The int type cast should be on the whole expression passed to the mod operator. Otherwise it won't work when/if c0/c1 is unsigned. Making c0/c1 unsigned makes it possible to use 5802 as MODX value.
-rw-r--r--lib/checksum.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/checksum.c b/lib/checksum.c
index f6d74d31..3ddde815 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -91,7 +91,7 @@ fletcher_checksum(u_char * buffer, const size_t len, const uint16_t offset)
}
/* The cast is important, to ensure the mod is taken as a signed value. */
- x = ((int)(len - offset - 1) * c0 - c1) % 255;
+ x = (int)((len - offset - 1) * c0 - c1) % 255;
if (x <= 0)
x += 255;