From 036e2faa997c39a5f15dbeb50528911778d8b29d Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 8 Jan 2025 07:59:34 +0100 Subject: [PATCH] perf hist: Fix width calculation in hpp__fmt() hpp__width_fn() round up width to length of the field name, hpp__fmt() should do it too. Otherwise, the numbers may end up unaligned if the field name is long. Signed-off-by: Dmitry Vyukov Reviewed-by: James Clark Link: https://lore.kernel.org/r/20250108065949.235718-1-dvyukov@google.com Signed-off-by: Namhyung Kim --- tools/perf/ui/hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index e5491995adf08..34fda1d5eccb4 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -121,7 +121,7 @@ int hpp__fmt(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, const char *fmtstr, hpp_snprint_fn print_fn, enum perf_hpp_fmt_type fmtype) { - int len = fmt->user_len ?: fmt->len; + int len = max(fmt->user_len ?: fmt->len, (int)strlen(fmt->name)); if (symbol_conf.field_sep) { return __hpp__fmt(hpp, he, get_field, fmtstr, 1, -- 2.50.1