Use nitems() from sys/param.h.

Sponsored by:	gandi.net (BSD Day Taiwan)
This commit is contained in:
araujo 2016-07-30 06:19:34 +00:00
parent cedf419a7b
commit b81bbb0799

View File

@ -898,7 +898,7 @@ CMDFUNCSTART(newtype)
return 1;
type = DIP(curinode, di_mode) & IFMT;
for (tp = typenamemap;
tp < &typenamemap[sizeof(typenamemap)/sizeof(*typenamemap)];
tp < &typenamemap[nitems(typenamemap)];
tp++) {
if (!strcmp(argv[1], tp->typename)) {
printf("setting type to %s\n", tp->typename);
@ -906,7 +906,7 @@ CMDFUNCSTART(newtype)
break;
}
}
if (tp == &typenamemap[sizeof(typenamemap)/sizeof(*typenamemap)]) {
if (tp == &typenamemap[nitems(typenamemap)]) {
warnx("type `%s' not known", argv[1]);
warnx("try one of `file', `dir', `socket', `fifo'");
return 1;