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


Groups > linux.kernel > #1201101

[PATCH 10/12] perf tools: Do not include escape sequences in color_vfprintf return

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 10/12] perf tools: Do not include escape sequences in color_vfprintf return
Date 2015-08-05 22:20 +0200
Message-ID <pUdkn-3qW-27@gated-at.bofh.it> (permalink)
References <pUdkl-3qW-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Andi Kleen <ak@linux.intel.com>

color_vprintf was including the length of the invisible escape sequences
in its return argument. Don't include them to make the return value
usable for indentation calculations.

v2: Add comment, rebase

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1438649408-20807-3-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/color.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index ff051d24a0bb..9b9565416f90 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -67,6 +67,7 @@ static int __color_vsnprintf(char *bf, size_t size, const char *color,
 	return r;
 }
 
+/* Colors are not included in return value */
 static int __color_vfprintf(FILE *fp, const char *color, const char *fmt,
 		va_list args)
 {
@@ -83,10 +84,10 @@ static int __color_vfprintf(FILE *fp, const char *color, const char *fmt,
 	}
 
 	if (perf_use_color_default && *color)
-		r += fprintf(fp, "%s", color);
+		fprintf(fp, "%s", color);
 	r += vfprintf(fp, fmt, args);
 	if (perf_use_color_default && *color)
-		r += fprintf(fp, "%s", PERF_COLOR_RESET);
+		fprintf(fp, "%s", PERF_COLOR_RESET);
 	return r;
 }
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/12] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 05/12] perf trace: Deref sys_enter pointer args with contents from probe:vfs_getname Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 10/12] perf tools: Do not include escape sequences in color_vfprintf return Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 01/12] perf script: No tracepoints? Don't call libtraceevent. Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 06/12] perf trace: Use vfs_getname syscall arg beautifier in more syscalls Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 12/12] perf tools: Fix build errors with mipsel-linux-uclibc compiler Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 11/12] perf trace: Write to stderr by default Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 02/12] perf trace: Do not show syscall tracepoint filter in the --no-syscalls case Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 03/12] perf trace: Remember if the vfs_getname tracepoint/kprobe is in place Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 09/12] perf tools: Remove trail argument to color vsprintf Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 07/12] perf tools: Per-event time support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200
  [PATCH 08/12] perf tools: Refine parse/config callchain functions Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-05 22:20 +0200

csiph-web