From: Jiri Olsa <jo...@kernel.org>

Adding header size to width computation for srcline sort entry,
because it's possible to get empty data with ':0' which set width
of 2 which is lower than width needed to display column header.

Signed-off-by: Jiri Olsa <jo...@kernel.org>
Cc: Andi Kleen <a...@firstfloor.org>
Cc: David Ahern <dsah...@gmail.com>
Cc: Don Zickus <dzic...@redhat.com>
Cc: Joe Mario <jma...@redhat.com>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Peter Zijlstra <a.p.zijls...@chello.nl>
Link: 
http://lkml.kernel.org/r/1474290610-23241-62-git-send-email-jo...@kernel.org
[ Added declaration to sort.h ]
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/util/hist.c | 6 ++++--
 tools/perf/util/sort.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 37a08f20730a..b02992efb513 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -177,8 +177,10 @@ void hists__calc_col_len(struct hists *hists, struct 
hist_entry *h)
        hists__new_col_len(hists, HISTC_LOCAL_WEIGHT, 12);
        hists__new_col_len(hists, HISTC_GLOBAL_WEIGHT, 12);
 
-       if (h->srcline)
-               hists__new_col_len(hists, HISTC_SRCLINE, strlen(h->srcline));
+       if (h->srcline) {
+               len = MAX(strlen(h->srcline), strlen(sort_srcline.se_header));
+               hists__new_col_len(hists, HISTC_SRCLINE, len);
+       }
 
        if (h->srcfile)
                hists__new_col_len(hists, HISTC_SRCFILE, strlen(h->srcfile));
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 28c0524c8702..9505483cb95c 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -40,6 +40,7 @@ extern struct sort_entry sort_dso_from;
 extern struct sort_entry sort_dso_to;
 extern struct sort_entry sort_sym_from;
 extern struct sort_entry sort_sym_to;
+extern struct sort_entry sort_srcline;
 extern enum sort_type sort__first_dimension;
 extern const char default_mem_sort_order[];
 
-- 
2.7.4

Reply via email to