diff options
| author | Masaki Muranaka <[email protected]> | 2013-03-09 00:35:58 +0900 |
|---|---|---|
| committer | Masaki Muranaka <[email protected]> | 2013-03-09 00:35:58 +0900 |
| commit | 5bed51e584c6bebdf2dc66ba319234250c8e6018 (patch) | |
| tree | d82bad9cee1a6a7bdbe60a4bf28cdead590c6426 /src/crc.c | |
| parent | 8a7f5360cf58492467df6ec236355436bdc2a977 (diff) | |
| download | mruby-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.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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++) { |
