From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Suzuki Poulouse <suzuki.poulose@arm.com>,
James Clark <james.clark@arm.com>,
Sean Christopherson <seanjc@google.com>,
Ravi Bangoria <ravi.bangoria@amd.com>,
Rob Herring <robh@kernel.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v1 1/3] perf pmu: Fewer const casts
Date: Thu, 6 Apr 2023 16:52:54 -0700 [thread overview]
Message-ID: <20230406235256.2768773-1-irogers@google.com> (raw)
struct pmu_event has const char*s, only unit needs to be non-const for
the sake of passing as an out argument to strtod. Reduce the const
casts from 4 down to 1.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/pmu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 78a407b42ad1..63a33fcfd42d 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -338,16 +338,16 @@ static int __perf_pmu__new_alias(struct list_head *list, int dirfd, char *name,
struct perf_pmu_alias *alias;
int ret;
char newval[256];
- char *long_desc = NULL, *topic = NULL, *unit = NULL, *pmu_name = NULL;
+ const char *long_desc = NULL, *topic = NULL, *unit = NULL, *pmu_name = NULL;
bool deprecated = false, perpkg = false;
if (pe) {
- long_desc = (char *)pe->long_desc;
- topic = (char *)pe->topic;
- unit = (char *)pe->unit;
+ long_desc = pe->long_desc;
+ topic = pe->topic;
+ unit = pe->unit;
perpkg = pe->perpkg;
deprecated = pe->deprecated;
- pmu_name = (char *)pe->pmu;
+ pmu_name = pe->pmu;
}
alias = malloc(sizeof(*alias));
@@ -405,7 +405,7 @@ static int __perf_pmu__new_alias(struct list_head *list, int dirfd, char *name,
desc ? strdup(desc) : NULL;
alias->topic = topic ? strdup(topic) : NULL;
if (unit) {
- if (perf_pmu__convert_scale(unit, &unit, &alias->scale) < 0)
+ if (perf_pmu__convert_scale(unit, (char **)&unit, &alias->scale) < 0)
return -1;
snprintf(alias->unit, sizeof(alias->unit), "%s", unit);
}
--
2.40.0.577.gac1e443424-goog
next reply other threads:[~2023-04-06 23:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 23:52 Ian Rogers [this message]
2023-04-06 23:52 ` [PATCH v1 2/3] perf pmu: Improve name/comments, avoid a memory allocation Ian Rogers
2023-04-06 23:52 ` [PATCH v1 3/3] perf pmu: Sort and remove duplicates using json PMU name 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=20230406235256.2768773-1-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=james.clark@arm.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=robh@kernel.org \
--cc=seanjc@google.com \
--cc=suzuki.poulose@arm.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).