summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/sort.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2013-09-11 14:46:56 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-11-04 11:50:28 -0300
commitb9c5143a012a543c4ee872498d6dbae5c10beb2e (patch)
treed7a288aefff2a6d50c5090a7608e63372e5776af /tools/perf/util/sort.c
parent6e6dc401d528e3b64626de82322fa237f1c1e576 (diff)
downloadop-kernel-dev-b9c5143a012a543c4ee872498d6dbae5c10beb2e.zip
op-kernel-dev-b9c5143a012a543c4ee872498d6dbae5c10beb2e.tar.gz
perf tools: Use an accessor to read thread comm
As the thread comm is going to be implemented by way of a more complicated data structure than just a pointer to a string from the thread struct, convert the readers of comm to use an accessor instead of accessing it directly. The accessor will be later overriden to support an enhanced comm implementation. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Tested-by: Jiri Olsa <jolsa@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-wr683zwy94hmj4ibogmnv9ce@git.kernel.org [ Rename thread__comm_curr() to thread__comm_str() ] Signed-off-by: Namhyung Kim <namhyung@kernel.org> [ Fixed up some minor const pointer issues ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/sort.c')
-rw-r--r--tools/perf/util/sort.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 19b4aa2..835e8bd 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -42,7 +42,7 @@ static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...)
return n;
}
-static int64_t cmp_null(void *l, void *r)
+static int64_t cmp_null(const void *l, const void *r)
{
if (!l && !r)
return 0;
@@ -63,8 +63,9 @@ sort__thread_cmp(struct hist_entry *left, struct hist_entry *right)
static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf,
size_t size, unsigned int width)
{
+ const char *comm = thread__comm_str(he->thread);
return repsep_snprintf(bf, size, "%*s:%5d", width - 6,
- he->thread->comm ?: "", he->thread->tid);
+ comm ?: "", he->thread->tid);
}
struct sort_entry sort_thread = {
@@ -85,8 +86,8 @@ sort__comm_cmp(struct hist_entry *left, struct hist_entry *right)
static int64_t
sort__comm_collapse(struct hist_entry *left, struct hist_entry *right)
{
- char *comm_l = left->thread->comm;
- char *comm_r = right->thread->comm;
+ const char *comm_l = thread__comm_str(left->thread);
+ const char *comm_r = thread__comm_str(right->thread);
if (!comm_l || !comm_r)
return cmp_null(comm_l, comm_r);
@@ -97,7 +98,7 @@ sort__comm_collapse(struct hist_entry *left, struct hist_entry *right)
static int hist_entry__comm_snprintf(struct hist_entry *he, char *bf,
size_t size, unsigned int width)
{
- return repsep_snprintf(bf, size, "%*s", width, he->thread->comm);
+ return repsep_snprintf(bf, size, "%*s", width, thread__comm_str(he->thread));
}
struct sort_entry sort_comm = {
OpenPOWER on IntegriCloud