* [PATCH v1] perf loongarch: Fix discarded const qualifier in _get_field()
@ 2026-09-24 2:17 Tiezhu Yang
2026-09-24 2:24 ` sashiko-bot
2026-09-24 5:23 ` Namhyung Kim
0 siblings, 2 replies; 4+ messages in thread
From: Tiezhu Yang @ 2026-09-24 2:17 UTC (permalink / raw)
To: Huacai Chen, Arnaldo Carvalho de Melo, Namhyung Kim
Cc: loongarch, linux-perf-users, linux-kernel
When building perf on LoongArch, the following compilation errors occur:
CC arch/loongarch/util/header.o
arch/loongarch/util/header.c: In function '_get_field':
arch/loongarch/util/header.c:31:15: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
31 | line2 = strrchr(line, ' ');
| ^
arch/loongarch/util/header.c:36:12: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
36 | nl = strrchr(line, '\n');
| ^
cc1: all warnings being treated as errors
Declare 'line2' and 'nl' as const char * to ensure type safety. In modern
glibc versions, strrchr() returns a 'const char *' if the input string is
const.
This is similar to commit 7378b6656aa4 ("perf riscv: Fix discarded const
qualifier in _get_field()").
Fixes: 492ac37fa38f ("perf kvm: Add kvm-stat for loongarch64")
Cc: stable@vger.kernel.org
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
| 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--git a/tools/perf/arch/loongarch/util/header.c b/tools/perf/arch/loongarch/util/header.c
index 0c6d823334a2..46f53a74f71e 100644
--- a/tools/perf/arch/loongarch/util/header.c
+++ b/tools/perf/arch/loongarch/util/header.c
@@ -26,7 +26,7 @@
static char *_get_field(const char *line)
{
- char *line2, *nl;
+ const char *line2, *nl;
line2 = strrchr(line, ' ');
if (!line2)
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf loongarch: Fix discarded const qualifier in _get_field()
2026-09-24 2:17 [PATCH v1] perf loongarch: Fix discarded const qualifier in _get_field() Tiezhu Yang
@ 2026-09-24 2:24 ` sashiko-bot
2026-09-24 5:23 ` Namhyung Kim
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-09-24 2:24 UTC (permalink / raw)
To: Tiezhu Yang; +Cc: linux-perf-users
> When building perf on LoongArch, the following compilation errors occur:
>
> CC arch/loongarch/util/header.o
> arch/loongarch/util/header.c: In function '_get_field':
> arch/loongarch/util/header.c:31:15: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
> 31 | line2 = strrchr(line, ' ');
> | ^
> arch/loongarch/util/header.c:36:12: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
> 36 | nl = strrchr(line, '\n');
> | ^
> cc1: all warnings being treated as errors
>
> Declare 'line2' and 'nl' as const char * to ensure type safety. In modern
> glibc versions, strrchr() returns a 'const char *' if the input string is
> const.
>
> This is similar to commit 7378b6656aa4 ("perf riscv: Fix discarded const
> qualifier in _get_field()").
>
> Fixes: 492ac37fa38f ("perf kvm: Add kvm-stat for loongarch64")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924021756.22433-1-yangtiezhu@loongson.cn?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf loongarch: Fix discarded const qualifier in _get_field()
2026-09-24 2:17 [PATCH v1] perf loongarch: Fix discarded const qualifier in _get_field() Tiezhu Yang
2026-09-24 2:24 ` sashiko-bot
@ 2026-09-24 5:23 ` Namhyung Kim
2026-09-24 17:22 ` Arnaldo Carvalho de Melo
1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2026-09-24 5:23 UTC (permalink / raw)
To: Tiezhu Yang
Cc: Huacai Chen, Arnaldo Carvalho de Melo, loongarch,
linux-perf-users, linux-kernel
On Thu, Sep 24, 2026 at 10:17:56AM +0800, Tiezhu Yang wrote:
> When building perf on LoongArch, the following compilation errors occur:
>
> CC arch/loongarch/util/header.o
> arch/loongarch/util/header.c: In function '_get_field':
> arch/loongarch/util/header.c:31:15: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
> 31 | line2 = strrchr(line, ' ');
> | ^
> arch/loongarch/util/header.c:36:12: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
> 36 | nl = strrchr(line, '\n');
> | ^
> cc1: all warnings being treated as errors
>
> Declare 'line2' and 'nl' as const char * to ensure type safety. In modern
> glibc versions, strrchr() returns a 'const char *' if the input string is
> const.
>
> This is similar to commit 7378b6656aa4 ("perf riscv: Fix discarded const
> qualifier in _get_field()").
>
> Fixes: 492ac37fa38f ("perf kvm: Add kvm-stat for loongarch64")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> ---
> tools/perf/arch/loongarch/util/header.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/arch/loongarch/util/header.c b/tools/perf/arch/loongarch/util/header.c
> index 0c6d823334a2..46f53a74f71e 100644
> --- a/tools/perf/arch/loongarch/util/header.c
> +++ b/tools/perf/arch/loongarch/util/header.c
> @@ -26,7 +26,7 @@
>
> static char *_get_field(const char *line)
> {
> - char *line2, *nl;
> + const char *line2, *nl;
>
> line2 = strrchr(line, ' ');
> if (!line2)
> --
> 2.42.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf loongarch: Fix discarded const qualifier in _get_field()
2026-09-24 5:23 ` Namhyung Kim
@ 2026-09-24 17:22 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-09-24 17:22 UTC (permalink / raw)
To: Namhyung Kim
Cc: Tiezhu Yang, Huacai Chen, loongarch, linux-perf-users,
linux-kernel
On Wed, Sep 23, 2026 at 10:23:27PM -0700, Namhyung Kim wrote:
> On Thu, Sep 24, 2026 at 10:17:56AM +0800, Tiezhu Yang wrote:
> > When building perf on LoongArch, the following compilation errors occur:
> >
> > CC arch/loongarch/util/header.o
> > arch/loongarch/util/header.c: In function '_get_field':
> > arch/loongarch/util/header.c:31:15: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
> > 31 | line2 = strrchr(line, ' ');
> > | ^
> > arch/loongarch/util/header.c:36:12: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
> > 36 | nl = strrchr(line, '\n');
> > | ^
> > cc1: all warnings being treated as errors
> >
> > Declare 'line2' and 'nl' as const char * to ensure type safety. In modern
> > glibc versions, strrchr() returns a 'const char *' if the input string is
> > const.
> >
> > This is similar to commit 7378b6656aa4 ("perf riscv: Fix discarded const
> > qualifier in _get_field()").
> >
> > Fixes: 492ac37fa38f ("perf kvm: Add kvm-stat for loongarch64")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks, applied to perf-tools-next, for v7.4.
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-24 17:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-24 2:17 [PATCH v1] perf loongarch: Fix discarded const qualifier in _get_field() Tiezhu Yang
2026-09-24 2:24 ` sashiko-bot
2026-09-24 5:23 ` Namhyung Kim
2026-09-24 17:22 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.