From: Li Guan Date: Wed, 13 May 2026 18:07:21 +0000 (+0800) Subject: perf riscv: Fix discarded const qualifier in _get_field() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7378b6656aa46fda56f2743d5a7c1f619c2f6f9b;p=thirdparty%2Flinux.git perf riscv: Fix discarded const qualifier in _get_field() The assignment of strrchr() return values to non-const char * variables triggers a -Werror=discarded-qualifiers warning when building with GCC 14. This happens because in newer glibc versions, strrchr() returns a 'const char *' if the input string is const. Properly declare 'line2' and 'nl' as const char * to match the glibc function signature and ensure type safety. This avoids the need for explicit type casting and aligns with the design pattern of not modifying read-only memory in the perf tool. Reviewed-by: Ian Rogers Signed-off-by: Li Guan Cc: Adrian Hunter Cc: Namhyung Kim Cc: Palmer Dabbelt Cc: Paul Walmsley Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/arch/riscv/util/header.c b/tools/perf/arch/riscv/util/header.c index 4b839203d4a54..891984e909bd8 100644 --- a/tools/perf/arch/riscv/util/header.c +++ b/tools/perf/arch/riscv/util/header.c @@ -19,7 +19,7 @@ static char *_get_field(const char *line) { - char *line2, *nl; + const char *line2, *nl; line2 = strrchr(line, ' '); if (!line2)