diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-04-26 02:32:42 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-04-26 02:32:42 +0000 |
commit | eb302be1b8e5764c05c46152fab25ba493c9d3b2 (patch) | |
tree | 036a2a8cac6694cafe75d3690e88efb8ea1410a4 /usr.bin | |
parent | 8e2bdef6dc9b0f4d93dd996ecdc328f333ee798f (diff) |
merge parts of strtonum() cleanup from tan.dang@gmail.com
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/lock/lock.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c index b37569b2ae1..e4d7f79cc35 100644 --- a/usr.bin/lock/lock.c +++ b/usr.bin/lock/lock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lock.c,v 1.21 2005/07/14 14:42:28 jmc Exp $ */ +/* $OpenBSD: lock.c,v 1.22 2006/04/26 02:32:41 deraadt Exp $ */ /* $NetBSD: lock.c,v 1.8 1996/05/07 18:32:31 jtc Exp $ */ /* @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)lock.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: lock.c,v 1.21 2005/07/14 14:42:28 jmc Exp $"; +static char rcsid[] = "$OpenBSD: lock.c,v 1.22 2006/04/26 02:32:41 deraadt Exp $"; #endif /* not lint */ /* @@ -92,6 +92,7 @@ main(int argc, char *argv[]) char *p, *style, *nstyle, *ttynam; struct itimerval ntimer, otimer; int ch, sectimeout, usemine; + const char *errstr; struct passwd *pw; struct tm *timp; time_t curtime; @@ -120,8 +121,9 @@ main(int argc, char *argv[]) usemine = 1; break; case 't': - if ((sectimeout = atoi(optarg)) <= 0) - errx(1, "illegal timeout value: %s", optarg); + sectimeout = strtonum(optarg, 1, INT_MAX, &errstr); + if (errstr) + errx(1, "timeout %s: %s", errstr, optarg); break; case 'p': usemine = 1; @@ -129,7 +131,6 @@ main(int argc, char *argv[]) case 'n': no_timeout = 1; break; - case '?': default: (void)fprintf(stderr, "usage: %s [-np] [-a style] [-t timeout]\n", |