Skip to content

Commit 18eb45b

Browse files
keesrafaeljw
authored andcommitted
ACPI: tables: Add __nonstring annotations for unterminated strings
When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the 4-byte ACPI identifier arrays with __nonstring (and the new __nonstring_array) to correctly identify the char arrays as "not C strings" and thereby eliminate the many warnings like this: 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: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (5 chars into 4 available) [-Wunterminated-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, | ^~~~~~~~~~~~~ Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1] Signed-off-by: Kees Cook <kees@kernel.org> Link: https://patch.msgid.link/20250415232028.work.843-kees@kernel.org Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 9d7a057 commit 18eb45b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/acpi/tables.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static u8 __init acpi_table_checksum(u8 *buffer, u32 length)
396396
}
397397

398398
/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */
399-
static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = {
399+
static const char table_sigs[][ACPI_NAMESEG_SIZE] __nonstring_array __initconst = {
400400
ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT,
401401
ACPI_SIG_EINJ, ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT,
402402
ACPI_SIG_MSCT, ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT,

0 commit comments

Comments
 (0)