]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf hist: Fix width calculation in hpp__fmt()
authorDmitry Vyukov <dvyukov@google.com>
Wed, 8 Jan 2025 06:59:34 +0000 (07:59 +0100)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 17 Jan 2025 17:51:18 +0000 (09:51 -0800)
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 <dvyukov@google.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/r/20250108065949.235718-1-dvyukov@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/ui/hist.c

index e5491995adf08bf25733d27c1b36a5c57c69a09d..34fda1d5eccb41f7ba17e8addc355c0159a9522a 100644 (file)
@@ -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,