From 06b805067833902613de1871fa01e29fc80c8247 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Sun, 20 Feb 2022 04:06:02 +0100
Subject: [PATCH] zpool: main: list: don't pay for printf
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia ZiemiaƄska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13125
---
 cmd/zpool/zpool_main.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index 07fabde8a3..717d8b806d 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -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,