Commit 8e8bbfb3 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf parse-events: Add const to evsel name

The evsel name is strdup-ed before assignment and so can be const.

A later change will add another similar string.

Using const makes it clearer that these are not out arguments.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Acked-by: default avatarAndi Kleen <ak@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andrew Kilroy <andrew.kilroy@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Changbin Du <changbin.du@intel.com>
Cc: Denys Zagorui <dzagorui@cisco.com>
Cc: Fabian Hemmer <copy@copy.sh>
Cc: Felix Fietkau <nbd@nbd.name>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jacob Keller <jacob.e.keller@intel.com>
Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kees Kook <keescook@chromium.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nicholas Fraser <nfraser@codeweavers.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Sami Tolvanen <samitolvanen@google.com>
Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Wan Jiabing <wanjiabing@vivo.com>
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/r/20211015172132.1162559-14-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 46bdc0bf
...@@ -38,7 +38,7 @@ static void config_hybrid_attr(struct perf_event_attr *attr, ...@@ -38,7 +38,7 @@ static void config_hybrid_attr(struct perf_event_attr *attr,
static int create_event_hybrid(__u32 config_type, int *idx, static int create_event_hybrid(__u32 config_type, int *idx,
struct list_head *list, struct list_head *list,
struct perf_event_attr *attr, char *name, struct perf_event_attr *attr, const char *name,
struct list_head *config_terms, struct list_head *config_terms,
struct perf_pmu *pmu) struct perf_pmu *pmu)
{ {
...@@ -70,7 +70,7 @@ static int pmu_cmp(struct parse_events_state *parse_state, ...@@ -70,7 +70,7 @@ static int pmu_cmp(struct parse_events_state *parse_state,
static int add_hw_hybrid(struct parse_events_state *parse_state, static int add_hw_hybrid(struct parse_events_state *parse_state,
struct list_head *list, struct perf_event_attr *attr, struct list_head *list, struct perf_event_attr *attr,
char *name, struct list_head *config_terms) const char *name, struct list_head *config_terms)
{ {
struct perf_pmu *pmu; struct perf_pmu *pmu;
int ret; int ret;
...@@ -94,7 +94,8 @@ static int add_hw_hybrid(struct parse_events_state *parse_state, ...@@ -94,7 +94,8 @@ static int add_hw_hybrid(struct parse_events_state *parse_state,
} }
static int create_raw_event_hybrid(int *idx, struct list_head *list, static int create_raw_event_hybrid(int *idx, struct list_head *list,
struct perf_event_attr *attr, char *name, struct perf_event_attr *attr,
const char *name,
struct list_head *config_terms, struct list_head *config_terms,
struct perf_pmu *pmu) struct perf_pmu *pmu)
{ {
...@@ -113,7 +114,7 @@ static int create_raw_event_hybrid(int *idx, struct list_head *list, ...@@ -113,7 +114,7 @@ static int create_raw_event_hybrid(int *idx, struct list_head *list,
static int add_raw_hybrid(struct parse_events_state *parse_state, static int add_raw_hybrid(struct parse_events_state *parse_state,
struct list_head *list, struct perf_event_attr *attr, struct list_head *list, struct perf_event_attr *attr,
char *name, struct list_head *config_terms) const char *name, struct list_head *config_terms)
{ {
struct perf_pmu *pmu; struct perf_pmu *pmu;
int ret; int ret;
...@@ -138,7 +139,8 @@ static int add_raw_hybrid(struct parse_events_state *parse_state, ...@@ -138,7 +139,8 @@ static int add_raw_hybrid(struct parse_events_state *parse_state,
int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state, int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state,
struct list_head *list, struct list_head *list,
struct perf_event_attr *attr, struct perf_event_attr *attr,
char *name, struct list_head *config_terms, const char *name,
struct list_head *config_terms,
bool *hybrid) bool *hybrid)
{ {
*hybrid = false; *hybrid = false;
...@@ -159,7 +161,8 @@ int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state, ...@@ -159,7 +161,8 @@ int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state,
} }
int parse_events__add_cache_hybrid(struct list_head *list, int *idx, int parse_events__add_cache_hybrid(struct list_head *list, int *idx,
struct perf_event_attr *attr, char *name, struct perf_event_attr *attr,
const char *name,
struct list_head *config_terms, struct list_head *config_terms,
bool *hybrid, bool *hybrid,
struct parse_events_state *parse_state) struct parse_events_state *parse_state)
......
...@@ -11,11 +11,13 @@ ...@@ -11,11 +11,13 @@
int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state, int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state,
struct list_head *list, struct list_head *list,
struct perf_event_attr *attr, struct perf_event_attr *attr,
char *name, struct list_head *config_terms, const char *name,
struct list_head *config_terms,
bool *hybrid); bool *hybrid);
int parse_events__add_cache_hybrid(struct list_head *list, int *idx, int parse_events__add_cache_hybrid(struct list_head *list, int *idx,
struct perf_event_attr *attr, char *name, struct perf_event_attr *attr,
const char *name,
struct list_head *config_terms, struct list_head *config_terms,
bool *hybrid, bool *hybrid,
struct parse_events_state *parse_state); struct parse_events_state *parse_state);
......
...@@ -337,7 +337,7 @@ static int parse_events__is_name_term(struct parse_events_term *term) ...@@ -337,7 +337,7 @@ static int parse_events__is_name_term(struct parse_events_term *term)
return term->type_term == PARSE_EVENTS__TERM_TYPE_NAME; return term->type_term == PARSE_EVENTS__TERM_TYPE_NAME;
} }
static char *get_config_name(struct list_head *head_terms) static const char *get_config_name(struct list_head *head_terms)
{ {
struct parse_events_term *term; struct parse_events_term *term;
...@@ -355,7 +355,7 @@ static struct evsel * ...@@ -355,7 +355,7 @@ static struct evsel *
__add_event(struct list_head *list, int *idx, __add_event(struct list_head *list, int *idx,
struct perf_event_attr *attr, struct perf_event_attr *attr,
bool init_attr, bool init_attr,
char *name, struct perf_pmu *pmu, const char *name, struct perf_pmu *pmu,
struct list_head *config_terms, bool auto_merge_stats, struct list_head *config_terms, bool auto_merge_stats,
const char *cpu_list) const char *cpu_list)
{ {
...@@ -394,14 +394,14 @@ __add_event(struct list_head *list, int *idx, ...@@ -394,14 +394,14 @@ __add_event(struct list_head *list, int *idx,
} }
struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr, struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr,
char *name, struct perf_pmu *pmu) const char *name, struct perf_pmu *pmu)
{ {
return __add_event(NULL, &idx, attr, false, name, pmu, NULL, false, return __add_event(NULL, &idx, attr, false, name, pmu, NULL, false,
NULL); NULL);
} }
static int add_event(struct list_head *list, int *idx, static int add_event(struct list_head *list, int *idx,
struct perf_event_attr *attr, char *name, struct perf_event_attr *attr, const char *name,
struct list_head *config_terms) struct list_head *config_terms)
{ {
return __add_event(list, idx, attr, true, name, NULL, config_terms, return __add_event(list, idx, attr, true, name, NULL, config_terms,
...@@ -464,7 +464,8 @@ int parse_events_add_cache(struct list_head *list, int *idx, ...@@ -464,7 +464,8 @@ int parse_events_add_cache(struct list_head *list, int *idx,
{ {
struct perf_event_attr attr; struct perf_event_attr attr;
LIST_HEAD(config_terms); LIST_HEAD(config_terms);
char name[MAX_NAME_LEN], *config_name; char name[MAX_NAME_LEN];
const char *config_name;
int cache_type = -1, cache_op = -1, cache_result = -1; int cache_type = -1, cache_op = -1, cache_result = -1;
char *op_result[2] = { op_result1, op_result2 }; char *op_result[2] = { op_result1, op_result2 };
int i, n, ret; int i, n, ret;
...@@ -2027,7 +2028,7 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add) ...@@ -2027,7 +2028,7 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add)
return 0; return 0;
} }
int parse_events_name(struct list_head *list, char *name) int parse_events_name(struct list_head *list, const char *name)
{ {
struct evsel *evsel; struct evsel *evsel;
...@@ -3344,7 +3345,7 @@ char *parse_events_formats_error_string(char *additional_terms) ...@@ -3344,7 +3345,7 @@ char *parse_events_formats_error_string(char *additional_terms)
struct evsel *parse_events__add_event_hybrid(struct list_head *list, int *idx, struct evsel *parse_events__add_event_hybrid(struct list_head *list, int *idx,
struct perf_event_attr *attr, struct perf_event_attr *attr,
char *name, struct perf_pmu *pmu, const char *name, struct perf_pmu *pmu,
struct list_head *config_terms) struct list_head *config_terms)
{ {
return __add_event(list, idx, attr, true, name, pmu, return __add_event(list, idx, attr, true, name, pmu,
......
...@@ -162,7 +162,7 @@ void parse_events_terms__purge(struct list_head *terms); ...@@ -162,7 +162,7 @@ void parse_events_terms__purge(struct list_head *terms);
void parse_events__clear_array(struct parse_events_array *a); void parse_events__clear_array(struct parse_events_array *a);
int parse_events__modifier_event(struct list_head *list, char *str, bool add); int parse_events__modifier_event(struct list_head *list, char *str, bool add);
int parse_events__modifier_group(struct list_head *list, char *event_mod); int parse_events__modifier_group(struct list_head *list, char *event_mod);
int parse_events_name(struct list_head *list, char *name); int parse_events_name(struct list_head *list, const char *name);
int parse_events_add_tracepoint(struct list_head *list, int *idx, int parse_events_add_tracepoint(struct list_head *list, int *idx,
const char *sys, const char *event, const char *sys, const char *event,
struct parse_events_error *error, struct parse_events_error *error,
...@@ -199,7 +199,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, ...@@ -199,7 +199,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
bool use_alias); bool use_alias);
struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr, struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr,
char *name, struct perf_pmu *pmu); const char *name, struct perf_pmu *pmu);
int parse_events_multi_pmu_add(struct parse_events_state *parse_state, int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
char *str, char *str,
...@@ -266,7 +266,8 @@ int perf_pmu__test_parse_init(void); ...@@ -266,7 +266,8 @@ int perf_pmu__test_parse_init(void);
struct evsel *parse_events__add_event_hybrid(struct list_head *list, int *idx, struct evsel *parse_events__add_event_hybrid(struct list_head *list, int *idx,
struct perf_event_attr *attr, struct perf_event_attr *attr,
char *name, struct perf_pmu *pmu, const char *name,
struct perf_pmu *pmu,
struct list_head *config_terms); struct list_head *config_terms);
#endif /* __PERF_PARSE_EVENTS_H */ #endif /* __PERF_PARSE_EVENTS_H */
...@@ -1906,7 +1906,7 @@ int perf_pmu__caps_parse(struct perf_pmu *pmu) ...@@ -1906,7 +1906,7 @@ int perf_pmu__caps_parse(struct perf_pmu *pmu)
} }
void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config, void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
char *name) const char *name)
{ {
struct perf_pmu_format *format; struct perf_pmu_format *format;
__u64 masks = 0, bits; __u64 masks = 0, bits;
......
...@@ -134,7 +134,7 @@ int perf_pmu__convert_scale(const char *scale, char **end, double *sval); ...@@ -134,7 +134,7 @@ int perf_pmu__convert_scale(const char *scale, char **end, double *sval);
int perf_pmu__caps_parse(struct perf_pmu *pmu); int perf_pmu__caps_parse(struct perf_pmu *pmu);
void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config, void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
char *name); const char *name);
bool perf_pmu__has_hybrid(void); bool perf_pmu__has_hybrid(void);
int perf_pmu__match(char *pattern, char *name, char *tok); int perf_pmu__match(char *pattern, char *name, char *tok);
......
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