diff --git a/src/commonlib/bsd/include/commonlib/bsd/compiler.h b/src/commonlib/bsd/include/commonlib/bsd/compiler.h index 2d77c49ab5..79e0c812da 100644 --- a/src/commonlib/bsd/include/commonlib/bsd/compiler.h +++ b/src/commonlib/bsd/include/commonlib/bsd/compiler.h @@ -66,6 +66,13 @@ #define __printf(a, b) __attribute__((format(printf, a, b))) #endif +// This checks the support for the nonstring attribute on multidimensional character arrays. +#if (defined(__GNUC__) && __GNUC__ >= 15) || (defined(__clang__) && __clang_major__ >= 21) +#define __nonstring __attribute__((__nonstring__)) +#else +#define __nonstring +#endif + /* * This evaluates to the type of the first expression, unless that is constant * in which case it evaluates to the type of the second. This is useful when diff --git a/src/commonlib/include/commonlib/loglevel.h b/src/commonlib/include/commonlib/loglevel.h index 79fbcfc6d9..c4c1b4b011 100644 --- a/src/commonlib/include/commonlib/loglevel.h +++ b/src/commonlib/include/commonlib/loglevel.h @@ -165,7 +165,7 @@ */ #define BIOS_LOG_PREFIX_PATTERN "[%.5s] " #define BIOS_LOG_PREFIX_MAX_LEVEL BIOS_SPEW -static const char bios_log_prefix[BIOS_LOG_PREFIX_MAX_LEVEL + 1][5] = { +static const char __nonstring bios_log_prefix[BIOS_LOG_PREFIX_MAX_LEVEL + 1][5] = { /* Note: These strings are *not* null-terminated to save space. */ [BIOS_EMERG] = "EMERG", [BIOS_ALERT] = "ALERT", diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c index 7154bc9d54..d5eb87ca25 100644 --- a/util/cbfstool/common.c +++ b/util/cbfstool/common.c @@ -192,7 +192,7 @@ uint64_t intfiletype(const char *name) char *bintohex(uint8_t *data, size_t len) { - static const char translate[16] = "0123456789abcdef"; + static const char __nonstring translate[16] = "0123456789abcdef"; char *result = malloc(len * 2 + 1); if (result == NULL)