linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/3] perf pmu: Fewer const casts
@ 2023-04-06 23:52 Ian Rogers
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Ian Rogers @ 2023-04-06 23:52 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Adrian Hunter, Suzuki Poulouse, James Clark,
	Sean Christopherson, Ravi Bangoria, Rob Herring, linux-perf-users,
	linux-kernel

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-06 23:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 23:52 [PATCH v1 1/3] perf pmu: Fewer const casts Ian Rogers
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

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).