From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
James Clark <james.clark@linaro.org>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Clark Williams <williams@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 4/4] perf trace: Don't change const char strings
Date: Thu, 11 Dec 2025 19:17:56 -0300 [thread overview]
Message-ID: <20251211221756.96294-5-acme@kernel.org> (raw)
In-Reply-To: <20251211221756.96294-1-acme@kernel.org>
We got away with this so far but now with fedora 44 complaining about
the return value of strchr et all, lets use strdup for good measure.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-trace.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index baee1f6956001d86..d49c1ae409d77df1 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -5173,8 +5173,8 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
int unset __maybe_unused)
{
struct trace *trace = (struct trace *)opt->value;
- const char *s = str;
- char *sep = NULL, *lists[2] = { NULL, NULL, };
+ const char *s;
+ char *strd, *sep = NULL, *lists[2] = { NULL, NULL, };
int len = strlen(str) + 1, err = -1, list, idx;
char *strace_groups_dir = system_path(STRACE_GROUPS_DIR);
char group_name[PATH_MAX];
@@ -5183,6 +5183,10 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
if (strace_groups_dir == NULL)
return -1;
+ s = strd = strdup(str);
+ if (strd == NULL)
+ return -1;
+
if (*s == '!') {
++s;
trace->not_ev_qualifier = true;
@@ -5257,8 +5261,7 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
free(strace_groups_dir);
free(lists[0]);
free(lists[1]);
- if (sep)
- *sep = ',';
+ free(strd);
return err;
}
--
2.52.0
next prev parent reply other threads:[~2025-12-11 22:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 22:17 [PATCH perf-next 0/4] glibc str functions const return fixes Arnaldo Carvalho de Melo
2025-12-11 22:17 ` [PATCH 1/4] perf list: Remove unused 'sep' variable Arnaldo Carvalho de Melo
2025-12-11 22:17 ` [PATCH 2/4] perf diff: Constify strchr() return variables Arnaldo Carvalho de Melo
2025-12-11 22:17 ` [PATCH 3/4] perf tools: Use const for variables receiving str{str,r?chr}() returns Arnaldo Carvalho de Melo
2025-12-11 22:17 ` Arnaldo Carvalho de Melo [this message]
2025-12-12 5:23 ` [PATCH perf-next 0/4] glibc str functions const return fixes Ian Rogers
2025-12-16 18:23 ` Arnaldo Carvalho de Melo
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=20251211221756.96294-5-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.