diff --git a/crc32.c b/crc32.c index e44ac87..68594f2 100644 --- a/crc32.c +++ b/crc32.c @@ -53,14 +53,14 @@ crc_le_fill_table(uint32_t *table, uint32_t polynomial) } static inline void -crc_be_cycle(uint32_t *table, uint32_t *remainder, char c) +crc_be_cycle(uint32_t *table, uint32_t *remainder, uint8_t c) { - const uint32_t byte = table[(((*remainder) >> 24) ^ c) & 0xFF]; - *remainder = (((*remainder) << 8) ^ byte) & 0xFFFFFFFF; + const uint32_t byte = table[(((*remainder) >> 24) ^ c)]; + *remainder = (((*remainder) << 8) ^ byte); } static inline void -crc_le_cycle(uint32_t *table, uint32_t *remainder, char c) +crc_le_cycle(uint32_t *table, uint32_t *remainder, uint8_t c) { const uint32_t byte = table[((*remainder) ^ c) & 0xFF]; *remainder = ((*remainder) >> 8) ^ byte; diff --git a/main.c b/main.c index 8c4905d..190f7eb 100644 --- a/main.c +++ b/main.c @@ -123,8 +123,8 @@ static uint32_t cycle_file(FILE *stream) { uint32_t remainder = starting; - void (*cycle)(uint32_t*, uint32_t*, char) = - (big_endian) ? crc_be_cycle : crc_le_cycle; + typeof(&crc_be_cycle) cycle; + cycle = (big_endian) ? crc_be_cycle : crc_le_cycle; uint32_t table[CRC_TABLE_SIZE]; if (big_endian)