From a4cecfbdc96faa5c9887f9ceb7d233acde75223f Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Wed, 20 Oct 2021 20:34:34 +0300 Subject: [PATCH] zpool should call zfs_nicestrtonum() with non-NULL handle When zfs_nicestrtonum() is called and there will be an error, the message is left in libzfs handle, if provided. We can use this message, to provide better feedback for user. Reviewed-by: Igor Kozhukhov Reviewed-by: Brian Behlendorf Signed-off-by: Toomas Soome Closes #12650 --- cmd/zpool/zpool_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index d42ff18d8..3a2caa9a8 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -7353,9 +7353,10 @@ zpool_do_trim(int argc, char **argv) "combined with the -c or -s options\n")); usage(B_FALSE); } - if (zfs_nicestrtonum(NULL, optarg, &rate) == -1) { - (void) fprintf(stderr, - gettext("invalid value for rate\n")); + if (zfs_nicestrtonum(g_zfs, optarg, &rate) == -1) { + (void) fprintf(stderr, "%s: %s\n", + gettext("invalid value for rate"), + libzfs_error_description(g_zfs)); usage(B_FALSE); } break;