lib/crc_byte: Parenthesize buffer address in CRC macro

This change fixes CRC calculations in cases where an expression
calculating the address using pointer arithmetic is passed into the
macro.

Change-Id: I55bbd2f208a94068ea3b3b3ae97b1683434c3007
Signed-off-by: Filip Brozovic <fbrozovic@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86099
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Filip Brozovic 2025-01-22 08:50:47 +01:00 committed by Matt DeVillier
commit ad3638e338

View file

@ -35,7 +35,7 @@ uint16_t crc16_byte(uint16_t prev_crc, uint8_t data);
uint32_t crc32_byte(uint32_t prev_crc, uint8_t data);
#define CRC(buf, size, crc_func) ({ \
const uint8_t *_crc_local_buf = (const uint8_t *)buf; \
const uint8_t *_crc_local_buf = (const uint8_t *)(buf); \
size_t _crc_local_size = size; \
__typeof__(crc_func(0, 0)) _crc_local_result = 0; \
while (_crc_local_size--) { \