From: Rodrigo Campos <rodrigo@sdfg.com.ar>
To: "Thomas Weißschuh" <linux@weissschuh.net>,
"Willy Tarreau" <w@1wt.eu>, "Shuah Khan" <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/nolibc: avoid GCC 15 -Wunterminated-string-initialization
Date: Tue, 24 Jun 2025 13:08:51 +0200 [thread overview]
Message-ID: <86bc2557-b9cc-4767-9379-e60786b3f825@sdfg.com.ar> (raw)
In-Reply-To: <20250623-nolibc-nonstring-v1-1-11282204766a@weissschuh.net>
On 6/23/25 11:34 PM, Thomas Weißschuh wrote:
> On GCC 15 the following warnings is emitted:
>
> nolibc-test.c: In function ‘run_stdlib’:
> nolibc-test.c:1416:32: warning: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (11 chars into 10 available) [-Wunterminated-string-initialization]
> 1416 | char buf[10] = "test123456";
> | ^~~~~~~~~~~~
>
> Increase the size of buf to avoid the warning.
>
> It would also be possible to use __attribute__((nonstring)) but that
> would require some ifdeffery to work with older compilers.
>
> Fixes: 1063649cf531 ("selftests/nolibc: Add tests for strlcat() and strlcpy()")
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> tools/testing/selftests/nolibc/nolibc-test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index dbe13000fb1ac153e9a89f627492daeb584a05d4..52640d8ae402b9e34174ae798e74882ca750ec2b 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -1413,7 +1413,7 @@ int run_stdlib(int min, int max)
> * Add some more chars after the \0, to test functions that overwrite the buffer set
> * the \0 at the exact right position.
> */
> - char buf[10] = "test123456";
> + char buf[11] = "test123456";
> buf[4] = '\0';
Reviewed-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
Sorry for the typo :)
Best,
Rodrigo
prev parent reply other threads:[~2025-06-24 11:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 21:34 Thomas Weißschuh
2025-06-23 21:37 ` Willy Tarreau
2025-06-24 11:08 ` Rodrigo Campos [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86bc2557-b9cc-4767-9379-e60786b3f825@sdfg.com.ar \
--to=rodrigo@sdfg.com.ar \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=shuah@kernel.org \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®