summaryrefslogtreecommitdiffstats
path: root/usr.sbin/iostat/iostat.c
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>2000-01-23 20:19:34 +0000
committercharnier <charnier@FreeBSD.org>2000-01-23 20:19:34 +0000
commit33144f5460c8233af1d5ef27106fa85766feded2 (patch)
treeb71330e9957edde6053be200d1193831dff2081c /usr.sbin/iostat/iostat.c
parent840a73c91f61d3436b296461c5f90a15e68d069e (diff)
downloadFreeBSD-src-33144f5460c8233af1d5ef27106fa85766feded2.zip
FreeBSD-src-33144f5460c8233af1d5ef27106fa85766feded2.tar.gz
Rework use of Nm.
Remove -? flag that was not working but documented. Make it work instead but hide it in man page and usage string as others tools do. Spelling. Abort on allocation failure (with errx()).
Diffstat (limited to 'usr.sbin/iostat/iostat.c')
-rw-r--r--usr.sbin/iostat/iostat.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index bf8ee5a..16a8126 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -24,8 +24,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
* Parts of this program are derived from the original FreeBSD iostat
@@ -99,6 +97,10 @@
* SUCH DAMAGE.
*/
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
#include <sys/param.h>
#include <sys/types.h>
@@ -155,9 +157,10 @@ usage(void)
* This isn't mentioned in the man page, or the usage statement,
* but it is supported.
*/
- fprintf(stderr, "usage: iostat [-CdhIKoT?] [-c count] [-M core]"
- " [-n devs] [-N system]\n"
- "\t [-t type,if,pass] [-w wait] [drives]\n");
+ fprintf(stderr, "%s\n%s\n",
+ "usage: iostat [-CdhIKoT] [-c count] [-M core] [-n devs] [-N system]",
+ " [-t type,if,pass] [-w wait] [drives]");
+ exit(1);
}
int
@@ -171,7 +174,6 @@ main(int argc, char **argv)
struct devstat_match *matches;
int num_matches = 0;
char errbuf[_POSIX2_LINE_MAX];
- char *err_str;
kvm_t *kd;
int hz, stathz;
int headercount;
@@ -185,7 +187,7 @@ main(int argc, char **argv)
matches = NULL;
maxshowdevs = 3;
- while ((c = getopt(argc, argv, "c:CdhIKM:n:N:ot:Tw:?")) != -1) {
+ while ((c = getopt(argc, argv, "c:CdhIKM:n:N:ot:Tw:")) != -1) {
switch(c) {
case 'c':
cflag++;
@@ -215,7 +217,7 @@ main(int argc, char **argv)
nflag++;
maxshowdevs = atoi(optarg);
if (maxshowdevs < 0)
- errx(1, "number of devcies %d is < 0",
+ errx(1, "number of devices %d is < 0",
maxshowdevs);
break;
case 'N':
@@ -239,9 +241,9 @@ main(int argc, char **argv)
if (waittime < 1)
errx(1, "wait time is < 1");
break;
+ case '?':
default:
usage();
- exit(1);
break;
}
}
@@ -288,7 +290,11 @@ main(int argc, char **argv)
err(1, "can't get number of devices");
cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
+ if (cur.dinfo == NULL)
+ errx(1, "malloc failed");
last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
+ if (last.dinfo == NULL)
+ errx(1, "malloc failed");
bzero(cur.dinfo, sizeof(struct devinfo));
bzero(last.dinfo, sizeof(struct devinfo));
@@ -308,6 +314,8 @@ main(int argc, char **argv)
* they are in the list of devices we have now.
*/
specified_devices = (char **)malloc(sizeof(char *));
+ if (specified_devices == NULL)
+ errx(1, "malloc failed");
for (num_devices_specified = 0; *argv; ++argv) {
if (isdigit(**argv))
break;
@@ -315,6 +323,8 @@ main(int argc, char **argv)
specified_devices = (char **)realloc(specified_devices,
sizeof(char *) *
num_devices_specified);
+ if (specified_devices == NULL)
+ errx(1, "malloc failed");
specified_devices[num_devices_specified - 1] = *argv;
}
OpenPOWER on IntegriCloud