summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2006-04-02 18:31:56 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2006-04-02 18:31:56 +0000
commit243fe6257fd9d75a6d920a7e5d08da309a512190 (patch)
tree1f47611722134f8a061129f51b04c1975acaf33a /lib
parent0cf0e1b2af1052634bc3b0d5ed817cc78cfd2040 (diff)
kill atoi(), correct signedness of internal API gettype(); ok a few people
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/disklabel.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libc/gen/disklabel.c b/lib/libc/gen/disklabel.c
index 818b482d4f3..ad1acab9899 100644
--- a/lib/libc/gen/disklabel.c
+++ b/lib/libc/gen/disklabel.c
@@ -37,10 +37,11 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include <string.h>
#include <unistd.h>
-static int gettype(char *, char **);
+static u_int gettype(char *, char **);
struct disklabel *
getdiskbyname(const char *name)
@@ -92,7 +93,7 @@ getdiskbyname(const char *name)
getnum(dp->d_ncylinders, "nc");
if (cgetstr(buf, "dt", &cq) > 0)
- dp->d_type = gettype(cq, dktypenames);
+ dp->d_type = (u_short)gettype(cq, dktypenames);
else
getnumdflt(dp->d_type, "dt", 0);
getnumdflt(dp->d_secpercyl, "sc", dp->d_nsectors * dp->d_ntracks);
@@ -132,7 +133,7 @@ getdiskbyname(const char *name)
}
getnumdflt(pp->p_fstype, ptype, 0);
if (pp->p_fstype == 0 && cgetstr(buf, ptype, &cq) > 0)
- pp->p_fstype = gettype(cq, fstypenames);
+ pp->p_fstype = (u_char)gettype(cq, fstypenames);
max = p;
}
}
@@ -149,7 +150,7 @@ getdiskbyname(const char *name)
return (dp);
}
-static int
+static u_int
gettype(char *t, char **names)
{
char **nm;
@@ -158,6 +159,6 @@ gettype(char *t, char **names)
if (strcasecmp(t, *nm) == 0)
return (nm - names);
if (isdigit((u_char)*t))
- return (atoi(t));
+ return ((u_int)strtonum(t, 0, USHRT_MAX, NULL));
return (0);
}