[PATCH v1 07/18] perf parse-events: Fix -Wdiscarded-qualifiers under C23

From: Shreenidhi Shedi

Date: Sat May 09 2026 - 14:04:39 EST


glibc >= 2.42 defaults to -std=gnu23, which promotes
-Wdiscarded-qualifiers to an error.

util/print-events.c:206:21: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
206 | buf = strchr(nd->s, '@');

util/print-events.c:215:29: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
215 | ptr = strchr(nd2->s, '@');

Signed-off-by: Shreenidhi Shedi <yesshedi@xxxxxxxxx>
---
tools/perf/util/print-events.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c
index c4d5d87fae2f..1ef1a3ed8051 100644
--- a/tools/perf/util/print-events.c
+++ b/tools/perf/util/print-events.c
@@ -203,7 +203,7 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob,
strlist__delete(bidlist);

strlist__for_each_entry(nd, sdtlist) {
- buf = strchr(nd->s, '@');
+ buf = strchr((char *)nd->s, '@');
if (buf)
*(buf++) = '\0';
if (name_only) {
@@ -212,7 +212,7 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob,
}
nd2 = strlist__next(nd);
if (nd2) {
- ptr = strchr(nd2->s, '@');
+ ptr = strchr((char *)nd2->s, '@');
if (ptr)
*ptr = '\0';
if (strcmp(nd->s, nd2->s) == 0)
--
2.54.0