From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755067AbbHFHDz (ORCPT ); Thu, 6 Aug 2015 03:03:55 -0400 Received: from terminus.zytor.com ([198.137.202.10]:55987 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755038AbbHFHDw (ORCPT ); Thu, 6 Aug 2015 03:03:52 -0400 Date: Thu, 6 Aug 2015 00:03:41 -0700 From: tip-bot for Andi Kleen Message-ID: Cc: eranian@google.com, mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, ak@linux.intel.com, jolsa@kernel.org, acme@redhat.com Reply-To: acme@redhat.com, jolsa@kernel.org, ak@linux.intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org, eranian@google.com In-Reply-To: <1438649408-20807-3-git-send-email-andi@firstfloor.org> References: <1438649408-20807-3-git-send-email-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Do not include escape sequences in color_vfprintf return Git-Commit-ID: b7a001d2067830a98e65d1bbbf99a6d435d70616 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: b7a001d2067830a98e65d1bbbf99a6d435d70616 Gitweb: http://git.kernel.org/tip/b7a001d2067830a98e65d1bbbf99a6d435d70616 Author: Andi Kleen AuthorDate: Mon, 3 Aug 2015 17:50:02 -0700 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 5 Aug 2015 16:46:06 -0300 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 Cc: Jiri Olsa Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1438649408-20807-3-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- 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 ff051d2..9b95654 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; }