crc: Use type cast in crc32_ieee_base to avoid undefined behavior

Change-Id: I8362831125927372c62ecb5eec2f5afe6f75ef24
Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
Roy Oursler 2018-12-13 13:33:23 -07:00
parent 636272cff6
commit 5c62f1e1ec

View File

@ -165,7 +165,7 @@ uint32_t crc32_ieee_base(uint32_t seed, uint8_t * buf, uint64_t len)
uint32_t poly = 0x04C11DB7; // IEEE standard uint32_t poly = 0x04C11DB7; // IEEE standard
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
rem = rem ^ (buf[i] << 24); rem = rem ^ ((uint64_t) buf[i] << 24);
for (j = 0; j < MAX_ITER; j++) { for (j = 0; j < MAX_ITER; j++) {
rem = rem << 1; rem = rem << 1;
rem = (rem & 0x100000000ULL) ? rem ^ poly : rem; rem = (rem & 0x100000000ULL) ? rem ^ poly : rem;