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 2/4] perf diff: Constify strchr() return variables
Date: Thu, 11 Dec 2025 19:17:54 -0300 [thread overview]
Message-ID: <20251211221756.96294-3-acme@kernel.org> (raw)
In-Reply-To: <20251211221756.96294-1-acme@kernel.org>
Newer glibc versions return const char for strchr() when the 's' arg is
const, change the return variable to const to match that.
Also we don't need to turn that ',' into a '\0', as strtol will stop in
the first invalid char. No need to touch read only memory.
First noticed with fedora 44.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-diff.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 53d5ea4a6a4f7b54..59bf1f72d12e226a 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -178,10 +178,9 @@ static struct header_column {
}
};
-static int setup_compute_opt_wdiff(char *opt)
+static int setup_compute_opt_wdiff(const char *opt)
{
- char *w1_str = opt;
- char *w2_str;
+ const char *w1_str = opt, *w2_str;
int ret = -EINVAL;
@@ -192,8 +191,7 @@ static int setup_compute_opt_wdiff(char *opt)
if (!w2_str)
goto out;
- *w2_str++ = 0x0;
- if (!*w2_str)
+ if (!*++w2_str)
goto out;
compute_wdiff_w1 = strtol(w1_str, NULL, 10);
@@ -214,7 +212,7 @@ static int setup_compute_opt_wdiff(char *opt)
return ret;
}
-static int setup_compute_opt(char *opt)
+static int setup_compute_opt(const char *opt)
{
if (compute == COMPUTE_WEIGHTED_DIFF)
return setup_compute_opt_wdiff(opt);
@@ -234,7 +232,7 @@ static int setup_compute(const struct option *opt, const char *str,
char *cstr = (char *) str;
char buf[50];
unsigned i;
- char *option;
+ const char *option;
if (!str) {
*cp = COMPUTE_DELTA;
--
2.52.0
next prev parent reply other threads:[~2025-12-11 22:18 UTC|newest]
Thread overview: 6+ 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 ` Arnaldo Carvalho de Melo [this message]
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 ` [PATCH 4/4] perf trace: Don't change const char strings Arnaldo Carvalho de Melo
2025-12-12 5:23 ` [PATCH perf-next 0/4] glibc str functions const return fixes Ian Rogers
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-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).