From: Shreenidhi Shedi <yesshedi@gmail.com>
To: gregkh@linuxfoundation.org, acme@kernel.org, linux@treblig.org,
mikhail.v.gavrilov@gmail.com
Cc: yesshedi@gmail.com, linux-kernel@vger.kernel.org,
Ian Rogers <irogers@google.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH v1 06/18] perf tools: Use const for variables receiving str{str,r?chr}() returns
Date: Sat, 9 May 2026 23:05:47 +0530 [thread overview]
Message-ID: <20260509173559.10999-7-yesshedi@gmail.com> (raw)
In-Reply-To: <20260509173559.10999-1-yesshedi@gmail.com>
From: Arnaldo Carvalho de Melo <acme@kernel.org>
commit 45718bce7daf39c618188b70a52644bb5a2f968a upstream
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>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
---
tools/perf/jvmti/libjvmti.c | 2 +-
tools/perf/util/evlist.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/perf/jvmti/libjvmti.c b/tools/perf/jvmti/libjvmti.c
index fcca275e5bf9..d6b04d0fd35a 100644
--- a/tools/perf/jvmti/libjvmti.c
+++ b/tools/perf/jvmti/libjvmti.c
@@ -142,7 +142,7 @@ copy_class_filename(const char * class_sign, const char * file_name, char * resu
*/
if (*class_sign == 'L') {
int j, i = 0;
- char *p = strrchr(class_sign, '/');
+ const char *p = strrchr(class_sign, '/');
if (p) {
/* drop the 'L' prefix and copy up to the final '/' */
for (i = 0; i < (p - class_sign); i++)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 41bbe6f85b0d..391a694ae2af 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1885,7 +1885,8 @@ static int evlist__parse_control_fifo(const char *str, int *ctl_fd, int *ctl_fd_
int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close)
{
- char *comma = NULL, *endptr = NULL;
+ const char *comma = NULL;
+ char *endptr = NULL;
*ctl_fd_close = false;
--
2.54.0
next prev parent reply other threads:[~2026-05-09 18:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-09 17:35 [PATCH v1 00/18] Backport fixes for -Wdiscarded-qualifiers and -Wnonnull with newer glibc Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 01/18] libbpf: Fix -Wdiscarded-qualifiers under C23 Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 02/18] perf diff: Constify strchr() return variables Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 03/18] perf test bpf: Address error about non-null argument for epoll_pwait 2nd arg Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 04/18] perf list: Fix -Wdiscarded-qualifiers under C23 Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 05/18] perf trace: Deal with compiler const checks Shreenidhi Shedi
2026-05-09 17:35 ` Shreenidhi Shedi [this message]
2026-05-09 17:35 ` [PATCH v1 07/18] perf parse-events: Fix -Wdiscarded-qualifiers under C23 Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 08/18] perf tools: Remove unused color_fwrite_lines Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 09/18] perf strlist: Don't write to const memory Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 10/18] perf metricgroup: Constify variables storing the result of strchr() on const tables Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 11/18] perf session: Don't write to memory pointed to a const pointer Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 12/18] perf trace-event: Constify variables storing the result of strchr() on const tables Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 13/18] perf units: " Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 14/18] perf bpf: Fix -Wdiscarded-qualifiers under C23 Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 15/18] perf time-utils: Constify variables storing the result of strchr() on const tables Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 16/18] perf demangle-java: " Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 17/18] perf parse-events:: Fix -Wdiscarded-qualifiers under C23 Shreenidhi Shedi
2026-05-09 17:35 ` [PATCH v1 18/18] perf bpf-event: Constify variables storing the result of strchr() on const tables Shreenidhi Shedi
2026-05-10 16:25 ` [PATCH v1 00/18] Backport fixes for -Wdiscarded-qualifiers and -Wnonnull with newer glibc Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260509173559.10999-7-yesshedi@gmail.com \
--to=yesshedi@gmail.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@treblig.org \
--cc=mikhail.v.gavrilov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox