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 <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Toomas Soome <tsoome@me.com>
Closes #12650
This commit is contained in:
Toomas Soome 2021-10-20 20:34:34 +03:00 committed by GitHub
parent a95c82bed8
commit a4cecfbdc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;