aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/contrib/opensolaris/cmd')
-rw-r--r--cddl/contrib/opensolaris/cmd/zfs/zfs_main.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
index 301042b54ca3..d453ba030488 100644
--- a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
+++ b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
@@ -7235,7 +7235,7 @@ zfs_do_bookmark(int argc, char **argv)
fnvlist_free(nvl);
if (ret != 0) {
- const char *err_msg;
+ const char *err_msg = NULL;
char errbuf[1024];
(void) snprintf(errbuf, sizeof (errbuf),
@@ -7259,11 +7259,13 @@ zfs_do_bookmark(int argc, char **argv)
err_msg = "out of space";
break;
default:
- err_msg = "unknown error";
+ (void) zfs_standard_error(g_zfs, ret, errbuf);
break;
}
- (void) fprintf(stderr, "%s: %s\n", errbuf,
- dgettext(TEXT_DOMAIN, err_msg));
+ if (err_msg != NULL) {
+ (void) fprintf(stderr, "%s: %s\n", errbuf,
+ dgettext(TEXT_DOMAIN, err_msg));
+ }
}
return (ret != 0);
@@ -7280,7 +7282,7 @@ zfs_do_channel_program(int argc, char **argv)
char c;
char *progbuf, *filename, *poolname;
size_t progsize, progread;
- nvlist_t *outnvl;
+ nvlist_t *outnvl = NULL;
uint64_t instrlimit = ZCP_DEFAULT_INSTRLIMIT;
uint64_t memlimit = ZCP_DEFAULT_MEMLIMIT;
boolean_t sync_flag = B_TRUE, json_output = B_FALSE;
@@ -7420,7 +7422,8 @@ zfs_do_channel_program(int argc, char **argv)
* falling back on strerror() for an unexpected return code.
*/
char *errstring = NULL;
- if (nvlist_exists(outnvl, ZCP_RET_ERROR)) {
+ const char *msg = gettext("Channel program execution failed");
+ if (outnvl != NULL && nvlist_exists(outnvl, ZCP_RET_ERROR)) {
(void) nvlist_lookup_string(outnvl,
ZCP_RET_ERROR, &errstring);
if (errstring == NULL)
@@ -7449,12 +7452,11 @@ zfs_do_channel_program(int argc, char **argv)
"programs must be run as root.";
break;
default:
- errstring = strerror(ret);
+ (void) zfs_standard_error(g_zfs, ret, msg);
}
}
- (void) fprintf(stderr,
- gettext("Channel program execution failed:\n%s\n"),
- errstring);
+ if (errstring != NULL)
+ (void) fprintf(stderr, "%s:\n%s\n", msg, errstring);
} else {
if (json_output) {
(void) nvlist_print_json(stdout, outnvl);