* [PATCH 1/1] ACPI: Fix building with GCC 15
@ 2025-01-21 21:42 Brahmajit Das
2025-02-13 15:46 ` Ard Biesheuvel
0 siblings, 1 reply; 9+ messages in thread
From: Brahmajit Das @ 2025-01-21 21:42 UTC (permalink / raw)
To: ardb, rafael.j.wysocki, lenb; +Cc: linux-acpi, linux-kernel
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 --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,
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/1] ACPI: Fix building with GCC 15
2025-01-21 21:42 [PATCH 1/1] ACPI: Fix building with GCC 15 Brahmajit Das
@ 2025-02-13 15:46 ` Ard Biesheuvel
2025-02-13 20:06 ` David Laight
0 siblings, 1 reply; 9+ messages in thread
From: Ard Biesheuvel @ 2025-02-13 15:46 UTC (permalink / raw)
To: Brahmajit Das; +Cc: rafael.j.wysocki, lenb, linux-acpi, linux-kernel
On Tue, 21 Jan 2025 at 22:42, Brahmajit Das <brahmajit.xyz@gmail.com> wrote:
>
> 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 --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,
Please add the __nonstring attribute instead.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/1] ACPI: Fix building with GCC 15
2025-02-13 15:46 ` Ard Biesheuvel
@ 2025-02-13 20:06 ` David Laight
2025-02-14 19:27 ` Brahmajit
0 siblings, 1 reply; 9+ messages in thread
From: David Laight @ 2025-02-13 20:06 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Brahmajit Das, rafael.j.wysocki, lenb, linux-acpi, linux-kernel
On Thu, 13 Feb 2025 16:46:56 +0100
Ard Biesheuvel <ardb@kernel.org> wrote:
> On Tue, 21 Jan 2025 at 22:42, Brahmajit Das <brahmajit.xyz@gmail.com> wrote:
> >
> > 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 --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,
>
> Please add the __nonstring attribute instead.
That doesn't fix initialisers.
There is a gcc bug about it (and a patch)...
David
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/1] ACPI: Fix building with GCC 15
2025-02-13 20:06 ` David Laight
@ 2025-02-14 19:27 ` Brahmajit
0 siblings, 0 replies; 9+ messages in thread
From: Brahmajit @ 2025-02-14 19:27 UTC (permalink / raw)
To: David Laight
Cc: Ard Biesheuvel, rafael.j.wysocki, lenb, linux-acpi, linux-kernel
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
--
Regards,
listout
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1] ACPI: Fix building with GCC 15
@ 2025-04-14 16:16 Brahmajit Das
2025-04-14 16:24 ` Brahmajit
2025-04-15 18:04 ` David Laight
0 siblings, 2 replies; 9+ messages in thread
From: Brahmajit Das @ 2025-04-14 16:16 UTC (permalink / raw)
Cc: Robert Moore, Rafael J. Wysocki, Len Brown, linux-acpi,
acpica-devel, linux-kernel
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.
Without the __attribute__((nonstring)) we would get the following build
error:
...
drivers/acpi/acpica/acpredef.h:903:11: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
903 | {{"_S3D", METHOD_0ARGS,
| ^~~~~~
drivers/acpi/acpica/acpredef.h:906:11: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
906 | {{"_S4D", METHOD_0ARGS,
| ^~~~~~
and,
...
drivers/acpi/acpica/nsrepair2.c:115:10: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
115 | {"_ALR", acpi_ns_repair_ALR},
| ^~~~~~
drivers/acpi/acpica/nsrepair2.c:116:10: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
116 | {"_CID", acpi_ns_repair_CID},
...
Upstream GCC has added this commit
622968990beee7499e951590258363545b4a3b57[0][1] which silences warning
about truncating NUL char when initializing nonstring arrays.
[0]: https://gcc.gnu.org/cgit/gcc/commit/?id=622968990beee7499e951590258363545b4a3b57
[1]: https://gcc.gnu.org/cgit/gcc/commit/?id=afb46540d3921e96c4cd7ba8fa2c8b0901759455
Thanks to Jakub Jelinek <jakub@gcc.gnu.org> for the gcc patch.
Signed-off-by: Brahmajit Das <listout@listout.xyz>
---
drivers/acpi/acpica/aclocal.h | 4 ++--
drivers/acpi/acpica/nsrepair2.c | 2 +-
drivers/acpi/tables.c | 28 +++++++++++++++-------------
include/acpi/actbl.h | 3 ++-
4 files changed, 20 insertions(+), 17 deletions(-)
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));
u16 argument_list;
u8 expected_btypes;
};
@@ -370,7 +370,7 @@ typedef acpi_status (*acpi_object_converter) (struct acpi_namespace_node *
converted_object);
struct acpi_simple_repair_info {
- char name[ACPI_NAMESEG_SIZE];
+ char name[ACPI_NAMESEG_SIZE] __attribute__((nonstring));
u32 unexpected_btypes;
u32 package_index;
acpi_object_converter object_converter;
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index 1bb7b71f07f1..a28b1fa2b1ea 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -25,7 +25,7 @@ acpi_status (*acpi_repair_function) (struct acpi_evaluate_info * info,
return_object_ptr);
typedef struct acpi_repair_info {
- char name[ACPI_NAMESEG_SIZE];
+ char name[ACPI_NAMESEG_SIZE] __attribute__((nonstring));
acpi_repair_function repair_function;
} acpi_repair_info;
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 2295abbecd14..27104cbb48b5 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -396,19 +396,21 @@ 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 = {
- 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,
- ACPI_SIG_ASF, ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR,
- ACPI_SIG_HPET, ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG,
- ACPI_SIG_MCHI, ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI,
- ACPI_SIG_TCPA, ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT,
- ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
- ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
- ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
- ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI,
- ACPI_SIG_NBFT };
+static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst
+ __attribute__((nonstring)) = {
+ 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,
+ ACPI_SIG_ASF, ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR,
+ ACPI_SIG_HPET, ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG,
+ ACPI_SIG_MCHI, ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI,
+ ACPI_SIG_TCPA, ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT,
+ ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
+ ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
+ ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
+ ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI,
+ ACPI_SIG_NBFT
+ };
#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 451f6276da49..88ba1b978053 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -66,7 +66,8 @@
******************************************************************************/
struct acpi_table_header {
- char signature[ACPI_NAMESEG_SIZE]; /* ASCII table signature */
+ char signature[ACPI_NAMESEG_SIZE]
+ __attribute__((nonstring)); /* ASCII table signature */
u32 length; /* Length of table in bytes, including this header */
u8 revision; /* ACPI Specification minor version number */
u8 checksum; /* To make sum of entire table == 0 */
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/1] ACPI: Fix building with GCC 15
2025-04-14 16:16 Brahmajit Das
@ 2025-04-14 16:24 ` Brahmajit
2025-04-14 16:39 ` Rafael J. Wysocki
2025-04-15 18:04 ` David Laight
1 sibling, 1 reply; 9+ messages in thread
From: Brahmajit @ 2025-04-14 16:24 UTC (permalink / raw)
To: Robert Moore, Rafael J. Wysocki, Len Brown, linux-acpi,
acpica-devel, linux-kernel
On 14.04.2025 21:46, Brahmajit Das 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.
>
> Without the __attribute__((nonstring)) we would get the following build
> error:
>
> ...
> drivers/acpi/acpica/acpredef.h:903:11: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
> 903 | {{"_S3D", METHOD_0ARGS,
> | ^~~~~~
> drivers/acpi/acpica/acpredef.h:906:11: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
> 906 | {{"_S4D", METHOD_0ARGS,
> | ^~~~~~
>
> and,
>
> ...
> drivers/acpi/acpica/nsrepair2.c:115:10: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
> 115 | {"_ALR", acpi_ns_repair_ALR},
> | ^~~~~~
> drivers/acpi/acpica/nsrepair2.c:116:10: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
> 116 | {"_CID", acpi_ns_repair_CID},
> ...
>
> Upstream GCC has added this commit
> 622968990beee7499e951590258363545b4a3b57[0][1] which silences warning
> about truncating NUL char when initializing nonstring arrays.
>
> [0]: https://gcc.gnu.org/cgit/gcc/commit/?id=622968990beee7499e951590258363545b4a3b57
> [1]: https://gcc.gnu.org/cgit/gcc/commit/?id=afb46540d3921e96c4cd7ba8fa2c8b0901759455
>
> Thanks to Jakub Jelinek <jakub@gcc.gnu.org> for the gcc patch.
>
> Signed-off-by: Brahmajit Das <listout@listout.xyz>
> ---
> drivers/acpi/acpica/aclocal.h | 4 ++--
> drivers/acpi/acpica/nsrepair2.c | 2 +-
> drivers/acpi/tables.c | 28 +++++++++++++++-------------
> include/acpi/actbl.h | 3 ++-
> 4 files changed, 20 insertions(+), 17 deletions(-)
>
> 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));
> u16 argument_list;
> u8 expected_btypes;
> };
> @@ -370,7 +370,7 @@ typedef acpi_status (*acpi_object_converter) (struct acpi_namespace_node *
> converted_object);
>
> struct acpi_simple_repair_info {
> - char name[ACPI_NAMESEG_SIZE];
> + char name[ACPI_NAMESEG_SIZE] __attribute__((nonstring));
> u32 unexpected_btypes;
> u32 package_index;
> acpi_object_converter object_converter;
> diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
> index 1bb7b71f07f1..a28b1fa2b1ea 100644
> --- a/drivers/acpi/acpica/nsrepair2.c
> +++ b/drivers/acpi/acpica/nsrepair2.c
> @@ -25,7 +25,7 @@ acpi_status (*acpi_repair_function) (struct acpi_evaluate_info * info,
> return_object_ptr);
>
> typedef struct acpi_repair_info {
> - char name[ACPI_NAMESEG_SIZE];
> + char name[ACPI_NAMESEG_SIZE] __attribute__((nonstring));
> acpi_repair_function repair_function;
>
> } acpi_repair_info;
> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> index 2295abbecd14..27104cbb48b5 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -396,19 +396,21 @@ 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 = {
> - 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,
> - ACPI_SIG_ASF, ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR,
> - ACPI_SIG_HPET, ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG,
> - ACPI_SIG_MCHI, ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI,
> - ACPI_SIG_TCPA, ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT,
> - ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
> - ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
> - ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
> - ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI,
> - ACPI_SIG_NBFT };
> +static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst
> + __attribute__((nonstring)) = {
> + 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,
> + ACPI_SIG_ASF, ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR,
> + ACPI_SIG_HPET, ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG,
> + ACPI_SIG_MCHI, ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI,
> + ACPI_SIG_TCPA, ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT,
> + ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
> + ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
> + ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
> + ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI,
> + ACPI_SIG_NBFT
> + };
>
> #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
>
> diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
> index 451f6276da49..88ba1b978053 100644
> --- a/include/acpi/actbl.h
> +++ b/include/acpi/actbl.h
> @@ -66,7 +66,8 @@
> ******************************************************************************/
>
> struct acpi_table_header {
> - char signature[ACPI_NAMESEG_SIZE]; /* ASCII table signature */
> + char signature[ACPI_NAMESEG_SIZE]
> + __attribute__((nonstring)); /* ASCII table signature */
> u32 length; /* Length of table in bytes, including this header */
> u8 revision; /* ACPI Specification minor version number */
> u8 checksum; /* To make sum of entire table == 0 */
> --
> 2.49.0
>
Do I need to send the acpica part to GitHub first?
--
Regards,
listout
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/1] ACPI: Fix building with GCC 15
2025-04-14 16:24 ` Brahmajit
@ 2025-04-14 16:39 ` Rafael J. Wysocki
0 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2025-04-14 16:39 UTC (permalink / raw)
To: Brahmajit
Cc: Robert Moore, Rafael J. Wysocki, Len Brown, linux-acpi,
acpica-devel, linux-kernel
On Mon, Apr 14, 2025 at 6:25 PM Brahmajit <brahmajit.xyz@gmail.com> wrote:
>
> On 14.04.2025 21:46, Brahmajit Das 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.
> >
> > Without the __attribute__((nonstring)) we would get the following build
> > error:
> >
> > ...
> > drivers/acpi/acpica/acpredef.h:903:11: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
> > 903 | {{"_S3D", METHOD_0ARGS,
> > | ^~~~~~
> > drivers/acpi/acpica/acpredef.h:906:11: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
> > 906 | {{"_S4D", METHOD_0ARGS,
> > | ^~~~~~
> >
> > and,
> >
> > ...
> > drivers/acpi/acpica/nsrepair2.c:115:10: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
> > 115 | {"_ALR", acpi_ns_repair_ALR},
> > | ^~~~~~
> > drivers/acpi/acpica/nsrepair2.c:116:10: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
> > 116 | {"_CID", acpi_ns_repair_CID},
> > ...
> >
> > Upstream GCC has added this commit
> > 622968990beee7499e951590258363545b4a3b57[0][1] which silences warning
> > about truncating NUL char when initializing nonstring arrays.
> >
> > [0]: https://gcc.gnu.org/cgit/gcc/commit/?id=622968990beee7499e951590258363545b4a3b57
> > [1]: https://gcc.gnu.org/cgit/gcc/commit/?id=afb46540d3921e96c4cd7ba8fa2c8b0901759455
> >
> > Thanks to Jakub Jelinek <jakub@gcc.gnu.org> for the gcc patch.
> >
> > Signed-off-by: Brahmajit Das <listout@listout.xyz>
> > ---
> > drivers/acpi/acpica/aclocal.h | 4 ++--
> > drivers/acpi/acpica/nsrepair2.c | 2 +-
> > drivers/acpi/tables.c | 28 +++++++++++++++-------------
> > include/acpi/actbl.h | 3 ++-
> > 4 files changed, 20 insertions(+), 17 deletions(-)
> >
> > 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));
> > u16 argument_list;
> > u8 expected_btypes;
> > };
> > @@ -370,7 +370,7 @@ typedef acpi_status (*acpi_object_converter) (struct acpi_namespace_node *
> > converted_object);
> >
> > struct acpi_simple_repair_info {
> > - char name[ACPI_NAMESEG_SIZE];
> > + char name[ACPI_NAMESEG_SIZE] __attribute__((nonstring));
> > u32 unexpected_btypes;
> > u32 package_index;
> > acpi_object_converter object_converter;
> > diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
> > index 1bb7b71f07f1..a28b1fa2b1ea 100644
> > --- a/drivers/acpi/acpica/nsrepair2.c
> > +++ b/drivers/acpi/acpica/nsrepair2.c
> > @@ -25,7 +25,7 @@ acpi_status (*acpi_repair_function) (struct acpi_evaluate_info * info,
> > return_object_ptr);
> >
> > typedef struct acpi_repair_info {
> > - char name[ACPI_NAMESEG_SIZE];
> > + char name[ACPI_NAMESEG_SIZE] __attribute__((nonstring));
> > acpi_repair_function repair_function;
> >
> > } acpi_repair_info;
> > diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> > index 2295abbecd14..27104cbb48b5 100644
> > --- a/drivers/acpi/tables.c
> > +++ b/drivers/acpi/tables.c
> > @@ -396,19 +396,21 @@ 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 = {
> > - 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,
> > - ACPI_SIG_ASF, ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR,
> > - ACPI_SIG_HPET, ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG,
> > - ACPI_SIG_MCHI, ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI,
> > - ACPI_SIG_TCPA, ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT,
> > - ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
> > - ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
> > - ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
> > - ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI,
> > - ACPI_SIG_NBFT };
> > +static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst
> > + __attribute__((nonstring)) = {
> > + 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,
> > + ACPI_SIG_ASF, ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR,
> > + ACPI_SIG_HPET, ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG,
> > + ACPI_SIG_MCHI, ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI,
> > + ACPI_SIG_TCPA, ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT,
> > + ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
> > + ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
> > + ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
> > + ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI,
> > + ACPI_SIG_NBFT
> > + };
> >
> > #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
> >
> > diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
> > index 451f6276da49..88ba1b978053 100644
> > --- a/include/acpi/actbl.h
> > +++ b/include/acpi/actbl.h
> > @@ -66,7 +66,8 @@
> > ******************************************************************************/
> >
> > struct acpi_table_header {
> > - char signature[ACPI_NAMESEG_SIZE]; /* ASCII table signature */
> > + char signature[ACPI_NAMESEG_SIZE]
> > + __attribute__((nonstring)); /* ASCII table signature */
> > u32 length; /* Length of table in bytes, including this header */
> > u8 revision; /* ACPI Specification minor version number */
> > u8 checksum; /* To make sum of entire table == 0 */
> > --
> > 2.49.0
> >
>
> Do I need to send the acpica part to GitHub first?
No, this problem will be taken care of differently.
Thanks!
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/1] ACPI: Fix building with GCC 15
2025-04-14 16:16 Brahmajit Das
2025-04-14 16:24 ` Brahmajit
@ 2025-04-15 18:04 ` David Laight
2025-04-15 20:30 ` Brahmajit
1 sibling, 1 reply; 9+ messages in thread
From: David Laight @ 2025-04-15 18:04 UTC (permalink / raw)
To: Brahmajit Das
Cc: Robert Moore, Rafael J. Wysocki, Len Brown, linux-acpi,
acpica-devel, linux-kernel
On Mon, 14 Apr 2025 21:46:42 +0530
Brahmajit Das <brahmajit.xyz@gmail.com> 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/1] ACPI: Fix building with GCC 15
2025-04-15 18:04 ` David Laight
@ 2025-04-15 20:30 ` Brahmajit
0 siblings, 0 replies; 9+ messages in thread
From: Brahmajit @ 2025-04-15 20:30 UTC (permalink / raw)
To: David Laight
Cc: Robert Moore, Rafael J. Wysocki, Len Brown, linux-acpi,
acpica-devel, linux-kernel
On 15.04.2025 19:04, David Laight wrote:
>
> 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
David, what if I used the __nonstring attribute from
include/linux/compiler_attributes.h which defines the following
#if __has_attribute(__nonstring__)
# define __nonstring __attribute__((__nonstring__))
#else
# define __nonstring
#endif
Which I came across from
https://www.kernel.org/doc/html/latest/process/programming-language.html#attributes
Also the checkpatch.pl scripts suggests using that instead.
I guess this would work from older compilers as well.
--
Regards,
listout
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-04-15 20:30 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-21 21:42 [PATCH 1/1] ACPI: Fix building with GCC 15 Brahmajit Das
2025-02-13 15:46 ` Ard Biesheuvel
2025-02-13 20:06 ` David Laight
2025-02-14 19:27 ` Brahmajit
-- strict thread matches above, loose matches on Subject: below --
2025-04-14 16:16 Brahmajit Das
2025-04-14 16:24 ` Brahmajit
2025-04-14 16:39 ` Rafael J. Wysocki
2025-04-15 18:04 ` David Laight
2025-04-15 20:30 ` Brahmajit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox