From ad3638e3386cee8f554c2c5ce3a7ce6321b90e01 Mon Sep 17 00:00:00 2001 From: Filip Brozovic Date: Wed, 22 Jan 2025 08:50:47 +0100 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/86099 Reviewed-by: Matt DeVillier Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- src/include/crc_byte.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/crc_byte.h b/src/include/crc_byte.h index 85b7221053..972b89a606 100644 --- a/src/include/crc_byte.h +++ b/src/include/crc_byte.h @@ -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--) { \