From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Yushan Wang <wangyushan12@huawei.com>
Cc: <mike.leach@linaro.org>, <mingo@redhat.com>, <acme@kernel.org>,
<namhyung@kernel.org>, <mark.rutland@arm.com>,
<alexander.shishkin@linux.intel.com>, <jolsa@kernel.org>,
<irogers@google.com>, <adrian.hunter@intel.com>,
<peterz@infradead.org>, <john.g.garry@oracle.com>,
<shiju.jose@huawei.com>, <will@kernel.org>,
<linux-perf-users@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <linuxarm@huawei.com>,
<liuyonglong@huawei.com>, <prime.zeng@hisilicon.com>,
<fanghao11@huawei.com>, <wangzhou1@hisilicon.com>
Subject: Re: [RFT PATCH 1/7] perf stat: Check color's length instead of the pointer
Date: Tue, 27 Jan 2026 15:58:35 +0000 [thread overview]
Message-ID: <20260127155835.000011c9@huawei.com> (raw)
In-Reply-To: <20260126123514.3238425-2-wangyushan12@huawei.com>
On Mon, 26 Jan 2026 20:35:08 +0800
Yushan Wang <wangyushan12@huawei.com> wrote:
> Color string returned by metric_threshold_classify__color() is never
> NULL, check the presence of *color will always return true.
>
> Fix this by change the checks against length of *color.
>
> Fixes: 37b77ae95416 ("perf stat: Change color to threshold in print_metric")
>
No blank line between tags.
Fixes: 37b77ae95416 ("perf stat: Change color to threshold in print_metric")
Signed-off-by: Yushan Wang <wangyushan12@huawei.com>
Some of the scripting run against the kernel uses that lack of blank lines
as a heuristic to identify what is a tag vs other similar looking text.
Thanks,
Jonathan
> Signed-off-by: Yushan Wang <wangyushan12@huawei.com>
> ---
> tools/perf/builtin-script.c | 2 +-
> tools/perf/util/stat-display.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 62e43d3c5ad7..9fe90f564c69 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -2100,7 +2100,7 @@ static void script_print_metric(struct perf_stat_config *config __maybe_unused,
> perf_sample__fprintf_start(NULL, mctx->sample, mctx->thread, mctx->evsel,
> PERF_RECORD_SAMPLE, mctx->fp);
> fputs("\tmetric: ", mctx->fp);
> - if (color)
> + if (strlen(color))
> color_fprintf(mctx->fp, color, fmt, val);
> else
> printf(fmt, val);
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index 6d02f84c5691..91c0c1020f4e 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -474,7 +474,7 @@ static void print_metric_std(struct perf_stat_config *config,
> do_new_line_std(config, os);
>
> n = fprintf(out, " # ");
> - if (color)
> + if (strlen(color))
> n += color_fprintf(out, color, fmt, val);
> else
> n += fprintf(out, fmt, val);
> @@ -607,7 +607,7 @@ static void print_metric_only(struct perf_stat_config *config,
> if (mlen < strlen(unit))
> mlen = strlen(unit) + 1;
>
> - if (color)
> + if (strlen(color))
> mlen += strlen(color) + sizeof(PERF_COLOR_RESET) - 1;
>
> color_snprintf(str, sizeof(str), color ?: "", fmt ?: "", val);
next prev parent reply other threads:[~2026-01-27 15:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 12:35 [RFT PATCH 0/7] perf tool: Support iostat for multiple platforms Yushan Wang
2026-01-26 12:35 ` [RFT PATCH 1/7] perf stat: Check color's length instead of the pointer Yushan Wang
2026-01-27 15:58 ` Jonathan Cameron [this message]
2026-01-29 15:19 ` wangyushan
2026-01-26 12:35 ` [RFT PATCH 2/7] perf stat: Save unnecessary print_metric() call Yushan Wang
2026-01-27 16:01 ` Jonathan Cameron
2026-01-29 15:17 ` wangyushan
2026-01-26 12:35 ` [RFT PATCH 3/7] perf-x86: iostat: Change iostat_prefix() to static Yushan Wang
2026-01-26 12:35 ` [RFT PATCH 4/7] perf-iostat: Extend iostat interface to support different iostat PMUs Yushan Wang
2026-01-26 12:35 ` [RFT PATCH 5/7] perf-iostat: Support wilder wildcard-match for pmus Yushan Wang
2026-01-26 16:44 ` Ian Rogers
2026-01-29 15:14 ` wangyushan
2026-01-26 12:35 ` [RFT PATCH 6/7] perf-iostat: Make x86 iostat compatible with new iostat framework Yushan Wang
2026-01-26 12:35 ` [RFT PATCH 7/7] perf-iostat: Enable iostat mode for HiSilicon PCIe PMU Yushan Wang
2026-01-26 17:01 ` [RFT PATCH 0/7] perf tool: Support iostat for multiple platforms Ian Rogers
2026-01-29 15:14 ` wangyushan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260127155835.000011c9@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=fanghao11@huawei.com \
--cc=irogers@google.com \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=prime.zeng@hisilicon.com \
--cc=shiju.jose@huawei.com \
--cc=wangyushan12@huawei.com \
--cc=wangzhou1@hisilicon.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox