mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-21 22:03:58 +00:00
perf evsel: Enable type checking for perf_evsel_config_term types
Use a typed enum for the perf_evsel_config_term type enum. This allows gcc to do much stronger type checks, and also check for missing case statements. I removed the unused _MAX member from the number. It found one missing case. I'm not sure it's a real problem, so I just turned it into a BUG_ON for now. Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: http://lkml.kernel.org/r/20171020202755.21410-1-andi@firstfloor.org [ Renamed the enum name to term_type as per jolsa's request ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
c2f1cead19
commit
d056513260
2 changed files with 4 additions and 3 deletions
|
@ -779,6 +779,8 @@ static void apply_config_terms(struct perf_evsel *evsel,
|
||||||
case PERF_EVSEL__CONFIG_TERM_OVERWRITE:
|
case PERF_EVSEL__CONFIG_TERM_OVERWRITE:
|
||||||
attr->write_backward = term->val.overwrite ? 1 : 0;
|
attr->write_backward = term->val.overwrite ? 1 : 0;
|
||||||
break;
|
break;
|
||||||
|
case PERF_EVSEL__CONFIG_TERM_DRV_CFG:
|
||||||
|
BUG_ON(1);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct cgroup_sel;
|
||||||
* It is allocated within event parsing and attached to
|
* It is allocated within event parsing and attached to
|
||||||
* perf_evsel::config_terms list head.
|
* perf_evsel::config_terms list head.
|
||||||
*/
|
*/
|
||||||
enum {
|
enum term_type {
|
||||||
PERF_EVSEL__CONFIG_TERM_PERIOD,
|
PERF_EVSEL__CONFIG_TERM_PERIOD,
|
||||||
PERF_EVSEL__CONFIG_TERM_FREQ,
|
PERF_EVSEL__CONFIG_TERM_FREQ,
|
||||||
PERF_EVSEL__CONFIG_TERM_TIME,
|
PERF_EVSEL__CONFIG_TERM_TIME,
|
||||||
|
@ -49,12 +49,11 @@ enum {
|
||||||
PERF_EVSEL__CONFIG_TERM_OVERWRITE,
|
PERF_EVSEL__CONFIG_TERM_OVERWRITE,
|
||||||
PERF_EVSEL__CONFIG_TERM_DRV_CFG,
|
PERF_EVSEL__CONFIG_TERM_DRV_CFG,
|
||||||
PERF_EVSEL__CONFIG_TERM_BRANCH,
|
PERF_EVSEL__CONFIG_TERM_BRANCH,
|
||||||
PERF_EVSEL__CONFIG_TERM_MAX,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct perf_evsel_config_term {
|
struct perf_evsel_config_term {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
int type;
|
enum term_type type;
|
||||||
union {
|
union {
|
||||||
u64 period;
|
u64 period;
|
||||||
u64 freq;
|
u64 freq;
|
||||||
|
|
Loading…
Add table
Reference in a new issue