diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-05-24 16:29:07 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-06-04 15:28:50 +0200 |
commit | 5dbe23e8772299f227f1ac974752bc853e9814bb (patch) | |
tree | 71861f4c37a0b20e792003ce4862e58a312296f7 /tools | |
parent | perf probe: Use return of map__get() to make code more compact (diff) | |
download | linux-5dbe23e8772299f227f1ac974752bc853e9814bb.tar.xz linux-5dbe23e8772299f227f1ac974752bc853e9814bb.zip |
perf cgroup: Make evlist__find_cgroup() more compact
By taking advantage that __get() routines return the pointer to the
object for which a reference count is being get.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-xnvd07rdxliy04oi062samik@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/cgroup.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index decb91f9da82..ccd02634a616 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -93,20 +93,17 @@ static int open_cgroup(const char *name) static struct cgroup *evlist__find_cgroup(struct perf_evlist *evlist, const char *str) { struct perf_evsel *counter; - struct cgroup *cgrp = NULL; /* * check if cgrp is already defined, if so we reuse it */ evlist__for_each_entry(evlist, counter) { if (!counter->cgrp) continue; - if (!strcmp(counter->cgrp->name, str)) { - cgrp = cgroup__get(counter->cgrp); - break; - } + if (!strcmp(counter->cgrp->name, str)) + return cgroup__get(counter->cgrp); } - return cgrp; + return NULL; } static struct cgroup *cgroup__new(const char *name) |