Skip to content

Commit b7a001d

Browse files
Andi Kleenacmel
authored andcommitted
perf tools: Do not include escape sequences in color_vfprintf return
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>
1 parent 8011de7 commit b7a001d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/perf/util/color.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ static int __color_vsnprintf(char *bf, size_t size, const char *color,
6767
return r;
6868
}
6969

70+
/* Colors are not included in return value */
7071
static int __color_vfprintf(FILE *fp, const char *color, const char *fmt,
7172
va_list args)
7273
{
@@ -83,10 +84,10 @@ static int __color_vfprintf(FILE *fp, const char *color, const char *fmt,
8384
}
8485

8586
if (perf_use_color_default && *color)
86-
r += fprintf(fp, "%s", color);
87+
fprintf(fp, "%s", color);
8788
r += vfprintf(fp, fmt, args);
8889
if (perf_use_color_default && *color)
89-
r += fprintf(fp, "%s", PERF_COLOR_RESET);
90+
fprintf(fp, "%s", PERF_COLOR_RESET);
9091
return r;
9192
}
9293

0 commit comments

Comments
 (0)