Skip to contentSkip to conversation

perf: use format string of printf to align strings

PATCH In review Amerigo Wang 1 participant 2 messages Dec 14, 2009 – Dec 28, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: use format string of printf to align strings

Instead of filling whitespaces to do alignment, use printf's format string.

---

tools/perf/builtin-help.c +1 -2
index 9f810b1..e427d69 100644
@@ -286,8 +286,7 @@ void list_common_cmds_help(void)
 
 	puts(" The most commonly used perf commands are:");
 	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-		printf("   %s   ", common_cmds[i].name);
-		mput_char(' ', longest - strlen(common_cmds[i].name));
+		printf("   %-*s   ", longest, common_cmds[i].name);
 		puts(common_cmds[i].help);
 	}
 }
#1 lore raw

[tip:perf/core] perf: Use format string of printf to align strings

Commit-ID:  3912f2abc942a002ef611fc973add5e5eadb3432
Gitweb:     http://git.kernel.org/tip/3912f2abc942a002ef611fc973add5e5eadb3432
Author:     Amerigo Wang <[email protected]>
AuthorDate: Mon, 14 Dec 2009 03:23:56 -0500
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 28 Dec 2009 09:03:16 +0100

perf: Use format string of printf to align strings

Instead of filling whitespaces to do alignment, use printf's format string.

This simplifies the code a bit.

Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/builtin-help.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
tools/perf/builtin-help.c +1 -2
index 9f810b1..e427d69 100644
@@ -286,8 +286,7 @@ void list_common_cmds_help(void)
 
 	puts(" The most commonly used perf commands are:");
 	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-		printf("   %s   ", common_cmds[i].name);
-		mput_char(' ', longest - strlen(common_cmds[i].name));
+		printf("   %-*s   ", longest, common_cmds[i].name);
 		puts(common_cmds[i].help);
 	}
 }