From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424090AbdKRI1x (ORCPT ); Sat, 18 Nov 2017 03:27:53 -0500 Received: from terminus.zytor.com ([65.50.211.136]:49933 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936006AbdKRI1n (ORCPT ); Sat, 18 Nov 2017 03:27:43 -0500 Date: Sat, 18 Nov 2017 00:25:33 -0800 From: tip-bot for Andi Kleen Message-ID: 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 Reply-To: linux-kernel@vger.kernel.org, jolsa@kernel.org, ak@linux.intel.com, mingo@kernel.org, tglx@linutronix.de, acme@redhat.com, hpa@zytor.com In-Reply-To: <20171020202755.21410-1-andi@firstfloor.org> References: <20171020202755.21410-1-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf evsel: Enable type checking for perf_evsel_config_term types Git-Commit-ID: d0565132605f454179699a1b8a3276fc0f8cc87b X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: d0565132605f454179699a1b8a3276fc0f8cc87b Gitweb: https://git.kernel.org/tip/d0565132605f454179699a1b8a3276fc0f8cc87b Author: Andi Kleen AuthorDate: Fri, 20 Oct 2017 13:27:54 -0700 Committer: Arnaldo Carvalho de Melo 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 Acked-by: Jiri Olsa 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 --- 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;