aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-annotate.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 1ec741615814..a33087328bd4 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -82,6 +82,16 @@ struct sort_entry {
82 size_t (*print)(FILE *fp, struct hist_entry *); 82 size_t (*print)(FILE *fp, struct hist_entry *);
83}; 83};
84 84
85static int64_t cmp_null(void *l, void *r)
86{
87 if (!l && !r)
88 return 0;
89 else if (!l)
90 return -1;
91 else
92 return 1;
93}
94
85/* --sort pid */ 95/* --sort pid */
86 96
87static int64_t 97static int64_t
@@ -116,14 +126,8 @@ sort__comm_collapse(struct hist_entry *left, struct hist_entry *right)
116 char *comm_l = left->thread->comm; 126 char *comm_l = left->thread->comm;
117 char *comm_r = right->thread->comm; 127 char *comm_r = right->thread->comm;
118 128
119 if (!comm_l || !comm_r) { 129 if (!comm_l || !comm_r)
120 if (!comm_l && !comm_r) 130 return cmp_null(comm_l, comm_r);
121 return 0;
122 else if (!comm_l)
123 return -1;
124 else
125 return 1;
126 }
127 131
128 return strcmp(comm_l, comm_r); 132 return strcmp(comm_l, comm_r);
129} 133}
@@ -149,14 +153,8 @@ sort__dso_cmp(struct hist_entry *left, struct hist_entry *right)
149 struct dso *dso_l = left->dso; 153 struct dso *dso_l = left->dso;
150 struct dso *dso_r = right->dso; 154 struct dso *dso_r = right->dso;
151 155
152 if (!dso_l || !dso_r) { 156 if (!dso_l || !dso_r)
153 if (!dso_l && !dso_r) 157 return cmp_null(dso_l, dso_r);
154 return 0;
155 else if (!dso_l)
156 return -1;
157 else
158 return 1;
159 }
160 158
161 return strcmp(dso_l->name, dso_r->name); 159 return strcmp(dso_l->name, dso_r->name);
162} 160}