]> git.ipfire.org Git - thirdparty/linux.git/commit
perf list: Don't write to const memory
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 20 Jan 2026 21:16:09 +0000 (18:16 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 21 Jan 2026 14:01:22 +0000 (11:01 -0300)
commit29132d16965e66fed0bf7b38242e7e57df294ba0
tree5d78fb140c386372ef3edb821ba37a1bcd598996
parent9a0a5b5ac4372da84394dc329f763d6b7d384a86
perf list: Don't write to const memory

Something now detected on fedora 44, where strchr() returns const if it
is passed a const pointer:

  util/print-events.c: In function 'print_sdt_events':
  util/print-events.c:89:29: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
     89 |                 char *bid = strchr(sdt_name->s, '@');
        |                             ^~~~~~

Fix it by using strchrnul() + strncmp() instead of temporarily scrubbing
it with '\0'.

Reviewed-by: Ian Rogers <irogers@google.com>
Suggested-by: David Laight <david.laight.linux@gmail.com>
Link: https://lore.kernel.org/r/20260121112536.27fd5d11@pumpkin
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/print-events.c