ACPI: Fix building with GCC 15
PATCH 1/1 ACPI: Fix building with GCC 15
Building with GCC 15 results in the following build error:
...
CC drivers/acpi/tables.o
In file included from ./include/acpi/actbl.h:371,
from ./include/acpi/acpi.h:26,
from ./include/linux/acpi.h:26,
from drivers/acpi/tables.c:19:
./include/acpi/actbl1.h:30:33: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
30 | #define ACPI_SIG_BERT "BERT" /* Boot Error Record Table */
| ^~~~~~
drivers/acpi/tables.c:400:9: note: in expansion of macro ‘ACPI_SIG_BERT’
400 | ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT,
| ^~~~~~~~~~~~~
./include/acpi/actbl1.h:31:33: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
31 | #define ACPI_SIG_BGRT "BGRT" /* Boot Graphics Resource Table */
| ^~~~~~
drivers/acpi/tables.c:400:24: note: in expansion of macro ‘ACPI_SIG_BGRT’
400 | ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT,
| ^~~~~~~~~~~~~./include/acpi/actbl1.h:34:33: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
34 | #define ACPI_SIG_CPEP "CPEP" /* Corrected Platform Error Polling table */
...
This is due to GCC having enabled -Werror=unterminated-string-initialization[0] by default. To work around this build time error we're modifying the size of table_sigs from table_sigs[][ACPI_NAMESEG_SIZE] to table_sigs[][ACPI_NAMESEG_SIZE + 1]. This ensures space for NUL, thus satisfying GCC.
[0]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-unterminated-string-initialization
--- drivers/acpi/tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/tables.c +1 -1
@@ -396,7 +396,7 @@ static u8 __init acpi_table_checksum(u8 *buffer, u32 length) }/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */ -static const char table_sigs[][ACPI_NAMESEG_SIZE ]__initconst = { +static const char table_sigs[][ACPI_NAMESEG_SIZE +1 ]__initconst = {ACPI_SIG_BERT ,ACPI_SIG_BGRT ,ACPI_SIG_CPEP ,ACPI_SIG_ECDT ,ACPI_SIG_EINJ ,ACPI_SIG_ERST ,ACPI_SIG_HEST ,ACPI_SIG_MADT ,ACPI_SIG_MSCT ,ACPI_SIG_SBST ,ACPI_SIG_SLIT ,ACPI_SIG_SRAT ,
Signature · 1 line
2.48.1
Quoted 43 lines · Brahmajit Das
Building with GCC 15 results in the following build error:
...
CCdrivers/acpi/tables.o
In file included from./include/acpi/actbl.h:371,from ./include/acpi/acpi.h:26, from ./include/linux/acpi.h:26, from drivers/acpi/tables.c:19: ./include/acpi/actbl1.h:30:33: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization] 30 | #define ACPI_SIG_BERT "BERT" /* Boot Error Record Table */ | ^~~~~~ drivers/acpi/tables.c:400:9: note: in expansion of macro ‘ACPI_SIG_BERT’ 400 | ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, | ^~~~~~~~~~~~~ ./include/acpi/actbl1.h:31:33: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization] 31 | #define ACPI_SIG_BGRT "BGRT" /* Boot Graphics Resource Table */ | ^~~~~~ drivers/acpi/tables.c:400:24: note: in expansion of macro ‘ACPI_SIG_BGRT’ 400 | ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, | ^~~~~~~~~~~~~
./include/acpi/actbl1.h:34:33: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
34 | #defineACPI_SIG_CPEP"CPEP" /* Corrected Platform Error Polling table */
...This is due to GCC having enabled -Werror=unterminated-string-initialization[0] by default. To work around this build time error we're modifying the size of
table_sigsfrom table_sigs[][ACPI_NAMESEG_SIZE] to table_sigs[][ACPI_NAMESEG_SIZE + 1]. This ensures space for NUL, thus satisfying GCC.[0]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-unterminated-string-initialization
Signed-off-by Brahmajit Das <[email protected]>--- drivers/acpi/tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/tables.c +0
-0
drivers/acpi/tables.c static u8 __init acpi_table_checksum(u8 *buffer, u32 length) · line 402
Quoted 8 lines
drivers/acpi/tables.c +1
-1@@ -396,7 +396,7 @@ static u8 __init acpi_table_checksum(u8 *buffer, u32 length) }/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */ -static const char table_sigs[][ACPI_NAMESEG_SIZE ]__initconst = { +static const char table_sigs[][ACPI_NAMESEG_SIZE +1 ]__initconst = {ACPI_SIG_BERT ,ACPI_SIG_BGRT ,ACPI_SIG_CPEP ,ACPI_SIG_ECDT ,ACPI_SIG_EINJ ,ACPI_SIG_ERST ,ACPI_SIG_HEST ,ACPI_SIG_MADT ,ACPI_SIG_MSCT ,ACPI_SIG_SBST ,ACPI_SIG_SLIT ,ACPI_SIG_SRAT ,
Please add the __nonstring attribute instead.
Quoted 46 lines · On Thu, 13 Feb 2025 16:46:56 +0100 Ard Biesheuvel <[email protected]> wrote:
Quoted 45 lines · Brahmajit Das
Building with GCC 15 results in the following build error:
...
CCdrivers/acpi/tables.o
In file included from./include/acpi/actbl.h:371,from ./include/acpi/acpi.h:26, from ./include/linux/acpi.h:26, from drivers/acpi/tables.c:19: ./include/acpi/actbl1.h:30:33: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization] 30 | #define ACPI_SIG_BERT "BERT" /* Boot Error Record Table */ | ^~~~~~ drivers/acpi/tables.c:400:9: note: in expansion of macro ‘ACPI_SIG_BERT’ 400 | ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, | ^~~~~~~~~~~~~ ./include/acpi/actbl1.h:31:33: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization] 31 | #define ACPI_SIG_BGRT "BGRT" /* Boot Graphics Resource Table */ | ^~~~~~ drivers/acpi/tables.c:400:24: note: in expansion of macro ‘ACPI_SIG_BGRT’ 400 | ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, | ^~~~~~~~~~~~~
./include/acpi/actbl1.h:34:33: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
34 | #defineACPI_SIG_CPEP"CPEP" /* Corrected Platform Error Polling table */
...This is due to GCC having enabled -Werror=unterminated-string-initialization[0] by default. To work around this build time error we're modifying the size of
table_sigsfrom table_sigs[][ACPI_NAMESEG_SIZE] to table_sigs[][ACPI_NAMESEG_SIZE + 1]. This ensures space for NUL, thus satisfying GCC.[0]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-unterminated-string-initialization
Signed-off-by Brahmajit Das <[email protected]>--- drivers/acpi/tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/tables.c +0
-0@@ -396,7 +396,7 @@ static u8 __init acpi_table_checksum(u8 *buffer, u32 length) }
Quoted 8 lines
drivers/acpi/tables.c static u8 __init acpi_table_checksum(u8 *buffer, u32 length) · line 402
Quoted 6 lines
drivers/acpi/tables.c +1
-1/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */ -static const char table_sigs[][ACPI_NAMESEG_SIZE ]__initconst = { +static const char table_sigs[][ACPI_NAMESEG_SIZE +1 ]__initconst = {ACPI_SIG_BERT ,ACPI_SIG_BGRT ,ACPI_SIG_CPEP ,ACPI_SIG_ECDT ,ACPI_SIG_EINJ ,ACPI_SIG_ERST ,ACPI_SIG_HEST ,ACPI_SIG_MADT ,ACPI_SIG_MSCT ,ACPI_SIG_SBST ,ACPI_SIG_SLIT ,ACPI_SIG_SRAT ,Please add the
__nonstringattribute instead.
That doesn't fix initialisers.
There is a gcc bug about it (and a patch)...
David
GCC bug
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178,
and patch
https://gcc.gnu.org/pipermail/gcc-patches/2024-December/671714.html
Signature · 2 lines
Regards, listout