lkml.org 
[lkml]   [2018]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 17/17] perf tools: Fix comment for sort__* compare functions
Date
In commit 2f15bd8c6c6e ("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.

Link: http://lkml.kernel.org/n/tip-8p85wxr2o5ia9uinxeea8853@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/sort.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 2da4d0456a03..e8514f651865 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -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));
}

--
2.13.6
\
 
 \ /
  Last update: 2018-02-06 19:27    [W:0.414 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site