diff mbox series

[1/1] ACPI: Fix building with GCC 15

Message ID 20250121214219.1455896-1-brahmajit.xyz@gmail.com (mailing list archive)
State New
Headers show
Series [1/1] ACPI: Fix building with GCC 15 | expand

Commit Message

Brahmajit Das Jan. 21, 2025, 9:42 p.m. UTC
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

Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
---
 drivers/acpi/tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 9e1b01c35070..5a6524eb79d8 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -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,