perf tools: Do not include escape sequences in color_vfprintf return
authorAndi Kleen <ak@linux.intel.com>
Tue, 4 Aug 2015 00:50:02 +0000 (17:50 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 5 Aug 2015 19:46:06 +0000 (16:46 -0300)
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

index ff051d24a0bb2ea60bede4365c4dce0c633a35ff..9b9565416f9037fb59e7e4382b58b34e4857a136 100644 (file)
@@ -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;
 }
 
This page took 0.02684 seconds and 5 git commands to generate.