From 4e49d8ed27893d1ff788ae7ed6bd364cfdff5fee Mon Sep 17 00:00:00 2001 From: Low-power Date: Wed, 19 Apr 2023 02:34:41 +0800 Subject: [PATCH] Values printed by zpool-iostat(8) should be right-aligned This inappropriate left-alignment was introduced in 7bb7b1f. Reviewed-by: Tony Hutter Reviewed-by: Matthew Ahrens Reviewed-by: Tino Reichardt Signed-off-by: WHR Closes #14751 --- cmd/zpool/zpool_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index a0072399f8..2311d4f046 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -4256,13 +4256,17 @@ print_iostat_header(iostat_cbdata_t *cb) * by order of magnitude. Uses column_size to add padding. */ static void -print_stat_color(char *statbuf, unsigned int column_size) +print_stat_color(const char *statbuf, unsigned int column_size) { fputs(" ", stdout); + size_t len = strlen(statbuf); + while (len < column_size) { + fputc(' ', stdout); + column_size--; + } if (*statbuf == '0') { color_start(ANSI_GRAY); fputc('0', stdout); - column_size--; } else { for (; *statbuf; statbuf++) { if (*statbuf == 'K') color_start(ANSI_GREEN); @@ -4277,8 +4281,6 @@ print_stat_color(char *statbuf, unsigned int column_size) } } color_end(); - for (; column_size > 0; column_size--) - fputc(' ', stdout); } /*