From 697448e51ce15aea6ba96de039d5c4d37abd2b25 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 11 Apr 2022 10:05:45 +0200 Subject: [PATCH] drivers/periph_cpuid: Minor cleanup Avoid use of `memcpy` altogether to work around false positive of `-Warray-bounds` in newer GCC versions. --- drivers/periph_common/cpuid.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/periph_common/cpuid.c b/drivers/periph_common/cpuid.c index e2ef3d05ff..6250b7376a 100644 --- a/drivers/periph_common/cpuid.c +++ b/drivers/periph_common/cpuid.c @@ -28,15 +28,15 @@ #include "periph/cpuid.h" +typedef struct { + uint8_t id[CPUID_LEN]; +} cpuid_t; + #ifdef CPUID_ADDR void cpuid_get(void *id) { -/* gcc 11.2.0 builtin bounds checking raises the following false positive warnings */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpragmas" /* silence the CI due to unknown -Wstringop-overread */ -#pragma GCC diagnostic ignored "-Warray-bounds" -#pragma GCC diagnostic ignored "-Wstringop-overread" - memcpy(id, (void *)CPUID_ADDR, CPUID_LEN); -#pragma GCC diagnostic pop + cpuid_t *dest = id; + const volatile cpuid_t *src = (const void *)CPUID_ADDR; + *dest = *src; } #endif