mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
5ad1de3931
Building coreboot host tools with GCC 15 results in build errors:
In file included from .../lbmk/src/coreboot/default/util/cbfstool/console/console.h:7,
from .../lbmk/src/coreboot/default/src/commonlib/fsp_relocate.c:3:
.../lbmk/src/coreboot/default/src/commonlib/include/commonlib/loglevel.h:170:26: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (6 chars into 5 available) [-Werror=unterminated-string-initialization]
170 | [BIOS_EMERG] = "EMERG",
| ^~~~~~~
.../lbmk/src/coreboot/default/src/commonlib/include/commonlib/loglevel.h:171:26: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (6 chars into 5 available) [-Werror=unterminated-string-initialization]
171 | [BIOS_ALERT] = "ALERT",
| ^~~~~~~
[...]
../cbfstool/common.c: In function 'bintohex':
../cbfstool/common.c:195:43: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (17 chars into 16 available) [-Werror=unterminated-string-initialization]
195 | static const char translate[16] = "0123456789abcdef";
| ^~~~~~~~~~~~~~~~~~
Add a patch that marks the latter with the "nonstring" attribute, and
disable the warning for the former because I couldn't figure out how to
add that attribute there.
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
63 lines
2.5 KiB
Diff
63 lines
2.5 KiB
Diff
From 281151d85240bd8a60545b6415e0f44ce6a2af33 Mon Sep 17 00:00:00 2001
|
|
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
|
|
Date: Tue, 29 Apr 2025 17:31:13 +0300
|
|
Subject: [PATCH] WIP: Fix build with GCC 15 as host compiler
|
|
|
|
GCC 15 now considers the unterminated-string-initialization warning as
|
|
part of -Werror by default. Coreboot compiles host utilities with the
|
|
system compiler, which results in getting this error in some files.
|
|
|
|
Mark a hexadecimal translation table in cbfstool code as "nonstring" to
|
|
avoid the warning-turned-error.
|
|
|
|
The bios log prefixes are non-null-terminated as well, but I couldn't
|
|
figure out how to mark them as non-strings. Temporarily disable the
|
|
warning with a pragma to avoid the error. That pragma causes an error on
|
|
GCC 14, so disable pragma warnings along with it to avoid that as well.
|
|
|
|
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
|
|
---
|
|
src/commonlib/include/commonlib/loglevel.h | 4 ++++
|
|
util/cbfstool/common.c | 2 +-
|
|
2 files changed, 5 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/commonlib/include/commonlib/loglevel.h b/src/commonlib/include/commonlib/loglevel.h
|
|
index 79fbcfc6d92b..31438c945ff5 100644
|
|
--- a/src/commonlib/include/commonlib/loglevel.h
|
|
+++ b/src/commonlib/include/commonlib/loglevel.h
|
|
@@ -163,6 +163,9 @@
|
|
* When printing logs, lines should be printed with the following prefixes in
|
|
* front of them according to the BIOS_LOG_PREFIX_PATTERN printf() pattern.
|
|
*/
|
|
+#pragma GCC diagnostic push
|
|
+#pragma GCC diagnostic ignored "-Wpragmas"
|
|
+#pragma GCC diagnostic ignored "-Wunterminated-string-initialization"
|
|
#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] = {
|
|
@@ -177,6 +180,7 @@ static const char bios_log_prefix[BIOS_LOG_PREFIX_MAX_LEVEL + 1][5] = {
|
|
[BIOS_DEBUG] = "DEBUG",
|
|
[BIOS_SPEW] = "SPEW ",
|
|
};
|
|
+#pragma GCC diagnostic pop
|
|
|
|
/*
|
|
* When printing to terminals supporting ANSI escape sequences, the following
|
|
diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c
|
|
index 7154bc9d5425..cb08c9e8ec11 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 translate[16] __attribute__((__nonstring__)) = "0123456789abcdef";
|
|
|
|
char *result = malloc(len * 2 + 1);
|
|
if (result == NULL)
|
|
|
|
--
|
|
2.49.0
|
|
|