From: David Laight <david.laight.linux@gmail.com>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Willy Tarreau <w@1wt.eu>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] selftests/nolibc: cast execve() argv string to character pointer
Date: Thu, 21 May 2026 19:15:58 +0100 [thread overview]
Message-ID: <20260521191558.6e62c6bc@pumpkin> (raw)
In-Reply-To: <20260521-nolibc-write-strings-v1-2-2debb3ad4142@weissschuh.net>
On Thu, 21 May 2026 18:29:30 +0200
Thomas Weißschuh <linux@weissschuh.net> wrote:
> The existing code would trigger a warning under -Wwrite-strings which is
> about to be enabled. execve() is specified as not modifying the argv
> array, but the exact semantics are not representable in the type system.
I suspect you'll have to fix it again to avoid 'casting away const'.
Can you use something like (char[]){"/"} ?
-- David
> See the section "Rationale" in page linked below.
>
> Link: https://pubs.opengroup.org/onlinepubs/9799919799/functions/exec.html
> 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 c3867cc570c6..9f8cb3672737 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -1533,7 +1533,7 @@ int run_syscall(int min, int max)
> CASE_TEST(dup2_m1); tmp = dup2(-1, 100); EXPECT_SYSER(1, tmp, -1, EBADF); if (tmp != -1) close(tmp); break;
> CASE_TEST(dup3_0); tmp = dup3(0, 100, 0); EXPECT_SYSNE(1, tmp, -1); close(tmp); break;
> CASE_TEST(dup3_m1); tmp = dup3(-1, 100, 0); EXPECT_SYSER(1, tmp, -1, EBADF); if (tmp != -1) close(tmp); break;
> - CASE_TEST(execve_root); EXPECT_SYSER(1, execve("/", (char*[]){ [0] = "/", [1] = NULL }, NULL), -1, EACCES); break;
> + CASE_TEST(execve_root); EXPECT_SYSER(1, execve("/", (char*[]){ [0] = (char *)"/", [1] = NULL }, NULL), -1, EACCES); break;
> CASE_TEST(fchdir_stdin); EXPECT_SYSER(1, fchdir(STDIN_FILENO), -1, ENOTDIR); break;
> CASE_TEST(fchdir_badfd); EXPECT_SYSER(1, fchdir(-1), -1, EBADF); break;
> CASE_TEST(file_stream); EXPECT_SYSZR(1, test_file_stream()); break;
>
next prev parent reply other threads:[~2026-05-21 18:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 16:29 [PATCH 0/3] tools/nolibc: -Wwrite-strings compatibility Thomas Weißschuh
2026-05-21 16:29 ` [PATCH 1/3] tools/nolibc: cast default values of program_invocation_name Thomas Weißschuh
2026-05-21 16:29 ` [PATCH 2/3] selftests/nolibc: cast execve() argv string to character pointer Thomas Weißschuh
2026-05-21 18:15 ` David Laight [this message]
2026-05-22 14:39 ` Thomas Weißschuh
2026-05-22 18:48 ` David Laight
2026-05-22 21:40 ` Thomas Weißschuh
2026-05-23 9:53 ` David Laight
2026-05-24 8:18 ` Thomas Weißschuh
2026-05-21 16:29 ` [PATCH 3/3] selftests/nolibc: test against -Wwrite-strings Thomas Weißschuh
2026-05-22 3:28 ` [PATCH 0/3] tools/nolibc: -Wwrite-strings compatibility Willy Tarreau
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=20260521191558.6e62c6bc@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--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®