zpool: main: list: don't pay for printf

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13125
This commit is contained in:
наб 2022-02-20 04:06:02 +01:00 committed by Brian Behlendorf
parent cdb3eb5aa4
commit 06b8050678

View File

@ -5022,7 +5022,7 @@ get_namewidth(zpool_handle_t *zhp, int min_width, int flags, boolean_t verbose)
if ((config = zpool_get_config(zhp, NULL)) != NULL) {
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&nvroot) == 0);
unsigned int poolname_len = strlen(zpool_get_name(zhp));
size_t poolname_len = strlen(zpool_get_name(zhp));
if (verbose == B_FALSE) {
width = MAX(poolname_len, min_width);
} else {
@ -5961,7 +5961,7 @@ print_header(list_cbdata_t *cb)
}
if (!first)
(void) printf(" ");
(void) fputs(" ", stdout);
else
first = B_FALSE;
@ -5979,14 +5979,14 @@ print_header(list_cbdata_t *cb)
}
if (pl->pl_next == NULL && !right_justify)
(void) printf("%s", header);
(void) fputs(header, stdout);
else if (right_justify)
(void) printf("%*s", (int)width, header);
else
(void) printf("%-*s", (int)width, header);
}
(void) printf("\n");
(void) fputc('\n', stdout);
}
/*
@ -6016,9 +6016,9 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
if (!first) {
if (cb->cb_scripted)
(void) printf("\t");
(void) fputc('\t', stdout);
else
(void) printf(" ");
(void) fputs(" ", stdout);
} else {
first = B_FALSE;
}
@ -6048,14 +6048,14 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
* format specifier.
*/
if (cb->cb_scripted || (pl->pl_next == NULL && !right_justify))
(void) printf("%s", propstr);
(void) fputs(propstr, stdout);
else if (right_justify)
(void) printf("%*s", (int)width, propstr);
else
(void) printf("%-*s", (int)width, propstr);
}
(void) printf("\n");
(void) fputc('\n', stdout);
}
static void
@ -6191,7 +6191,7 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
}
print_one_column(ZPOOL_PROP_HEALTH, 0, state, scripted,
B_TRUE, format);
(void) printf("\n");
(void) fputc('\n', stdout);
}
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,