]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPICA: Introduce ACPI_NONSTRING
authorKees Cook <kees@kernel.org>
Fri, 25 Apr 2025 19:27:58 +0000 (21:27 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 12 May 2025 13:38:42 +0000 (15:38 +0200)
ACPICA commit 878823ca20f1987cba0c9d4c1056be0d117ea4fe

In order to distinguish character arrays from C Strings (i.e. strings with
a terminating NUL character), add support for the "nonstring" attribute
provided by GCC. (A better name might be "ACPI_NONCSTRING", but that's
the attribute name, so stick to the existing naming convention.)

GCC 15's -Wunterminated-string-initialization will warn about truncation
of the NUL byte for string initializers unless the destination is marked
with "nonstring". Prepare for applying this attribute to the project.

Link: https://github.com/acpica/acpica/commit/878823ca
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/1841930.VLH7GnMWUR@rjwysocki.net
Signed-off-by: Kees Cook <kees@kernel.org>
[ rjw: Pick up the tag from Kees ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
include/acpi/actypes.h
include/acpi/platform/acgcc.h

index 80767e8bf3ad43c0359bbc2a9f90d332cb85fde6..f7b3c4a4b7e7c3e36257eaedba64d2140775fbea 100644 (file)
@@ -1327,4 +1327,8 @@ typedef enum {
 #define ACPI_FLEX_ARRAY(TYPE, NAME)     TYPE NAME[0]
 #endif
 
+#ifndef ACPI_NONSTRING
+#define ACPI_NONSTRING         /* No terminating NUL character */
+#endif
+
 #endif                         /* __ACTYPES_H__ */
index 04b4bf62051707d2eeb2e626a7b11aed91944f9f..68e9379623e6dcc38ed0164105e7cd1cce5de254 100644 (file)
                 TYPE NAME[];                    \
         }
 
+/*
+ * Explicitly mark strings that lack a terminating NUL character so
+ * that ACPICA can be built with -Wunterminated-string-initialization.
+ */
+#if __has_attribute(__nonstring__)
+#define ACPI_NONSTRING __attribute__((__nonstring__))
+#endif
+
 #endif                         /* __ACGCC_H__ */