From: Dmitry Vyukov Date: Wed, 8 Jan 2025 06:59:34 +0000 (+0100) Subject: perf hist: Fix width calculation in hpp__fmt() X-Git-Tag: v6.14-rc1~120^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=036e2faa997c39a5f15dbeb50528911778d8b29d;p=thirdparty%2Flinux.git 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 --- 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,