Re: [PATCH v1] perf loongarch: Fix discarded const qualifier in _get_field()
From: Arnaldo Carvalho de Melo
Date: Thu Sep 24 2026 - 13:49:46 EST
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@xxxxxxxxxxxxxxx
> > Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
>
> Acked-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Thanks, applied to perf-tools-next, for v7.4.
- Arnaldo