Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Use const for variables receiving str{str,r?chr}() returns

Newer glibc versions return const char for str{str,chr}() where the
haystack/s is const so to avoid warnings like these on fedora 44 change
some variables to const:

36 8.17 fedora:44 : FAIL gcc version 15.2.1 20251111 (Red Hat 15.2.1-4) (GCC)
libbpf.c: In function 'kallsyms_cb':
libbpf.c:8489:13: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
8489 | res = strstr(sym_name, ".llvm.");

Reviewed-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20251211221756.96294-4-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Arnaldo Carvalho de Melo and committed by
Arnaldo Carvalho de Melo
45718bce f6f41aef

+5 -4
+1 -1
tools/perf/jvmti/libjvmti.c
··· 142 142 */ 143 143 if (*class_sign == 'L') { 144 144 size_t j, i = 0; 145 - char *p = strrchr(class_sign, '/'); 145 + const char *p = strrchr(class_sign, '/'); 146 146 if (p) { 147 147 /* drop the 'L' prefix and copy up to the final '/' */ 148 148 for (i = 0; i < (size_t)(p - class_sign); i++)
+2 -2
tools/perf/tests/parse-events.c
··· 2609 2609 for (int i = 0; i < cnt; i++) { 2610 2610 struct evlist_test e = events[i]; 2611 2611 int test_ret; 2612 - const char *pos = e.name; 2613 - char buf[1024], *buf_pos = buf, *end; 2612 + const char *pos = e.name, *end; 2613 + char buf[1024], *buf_pos = buf; 2614 2614 2615 2615 while ((end = strstr(pos, "default_core"))) { 2616 2616 size_t len = end - pos;
+2 -1
tools/perf/util/evlist.c
··· 1945 1945 1946 1946 int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close) 1947 1947 { 1948 - char *comma = NULL, *endptr = NULL; 1948 + const char *comma = NULL; 1949 + char *endptr = NULL; 1949 1950 1950 1951 *ctl_fd_close = false; 1951 1952