diff options
author | Eric Jackson <ericj@cvs.openbsd.org> | 2002-01-08 17:16:39 +0000 |
---|---|---|
committer | Eric Jackson <ericj@cvs.openbsd.org> | 2002-01-08 17:16:39 +0000 |
commit | 8d08a266cf5f857d030ffb88b11b86471c25ebe0 (patch) | |
tree | 54ac83131045e9eca1fe60e84cb48399d3fe4741 /usr.bin | |
parent | f166b7b2ad149ec44be4fcbc48c8693b54386bee (diff) |
atoi->strtoul
also, sbuf.private is a long
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/modstat/modstat.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/modstat/modstat.c b/usr.bin/modstat/modstat.c index 113c2b3c5d2..8f2f1c9c620 100644 --- a/usr.bin/modstat/modstat.c +++ b/usr.bin/modstat/modstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modstat.c,v 1.15 2002/01/08 04:59:24 ericj Exp $ */ +/* $OpenBSD: modstat.c,v 1.16 2002/01/08 17:16:38 ericj Exp $ */ /* * Copyright (c) 1993 Terrence R. Lambert. @@ -58,6 +58,7 @@ static char *type_names[] = { "EXEC", "MISC" }; +static int devfd; static void usage() @@ -98,7 +99,7 @@ dostat(int devfd, int modnum, char *modname) } /* Decode this stat buffer... */ - printf("%-7s %3d %3ld %0*lx %04lx %0*x %3ld %s\n", + printf("%-7s %3d %3ld %0*lx %04lx %0*lx %3ld %s\n", type_names[sbuf.type], sbuf.id, sbuf.offset, POINTERSIZE, (long)sbuf.area, (long)sbuf.size, POINTERSIZE, (long)sbuf.private, (long)sbuf.ver, sbuf.name); @@ -106,8 +107,6 @@ dostat(int devfd, int modnum, char *modname) return 0; } -int devfd; - int main(argc, argv) int argc; @@ -115,15 +114,19 @@ main(argc, argv) { int c, modnum = -1; char *modname = NULL; + char *endptr; while ((c = getopt(argc, argv, "i:n:")) != -1) { switch (c) { case 'i': + modnum = (int)strtol(optarg, &endptr, 0); + if (modnum < 0 || modnum > INT_MAX || *endptr != '\0') + errx(1, "%s: not a valid number", optarg); modnum = atoi(optarg); - break; /* number */ + break; case 'n': modname = optarg; - break; /* name */ + break; default: usage(); break; |