Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1434878 > unrolled thread

[PATCH 04/11] perf annotate: Simplify header dotted line sizing

Started byArnaldo Carvalho de Melo <acme@kernel.org>
First post2016-07-01 00:20 +0200
Last post2016-07-01 00:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 04/11] perf annotate: Simplify header dotted line sizing Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-01 00:20 +0200

#1434878 — [PATCH 04/11] perf annotate: Simplify header dotted line sizing

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-07-01 00:20 +0200
Subject[PATCH 04/11] perf annotate: Simplify header dotted line sizing
Message-ID<rPSts-6J4-19@gated-at.bofh.it>
From: "Peter Zijlstra (Intel)" <peterz@infradead.org>

No need to use strlen, etc to figure that out, just use the return from
printf(), it will tell how wide the following line needs to be.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20160630082955.GA30921@twins.programming.kicks-ass.net
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/annotate.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index c385fecb9d32..78e5d6f3ff61 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1528,7 +1528,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 	int more = 0;
 	u64 len;
 	int width = 8;
-	int namelen, evsel_name_len, graph_dotted_len;
+	int graph_dotted_len;
 
 	filename = strdup(dso->long_name);
 	if (!filename)
@@ -1540,17 +1540,14 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 		d_filename = basename(filename);
 
 	len = symbol__size(sym);
-	namelen = strlen(d_filename);
-	evsel_name_len = strlen(evsel_name);
 
 	if (perf_evsel__is_group_event(evsel))
 		width *= evsel->nr_members;
 
-	printf(" %-*.*s|	Source code & Disassembly of %s for %s\n",
+	graph_dotted_len = printf(" %-*.*s|	Source code & Disassembly of %s for %s\n",
 	       width, width, "Percent", d_filename, evsel_name);
 
-	graph_dotted_len = width + namelen + evsel_name_len;
-	printf("-%-*.*s-----------------------------------------\n",
+	printf("%-*.*s----\n",
 	       graph_dotted_len, graph_dotted_len, graph_dotted_line);
 
 	if (verbose)
-- 
2.7.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web