Values printed by zpool-iostat(8) should be right-aligned

This inappropriate left-alignment was introduced in 7bb7b1f.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Signed-off-by: WHR <msl0000023508@gmail.com>
Closes #14751
This commit is contained in:
Low-power 2023-04-19 02:34:41 +08:00 committed by Tony Hutter
parent a969b1b22c
commit 4e49d8ed27
1 changed files with 6 additions and 4 deletions

View File

@ -4256,13 +4256,17 @@ print_iostat_header(iostat_cbdata_t *cb)
* by order of magnitude. Uses column_size to add padding. * by order of magnitude. Uses column_size to add padding.
*/ */
static void static void
print_stat_color(char *statbuf, unsigned int column_size) print_stat_color(const char *statbuf, unsigned int column_size)
{ {
fputs(" ", stdout); fputs(" ", stdout);
size_t len = strlen(statbuf);
while (len < column_size) {
fputc(' ', stdout);
column_size--;
}
if (*statbuf == '0') { if (*statbuf == '0') {
color_start(ANSI_GRAY); color_start(ANSI_GRAY);
fputc('0', stdout); fputc('0', stdout);
column_size--;
} else { } else {
for (; *statbuf; statbuf++) { for (; *statbuf; statbuf++) {
if (*statbuf == 'K') color_start(ANSI_GREEN); if (*statbuf == 'K') color_start(ANSI_GREEN);
@ -4277,8 +4281,6 @@ print_stat_color(char *statbuf, unsigned int column_size)
} }
} }
color_end(); color_end();
for (; column_size > 0; column_size--)
fputc(' ', stdout);
} }
/* /*