diff --git a/libc/misc/lib_crc16.c b/libc/misc/lib_crc16.c index 76e8dac8a5..0240e41ab2 100644 --- a/libc/misc/lib_crc16.c +++ b/libc/misc/lib_crc16.c @@ -114,9 +114,9 @@ uint16_t crc16part(FAR const uint8_t *src, size_t len, uint16_t crc16val) { size_t i; - for (i = 0; i < len; i++) + for (i = 0; i < len; i++) { - crc16val = crc16_tab[((crc16val >> 8) & 255)] ^ (crc16val << 8) ^ src[i]; + crc16val = crc16_tab[((crc16val >> 8) & 0xff) ^ src[i]] ^ (crc16val << 8); } return crc16val; diff --git a/libc/misc/lib_crc32.c b/libc/misc/lib_crc32.c index 40e7c014a0..cd6ac0758a 100644 --- a/libc/misc/lib_crc32.c +++ b/libc/misc/lib_crc32.c @@ -102,9 +102,9 @@ uint32_t crc32part(FAR const uint8_t *src, size_t len, uint32_t crc32val) { size_t i; - for (i = 0; i < len; i++) + for (i = 0; i < len; i++) { - crc32val = crc32_tab[(crc32val ^ src[i]) & 0xff] ^ (crc32val >> 8); + crc32val = crc32_tab[(crc32val & 0xff) ^ src[i]] ^ (crc32val >> 8); } return crc32val; } diff --git a/libc/misc/lib_crc8.c b/libc/misc/lib_crc8.c index ae3e01d5d7..4da049c60a 100644 --- a/libc/misc/lib_crc8.c +++ b/libc/misc/lib_crc8.c @@ -124,13 +124,13 @@ uint8_t crc8part(FAR const uint8_t *src, size_t len, uint8_t crc8val) { size_t i; - crc8val ^= 0xFF; - for (i = 0; i < len; i++) + crc8val ^= 0xff; + for (i = 0; i < len; i++) { crc8val = crc8_tab[crc8val ^ src[i]]; } - return crc8val ^ 0xFF; + return crc8val ^ 0xff; } /************************************************************************************************