Commit 970ef02e authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf parse-events: Make term's config const

This avoids casts in tests. Use zfree in a few places to avoid
warnings about a freeing a const pointer.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Ming Wang <wangming01@loongson.cn>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Wei Li <liwei391@huawei.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230825024002.801955-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c091ee90
...@@ -28,55 +28,55 @@ static struct test_format { ...@@ -28,55 +28,55 @@ static struct test_format {
/* Simulated users input. */ /* Simulated users input. */
static struct parse_events_term test_terms[] = { static struct parse_events_term test_terms[] = {
{ {
.config = (char *) "krava01", .config = "krava01",
.val.num = 15, .val.num = 15,
.type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_val = PARSE_EVENTS__TERM_TYPE_NUM,
.type_term = PARSE_EVENTS__TERM_TYPE_USER, .type_term = PARSE_EVENTS__TERM_TYPE_USER,
}, },
{ {
.config = (char *) "krava02", .config = "krava02",
.val.num = 170, .val.num = 170,
.type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_val = PARSE_EVENTS__TERM_TYPE_NUM,
.type_term = PARSE_EVENTS__TERM_TYPE_USER, .type_term = PARSE_EVENTS__TERM_TYPE_USER,
}, },
{ {
.config = (char *) "krava03", .config = "krava03",
.val.num = 1, .val.num = 1,
.type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_val = PARSE_EVENTS__TERM_TYPE_NUM,
.type_term = PARSE_EVENTS__TERM_TYPE_USER, .type_term = PARSE_EVENTS__TERM_TYPE_USER,
}, },
{ {
.config = (char *) "krava11", .config = "krava11",
.val.num = 27, .val.num = 27,
.type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_val = PARSE_EVENTS__TERM_TYPE_NUM,
.type_term = PARSE_EVENTS__TERM_TYPE_USER, .type_term = PARSE_EVENTS__TERM_TYPE_USER,
}, },
{ {
.config = (char *) "krava12", .config = "krava12",
.val.num = 1, .val.num = 1,
.type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_val = PARSE_EVENTS__TERM_TYPE_NUM,
.type_term = PARSE_EVENTS__TERM_TYPE_USER, .type_term = PARSE_EVENTS__TERM_TYPE_USER,
}, },
{ {
.config = (char *) "krava13", .config = "krava13",
.val.num = 2, .val.num = 2,
.type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_val = PARSE_EVENTS__TERM_TYPE_NUM,
.type_term = PARSE_EVENTS__TERM_TYPE_USER, .type_term = PARSE_EVENTS__TERM_TYPE_USER,
}, },
{ {
.config = (char *) "krava21", .config = "krava21",
.val.num = 119, .val.num = 119,
.type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_val = PARSE_EVENTS__TERM_TYPE_NUM,
.type_term = PARSE_EVENTS__TERM_TYPE_USER, .type_term = PARSE_EVENTS__TERM_TYPE_USER,
}, },
{ {
.config = (char *) "krava22", .config = "krava22",
.val.num = 11, .val.num = 11,
.type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_val = PARSE_EVENTS__TERM_TYPE_NUM,
.type_term = PARSE_EVENTS__TERM_TYPE_USER, .type_term = PARSE_EVENTS__TERM_TYPE_USER,
}, },
{ {
.config = (char *) "krava23", .config = "krava23",
.val.num = 2, .val.num = 2,
.type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_val = PARSE_EVENTS__TERM_TYPE_NUM,
.type_term = PARSE_EVENTS__TERM_TYPE_USER, .type_term = PARSE_EVENTS__TERM_TYPE_USER,
......
...@@ -199,7 +199,7 @@ static void fix_raw(struct list_head *config_terms, struct perf_pmu *pmu) ...@@ -199,7 +199,7 @@ static void fix_raw(struct list_head *config_terms, struct perf_pmu *pmu)
continue; continue;
if (perf_pmu__have_event(pmu, term->val.str)) { if (perf_pmu__have_event(pmu, term->val.str)) {
free(term->config); zfree(&term->config);
term->config = term->val.str; term->config = term->val.str;
term->type_val = PARSE_EVENTS__TERM_TYPE_NUM; term->type_val = PARSE_EVENTS__TERM_TYPE_NUM;
term->type_term = PARSE_EVENTS__TERM_TYPE_USER; term->type_term = PARSE_EVENTS__TERM_TYPE_USER;
...@@ -208,7 +208,7 @@ static void fix_raw(struct list_head *config_terms, struct perf_pmu *pmu) ...@@ -208,7 +208,7 @@ static void fix_raw(struct list_head *config_terms, struct perf_pmu *pmu)
continue; continue;
} }
free(term->config); zfree(&term->config);
term->config = strdup("config"); term->config = strdup("config");
errno = 0; errno = 0;
num = strtoull(term->val.str + 1, NULL, 16); num = strtoull(term->val.str + 1, NULL, 16);
...@@ -1416,7 +1416,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state, ...@@ -1416,7 +1416,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
struct perf_pmu *pmu = NULL; struct perf_pmu *pmu = NULL;
YYLTYPE *loc = loc_; YYLTYPE *loc = loc_;
int ok = 0; int ok = 0;
char *config; const char *config;
*listp = NULL; *listp = NULL;
...@@ -1435,7 +1435,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state, ...@@ -1435,7 +1435,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
PARSE_EVENTS__TERM_TYPE_USER, PARSE_EVENTS__TERM_TYPE_USER,
config, 1, false, NULL, config, 1, false, NULL,
NULL) < 0) { NULL) < 0) {
free(config); zfree(&config);
goto out_err; goto out_err;
} }
list_add_tail(&term->list, head); list_add_tail(&term->list, head);
...@@ -2378,7 +2378,7 @@ static int new_term(struct parse_events_term **_term, ...@@ -2378,7 +2378,7 @@ static int new_term(struct parse_events_term **_term,
} }
int parse_events_term__num(struct parse_events_term **term, int parse_events_term__num(struct parse_events_term **term,
int type_term, char *config, u64 num, int type_term, const char *config, u64 num,
bool no_value, bool no_value,
void *loc_term_, void *loc_val_) void *loc_term_, void *loc_val_)
{ {
......
...@@ -83,7 +83,7 @@ enum { ...@@ -83,7 +83,7 @@ enum {
}; };
struct parse_events_term { struct parse_events_term {
char *config; const char *config;
union { union {
char *str; char *str;
u64 num; u64 num;
...@@ -138,7 +138,7 @@ bool parse_events__filter_pmu(const struct parse_events_state *parse_state, ...@@ -138,7 +138,7 @@ bool parse_events__filter_pmu(const struct parse_events_state *parse_state,
void parse_events__shrink_config_terms(void); void parse_events__shrink_config_terms(void);
int parse_events__is_hardcoded_term(struct parse_events_term *term); int parse_events__is_hardcoded_term(struct parse_events_term *term);
int parse_events_term__num(struct parse_events_term **term, int parse_events_term__num(struct parse_events_term **term,
int type_term, char *config, u64 num, int type_term, const char *config, u64 num,
bool novalue, bool novalue,
void *loc_term, void *loc_val); void *loc_term, void *loc_val);
int parse_events_term__str(struct parse_events_term **term, int parse_events_term__str(struct parse_events_term **term,
......
...@@ -1418,7 +1418,7 @@ static struct perf_pmu_alias *pmu_find_alias(struct perf_pmu *pmu, ...@@ -1418,7 +1418,7 @@ static struct perf_pmu_alias *pmu_find_alias(struct perf_pmu *pmu,
struct parse_events_term *term) struct parse_events_term *term)
{ {
struct perf_pmu_alias *alias; struct perf_pmu_alias *alias;
char *name; const char *name;
if (parse_events__is_hardcoded_term(term)) if (parse_events__is_hardcoded_term(term))
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment