mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
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 <irogers@google.com> Signed-off-by: Li Guan <guanli.oerv@isrc.iscas.ac.cn> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <pjw@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
f83deb0580
commit
7378b6656a
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
static char *_get_field(const char *line)
|
||||
{
|
||||
char *line2, *nl;
|
||||
const char *line2, *nl;
|
||||
|
||||
line2 = strrchr(line, ' ');
|
||||
if (!line2)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user