Skip to content

Commit

Permalink
perf tools: Fix comment for sort__* compare functions
Browse files Browse the repository at this point in the history
In commit 2f15bd8 ("perf tools: Fix "Command" sort_entry's cmp and
collapse function") we switched from pointer to string comparison.

But failed to remove related comments. Removing them and adding another
one to warn before pointer comparison in here.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180206181813.10943-18-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Feb 16, 2018
1 parent fdf7c49 commit a7402c9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tools/perf/util/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,20 @@ struct sort_entry sort_thread = {

/* --sort comm */

/*
* We can't use pointer comparison in functions below,
* because it gives different results based on pointer
* values, which could break some sorting assumptions.
*/
static int64_t
sort__comm_cmp(struct hist_entry *left, struct hist_entry *right)
{
/* Compare the addr that should be unique among comm */
return strcmp(comm__str(right->comm), comm__str(left->comm));
}

static int64_t
sort__comm_collapse(struct hist_entry *left, struct hist_entry *right)
{
/* Compare the addr that should be unique among comm */
return strcmp(comm__str(right->comm), comm__str(left->comm));
}

Expand Down

0 comments on commit a7402c9

Please sign in to comment.