diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2013-03-11 16:43:14 +0900 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-03-15 13:06:02 -0300 |
commit | b3a319d528fd57ef600731ee1b84d00b7204881d (patch) | |
tree | fadbcc4a692d5a4e841af9823c527eca7c5dc7dc /tools/perf/util/thread_map.h | |
parent | 85397956de304106e2fdace2db8f69ab4e966bc5 (diff) | |
download | op-kernel-dev-b3a319d528fd57ef600731ee1b84d00b7204881d.zip op-kernel-dev-b3a319d528fd57ef600731ee1b84d00b7204881d.tar.gz |
perf evlist: Add thread_map__nr() helper
Introduce and use the thread_map__nr() function to protect a possible
NULL pointer dereference and cleanup the code a bit.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1362987798-24969-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/thread_map.h')
-rw-r--r-- | tools/perf/util/thread_map.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/perf/util/thread_map.h b/tools/perf/util/thread_map.h index f718df8..0cd8b31 100644 --- a/tools/perf/util/thread_map.h +++ b/tools/perf/util/thread_map.h @@ -21,4 +21,9 @@ void thread_map__delete(struct thread_map *threads); size_t thread_map__fprintf(struct thread_map *threads, FILE *fp); +static inline int thread_map__nr(struct thread_map *threads) +{ + return threads ? threads->nr : 1; +} + #endif /* __PERF_THREAD_MAP_H */ |