Re: [PATCH 1/1] ACPI: Fix building with GCC 15
From: David Laight
Date: Tue Apr 15 2025 - 14:05:13 EST
On Mon, 14 Apr 2025 21:46:42 +0530
Brahmajit Das <brahmajit.xyz@xxxxxxxxx> wrote:
> Since the Linux kernel initializes many non-C-string char arrays with
> literals. While it would be possible to convert initializers from:
> { "BOOP", ... }
> to something like:
> { { 'B', 'O', 'O', 'P' }, ... }
> that is annoying.
> Making -Wunterminated-string-initialization stay silent about char
> arrays marked with nonstring would be much better.
...
> diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
> index 6f4fe47c955b..d2cda1b35e59 100644
> --- a/drivers/acpi/acpica/aclocal.h
> +++ b/drivers/acpi/acpica/aclocal.h
> @@ -293,7 +293,7 @@ acpi_status (*acpi_internal_method) (struct acpi_walk_state * walk_state);
> * expected_return_btypes - Allowed type(s) for the return value
> */
> struct acpi_name_info {
> - char name[ACPI_NAMESEG_SIZE];
> + char name[ACPI_NAMESEG_SIZE] __attribute__((nonstring));
Doesn't than generate an 'unknown attribute' error on older compilers?
Does:
typedef char char_nonstring __attribute__((nonstring));
char_nonstring name[4] = "abcd";
work?
If so the attribute could even be applied to 'u8'.
David