From: tip-bot for Andi Kleen <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, acme@redhat.com, mingo@kernel.org,
tglx@linutronix.de, ak@linux.intel.com,
linux-kernel@vger.kernel.org, jolsa@kernel.org
Subject: [tip:perf/core] perf evsel: Enable type checking for perf_evsel_config_term types
Date: Sat, 18 Nov 2017 00:25:33 -0800 [thread overview]
Message-ID: <tip-d0565132605f454179699a1b8a3276fc0f8cc87b@git.kernel.org> (raw)
In-Reply-To: <20171020202755.21410-1-andi@firstfloor.org>
Commit-ID: d0565132605f454179699a1b8a3276fc0f8cc87b
Gitweb: https://git.kernel.org/tip/d0565132605f454179699a1b8a3276fc0f8cc87b
Author: Andi Kleen <ak@linux.intel.com>
AuthorDate: Fri, 20 Oct 2017 13:27:54 -0700
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 16 Nov 2017 14:49:51 -0300
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>
---
tools/perf/util/evsel.c | 2 ++
tools/perf/util/evsel.h | 5 ++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bfde6a7..4376cdf 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -779,6 +779,8 @@ static void apply_config_terms(struct perf_evsel *evsel,
case PERF_EVSEL__CONFIG_TERM_OVERWRITE:
attr->write_backward = term->val.overwrite ? 1 : 0;
break;
+ case PERF_EVSEL__CONFIG_TERM_DRV_CFG:
+ BUG_ON(1);
default:
break;
}
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 157f49e..0688880 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -38,7 +38,7 @@ struct cgroup_sel;
* It is allocated within event parsing and attached to
* perf_evsel::config_terms list head.
*/
-enum {
+enum term_type {
PERF_EVSEL__CONFIG_TERM_PERIOD,
PERF_EVSEL__CONFIG_TERM_FREQ,
PERF_EVSEL__CONFIG_TERM_TIME,
@@ -49,12 +49,11 @@ enum {
PERF_EVSEL__CONFIG_TERM_OVERWRITE,
PERF_EVSEL__CONFIG_TERM_DRV_CFG,
PERF_EVSEL__CONFIG_TERM_BRANCH,
- PERF_EVSEL__CONFIG_TERM_MAX,
};
struct perf_evsel_config_term {
struct list_head list;
- int type;
+ enum term_type type;
union {
u64 period;
u64 freq;
prev parent reply other threads:[~2017-11-18 8:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-20 20:27 [PATCH 1/2] perf, tools: " Andi Kleen
2017-10-20 20:27 ` [PATCH 2/2] perf, tools, record: Fix -c/-F options for cpu event aliases Andi Kleen
2017-10-24 7:39 ` Jiri Olsa
2017-11-18 8:25 ` [tip:perf/core] perf " tip-bot for Andi Kleen
2017-11-29 6:28 ` tip-bot for Andi Kleen
2017-10-24 7:38 ` [PATCH 1/2] perf, tools: Enable type checking for perf_evsel_config_term types Jiri Olsa
2017-11-08 15:40 ` Arnaldo Carvalho de Melo
2017-11-18 8:25 ` tip-bot for Andi Kleen [this message]
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=tip-d0565132605f454179699a1b8a3276fc0f8cc87b@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome