diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2006-07-27 04:53:28 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2006-07-27 04:53:28 +0000 |
commit | 463022a1f7e1d150df7527f395eb87e9c2dbc54a (patch) | |
tree | 6334fd3446160fd8adb24ecf1fc28efeb2e6fbfa /sbin/fdisk | |
parent | ea38d861cae80b6be161a068a5d5dac6f743d30a (diff) |
Change some obvious atoi() to strtonum().
OK tedu@
Diffstat (limited to 'sbin/fdisk')
-rw-r--r-- | sbin/fdisk/fdisk.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index 7a0aa9ef10a..dc3d25dd8c6 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdisk.c,v 1.42 2006/07/27 04:06:13 ray Exp $ */ +/* $OpenBSD: fdisk.c,v 1.43 2006/07/27 04:53:27 ray Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -77,6 +77,8 @@ main(int argc, char *argv[]) char mbr_buf[DEV_BSIZE]; while ((ch = getopt(argc, argv, "ieuf:c:h:s:")) != -1) { + const char *errstr; + switch(ch) { case 'i': i_flag = 1; @@ -91,22 +93,20 @@ main(int argc, char *argv[]) mbrfile = optarg; break; case 'c': - c_arg = atoi(optarg); - if (c_arg < 1 || c_arg > 262144) - errx(1, "Cylinder argument out of range " - "[1..262144]."); + c_arg = strtonum(optarg, 1, 262144, &errstr); + if (errstr) + errx(1, "Cylinder argument %s [1..262144].", + errstr); break; case 'h': - h_arg = atoi(optarg); - if (h_arg < 1 || h_arg > 256) - errx(1, "Head argument out of range " - "[1..256]."); + h_arg = strtonum(optarg, 1, 256, &errstr); + if (errstr) + errx(1, "Head argument %s [1..256].", errstr); break; case 's': - s_arg = atoi(optarg); - if (s_arg < 1 || s_arg > 63) - errx(1, "Sector argument out of range " - "[1..63]."); + s_arg = strtonum(optarg, 1, 63, &errstr); + if (errstr) + errx(1, "Sector argument %s [1..63].", errstr); break; default: usage(); |