summaryrefslogtreecommitdiffhomepage
path: root/src/crc.c
diff options
context:
space:
mode:
authorMasaki Muranaka <[email protected]>2013-03-09 00:35:58 +0900
committerMasaki Muranaka <[email protected]>2013-03-09 00:35:58 +0900
commit5bed51e584c6bebdf2dc66ba319234250c8e6018 (patch)
treed82bad9cee1a6a7bdbe60a4bf28cdead590c6426 /src/crc.c
parent8a7f5360cf58492467df6ec236355436bdc2a977 (diff)
downloadmruby-5bed51e584c6bebdf2dc66ba319234250c8e6018.tar.gz
mruby-5bed51e584c6bebdf2dc66ba319234250c8e6018.zip
Don't use int. It decreases portability. Use size_t as array index and length. It avoids overflow in the extreme situations.
Diffstat (limited to 'src/crc.c')
-rw-r--r--src/crc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/crc.c b/src/crc.c
index 70fa60dfb..db852f6cb 100644
--- a/src/crc.c
+++ b/src/crc.c
@@ -18,9 +18,10 @@
#define CRC_CARRY_BIT (1 << 24)
uint16_t
-calc_crc_16_ccitt(const uint8_t *src, uint32_t nbytes, uint16_t crc)
+calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc)
{
- uint32_t ibyte, ibit;
+ size_t ibyte;
+ uint32_t ibit;
uint32_t crcwk = crc << 8;
for (ibyte = 0; ibyte < nbytes; ibyte++) {