diff options
author | 2012-01-22 11:00:39 +0000 | |
---|---|---|
committer | 2012-01-22 11:00:39 +0000 | |
commit | 0a69bfccb3e46a2d7e0d2e24c98d568b74d45895 (patch) | |
tree | ce1b20332025a2d00e131b733d424b6d60897eb9 | |
parent | Move list initialisation to the start of the function - this prevents us (diff) | |
download | wireguard-openbsd-0a69bfccb3e46a2d7e0d2e24c98d568b74d45895.tar.xz wireguard-openbsd-0a69bfccb3e46a2d7e0d2e24c98d568b74d45895.zip |
If no controller name is provided, use the program name as a prefix. Also,
exit with an "unknown error" if a bio(4) error is reported but no status
message has been provided.
-rw-r--r-- | sbin/bioctl/bioctl.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c index 538938ad852..363f9d6c9cf 100644 --- a/sbin/bioctl/bioctl.c +++ b/sbin/bioctl/bioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioctl.c,v 1.108 2012/01/20 14:09:25 jsing Exp $ */ +/* $OpenBSD: bioctl.c,v 1.109 2012/01/22 11:00:39 jsing Exp $ */ /* * Copyright (c) 2004, 2005 Marco Peereboom @@ -310,16 +310,24 @@ str2locator(const char *string, struct locator *location) void bio_status(struct bio_status *bs) { + extern char *__progname; + char *prefix; int i; - for (i = 0; i < bs->bs_msg_count; i++) { - if (strlen(bs->bs_controller)) - printf("%s: ", bs->bs_controller); - printf("%s\n", bs->bs_msgs[i].bm_msg); - } + if (strlen(bs->bs_controller)) + prefix = bs->bs_controller; + else + prefix = __progname; + + for (i = 0; i < bs->bs_msg_count; i++) + printf("%s: %s\n", prefix, bs->bs_msgs[i].bm_msg); - if (bs->bs_status == BIO_STATUS_ERROR) - exit(1); + if (bs->bs_status == BIO_STATUS_ERROR) { + if (bs->bs_msg_count == 0) + errx(1, "unknown error"); + else + exit(1); + } } void |