summaryrefslogtreecommitdiff
path: root/sbin/dump/main.c
diff options
context:
space:
mode:
authorMoritz Jodeit <moritz@cvs.openbsd.org>2005-05-24 21:28:51 +0000
committerMoritz Jodeit <moritz@cvs.openbsd.org>2005-05-24 21:28:51 +0000
commit5a2b580af86f59261812204415f88a0416bea538 (patch)
tree901e5fdec1c9fa5a7a5ead23ac1eca2d42835b3e /sbin/dump/main.c
parent76b52d8b51de53cd7a2af974d3d71b793ca66973 (diff)
fix minor ouput glitch, by using strtonum instead of strtol.
ok millert@
Diffstat (limited to 'sbin/dump/main.c')
-rw-r--r--sbin/dump/main.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index 8b658aca1c6..37bb79c0d79 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.37 2004/11/04 20:10:07 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.38 2005/05/24 21:28:50 moritz Exp $ */
/* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */
/*-
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 4/15/94";
#else
-static const char rcsid[] = "$OpenBSD: main.c,v 1.37 2004/11/04 20:10:07 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: main.c,v 1.38 2005/05/24 21:28:50 moritz Exp $";
#endif
#endif /* not lint */
@@ -573,14 +573,16 @@ usage(void)
static long
numarg(char *meaning, long vmin, long vmax)
{
- char *p;
long val;
+ const char *errstr;
+
+ if (vmax == 0)
+ vmax = LONG_MAX;
+ val = strtonum(optarg, vmin, vmax, &errstr);
+ if (errstr)
+ errx(X_STARTUP, "%s is %s [%ld - %ld]",
+ meaning, errstr, vmin, vmax);
- val = strtol(optarg, &p, 10);
- if (*p)
- errx(X_STARTUP, "illegal %s -- %s", meaning, optarg);
- if (val < vmin || (vmax && val > vmax))
- errx(X_STARTUP, "%s must be between %ld and %ld", meaning, vmin, vmax);
return (val);
}