Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Sasha Levin
Tue, 03 Nov 2026 16:54
[PATCH net-next] selftests: net: tcp_ao: make the netstat column pointer const
Author: Sasha Levin
Date: Tue, 03 Nov 2026 16:54
Date: Tue, 03 Nov 2026 16:54
33 lines
8856 bytes
8856 bytes
lookup_get_column() stores the result of strchr() on a const string in
a plain char pointer. Since glibc 2.43, strchr() returns a const char
pointer for a const argument when C23 features are enabled, as they
are with _GNU_SOURCE, so gcc and clang warn:
lib/proc.c:61:16: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
The pointer is only used to compute the length, so make it const.
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Found with gcc 16 and clang 21 on glibc 2.43; KernelCI's gcc 15 builds
show the same warning.
tools/testing/selftests/net/tcp_ao/lib/proc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/tcp_ao/lib/proc.c b/tools/testing/selftests/net/tcp_ao/lib/proc.c
index 8b984fa042869..50062b527a393 100644
--- a/tools/testing/selftests/net/tcp_ao/lib/proc.c
+++ b/tools/testing/selftests/net/tcp_ao/lib/proc.c
@@ -56,7 +56,7 @@ static struct netstat *lookup_get(struct netstat *ns,
static struct netstat *lookup_get_column(struct netstat *ns, const char *line)
{
- char *column;
+ const char *column;
column = strchr(line, ':');
if (!column)
--
2.53.0
Re: [PATCH net-next] selftests: net: tcp_ao: make the netstat column pointer const
Author: Hangbin Liu
Date: Wed, 04 Nov 2026 01:48
Date: Wed, 04 Nov 2026 01:48
37 lines
9743 bytes
9743 bytes
On Tue, Nov 03, 2026 at 11:54:19AM -0500, Sasha Levin wrote:
> lookup_get_column() stores the result of strchr() on a const string in
> a plain char pointer. Since glibc 2.43, strchr() returns a const char
> pointer for a const argument when C23 features are enabled, as they
> are with _GNU_SOURCE, so gcc and clang warn:
>
> lib/proc.c:61:16: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
>
> The pointer is only used to compute the length, so make it const.
>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> Found with gcc 16 and clang 21 on glibc 2.43; KernelCI's gcc 15 builds
> show the same warning.
>
> tools/testing/selftests/net/tcp_ao/lib/proc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/tcp_ao/lib/proc.c b/tools/testing/selftests/net/tcp_ao/lib/proc.c
> index 8b984fa042869..50062b527a393 100644
> --- a/tools/testing/selftests/net/tcp_ao/lib/proc.c
> +++ b/tools/testing/selftests/net/tcp_ao/lib/proc.c
> @@ -56,7 +56,7 @@ static struct netstat *lookup_get(struct netstat *ns,
>
> static struct netstat *lookup_get_column(struct netstat *ns, const char *line)
> {
> - char *column;
> + const char *column;
>
> column = strchr(line, ':');
> if (!column)
> --
> 2.53.0
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Re: [PATCH net-next] selftests: net: tcp_ao: make the netstat column pointer const
Author: Dmitry Safonov
Date: Wed, 04 Nov 2026 13:46
Date: Wed, 04 Nov 2026 13:46
42 lines
13461 bytes
13461 bytes
On Tue, 3 Nov 2026 at 16:54, Sasha Levin <sashal@kernel.org> wrote:
>
> lookup_get_column() stores the result of strchr() on a const string in
> a plain char pointer. Since glibc 2.43, strchr() returns a const char
> pointer for a const argument when C23 features are enabled, as they
> are with _GNU_SOURCE, so gcc and clang warn:
>
> lib/proc.c:61:16: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
>
> The pointer is only used to compute the length, so make it const.
>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
Acked-by: Dmitry Safonov <0x7f454c46@gmail.com>
Thanks!
> ---
> Found with gcc 16 and clang 21 on glibc 2.43; KernelCI's gcc 15 builds
> show the same warning.
>
> tools/testing/selftests/net/tcp_ao/lib/proc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/tcp_ao/lib/proc.c b/tools/testing/selftests/net/tcp_ao/lib/proc.c
> index 8b984fa042869..50062b527a393 100644
> --- a/tools/testing/selftests/net/tcp_ao/lib/proc.c
> +++ b/tools/testing/selftests/net/tcp_ao/lib/proc.c
> @@ -56,7 +56,7 @@ static struct netstat *lookup_get(struct netstat *ns,
>
> static struct netstat *lookup_get_column(struct netstat *ns, const char *line)
> {
> - char *column;
> + const char *column;
>
> column = strchr(line, ':');
> if (!column)
> --
> 2.53.0
>
Re: [PATCH net-next] selftests: net: tcp_ao: make the netstat column pointer const
Author: patchwork-bot+netdevbpf
Date: Fri, 06 Nov 2026 22:50
Date: Fri, 06 Nov 2026 22:50
24 lines
8738 bytes
8738 bytes
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 3 Nov 2026 11:54:19 -0500 you wrote:
> lookup_get_column() stores the result of strchr() on a const string in
> a plain char pointer. Since glibc 2.43, strchr() returns a const char
> pointer for a const argument when C23 features are enabled, as they
> are with _GNU_SOURCE, so gcc and clang warn:
>
> lib/proc.c:61:16: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
>
> [...]
Here is the summary with links:
- [net-next] selftests: net: tcp_ao: make the netstat column pointer const
https://git.kernel.org/netdev/net-next/c/f13fc72ba243
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads