commonlib/endian: Silence GCC -Warray-bounds false positives

Recent GCC versions (>=12) warn about out-of-bounds accesses when
writing through *(volatile uint8_t *)dest in endian.h.
This is a false positive since these pointers intentionally alias
hardware/physical memory.

Change-Id: Ia47aa1214998dbc17bd4a58f7d996bcc6fff7b6a
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/89328
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
This commit is contained in:
Elyes Haouas 2025-09-24 16:57:57 +02:00
commit 668ea97075

View file

@ -7,6 +7,11 @@
#include <stdint.h>
#include <string.h>
/* GCC >= 12 triggers false positives (-Warray-bounds) on
* deliberate low-level memory accesses here. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
/* Endian agnostic functions working on single byte. */
static inline uint8_t read_ble8(const void *src)
@ -247,4 +252,4 @@ static inline void zero_n(void *dest, size_t n)
memset(dest, 0, n);
}
#endif
#endif /* _COMMONLIB_ENDIAN_H_ */