iio: magnetometer: ak8974: Add __nonstring annotations for unterminated strings
Subsystems (2)
PATCH 1/1 iio: magnetometer: ak8974: 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 arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.
--- drivers/iio/magnetometer/ak8974.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/magnetometer/ak8974.c +2 -2
@@ -535,8 +535,8 @@ static int ak8974_detect(struct ak8974 *ak8974) fab_data2, sizeof(fab_data2));for (i =0 ; i <3 ; ++i) { -static const char axis[3 ] ="XYZ" ; -static const char pgaxis[6 ] ="ZYZXYX" ; + static const char axis[3] __nonstring = "XYZ"; + static const char pgaxis[6] __nonstring = "ZYZXYX";unsigned offz =le16_to_cpu (fab_data2[i]) &0x7F ;unsigned fine =le16_to_cpu (fab_data1[i]);unsigned sens =le16_to_cpu (fab_data1[i +3 ]);
Signature · 1 line
2.34.1
Quoted 6 lines · Kees Cook
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 arrays with
__nonstringto and correctly identify the char array as "not a C string" and thereby eliminate the warning.
Quoted 6 lines
Cc Linus Walleij <[email protected]>Cc Jonathan Cameron <[email protected]>Cc Lars-Peter Clausen <[email protected]>Signed-off-by Kees Cook <[email protected]>
Fair enough,
Yours,
Linus Walleij
Jonathan Cameron
maintainerQuoted 15 lines · On Fri, 14 Mar 2025 11:31:09 +0100 Linus Walleij <[email protected]>…
Quoted 6 lines · Kees Cook
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 arrays with
__nonstringto and correctly identify the char array as "not a C string" and thereby eliminate the warning.Quoted 6 lines
Cc Linus Walleij <[email protected]>Cc Jonathan Cameron <[email protected]>Cc Lars-Peter Clausen <[email protected]>Signed-off-by Kees Cook <[email protected]>
Quoted 3 lines
Fair enough,
Reviewed-by Linus Walleij <[email protected]>
Kees,
I've currently queued this for next cycle as it doesn't feel like a fix as such and I've already sent my pull request for the merge window.
Is it worth rushing it in, or is a fully cycle delay an issue? (6.16)
If slow is fine, applied to the testing branch of iio.git which gets 0-day bot exposure.
Jonathan
Quoted 2 lines
Yours,
Linus Walleij
Quoted 23 lines · Jonathan Cameron
Quoted 15 lines · On Fri, 14 Mar 2025 11:31:09 +0100 Linus Walleij <[email protected]>…
Quoted 6 lines · Kees Cook
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 arrays with
__nonstringto and correctly identify the char array as "not a C string" and thereby eliminate the warning.Quoted 6 lines
Cc Linus Walleij <[email protected]>Cc Jonathan Cameron <[email protected]>Cc Lars-Peter Clausen <[email protected]>Signed-off-by Kees Cook <[email protected]>Quoted 3 lines
Fair enough,
Reviewed-by Linus Walleij <[email protected]>Kees,
Quoted 7 lines
I've currently queued this for next cycle as it doesn't feel like a fix as such and I've already sent my pull request for the merge window.
Is it worth rushing it in, or is a fully cycle delay an issue? (6.16)
If slow is fine, applied to the testing branch of iio.git which gets 0-day bot exposure.
No rush needed at all. This is just for cleaning up warnings for the coming releases of GCC 15 in couple months. Thanks for picking it up!
Signature · 1 line
Kees Cook
Jonathan Cameron
maintainerQuoted 27 lines · On Sat, 15 Mar 2025 14:56:02 -0700 Kees Cook <[email protected]> wrote:
Quoted 26 lines · Jonathan Cameron
Quoted 15 lines · On Fri, 14 Mar 2025 11:31:09 +0100 Linus Walleij <[email protected]>…
Quoted 6 lines · Kees Cook
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 arrays with
__nonstringto and correctly identify the char array as "not a C string" and thereby eliminate the warning.Quoted 6 lines
Cc Linus Walleij <[email protected]>Cc Jonathan Cameron <[email protected]>Cc Lars-Peter Clausen <[email protected]>Signed-off-by Kees Cook <[email protected]>Quoted 3 lines
Fair enough,
Reviewed-by Linus Walleij <[email protected]>Kees,
I've currently queued this for next cycle as it doesn't feel like a fix as such and I've already sent my pull request for the merge window.
Quoted 8 lines
Quoted 4 lines
Is it worth rushing it in, or is a fully cycle delay an issue? (6.16)
If slow is fine, applied to the testing branch of iio.git which gets 0-day bot exposure.
No rush needed at all. This is just for cleaning up warnings for the coming releases of GCC 15 in couple months. Thanks for picking it up!
Dropped because it clashes with:
05e8d261a34e ("gcc-15: add '__nonstring' markers to byte arrays")