summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-kvm.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2023-04-20 21:54:11 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-24 20:28:11 +0300
commitce1d3bc2733224573600e5564203345caea814eb (patch)
tree328b64218285f9e19a17faa9bd020c3f3ffac383 /tools/perf/builtin-kvm.c
parent9be6ab181b7b8d6114e225ae3c7c01bb6380cf8a (diff)
downloadlinux-ce1d3bc2733224573600e5564203345caea814eb.tar.xz
perf evsel: Introduce evsel__name_is() method to check if the evsel name is equal to a given string
This makes the logic a bit clear by avoiding the !strcmp() pattern and also a way to intercept the pointer if we need to do extra validation on it or to do lazy setting of evsel->name via evsel__name(evsel). Reviewed-by: "Liang, Kan" <kan.liang@linux.intel.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/lkml/ZEGLM8VehJbS0gP2@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-kvm.c')
-rw-r--r--tools/perf/builtin-kvm.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 747d19336340..71165036e4ca 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -625,7 +625,7 @@ void exit_event_get_key(struct evsel *evsel,
bool kvm_exit_event(struct evsel *evsel)
{
- return !strcmp(evsel->name, kvm_exit_trace);
+ return evsel__name_is(evsel, kvm_exit_trace);
}
bool exit_event_begin(struct evsel *evsel,
@@ -641,7 +641,7 @@ bool exit_event_begin(struct evsel *evsel,
bool kvm_entry_event(struct evsel *evsel)
{
- return !strcmp(evsel->name, kvm_entry_trace);
+ return evsel__name_is(evsel, kvm_entry_trace);
}
bool exit_event_end(struct evsel *evsel,
@@ -878,7 +878,7 @@ static bool is_child_event(struct perf_kvm_stat *kvm,
return false;
for (; child_ops->name; child_ops++) {
- if (!strcmp(evsel->name, child_ops->name)) {
+ if (evsel__name_is(evsel, child_ops->name)) {
child_ops->get_key(evsel, sample, key);
return true;
}