Use nitems() from sys/param.h.
MFC after: 2 weeks.
This commit is contained in:
parent
bf092a3d6f
commit
c52ee6c23b
@ -213,14 +213,12 @@ geticmptypebynumber(u_int8_t type, sa_family_t af)
|
||||
unsigned int i;
|
||||
|
||||
if (af != AF_INET6) {
|
||||
for (i=0; i < (sizeof (icmp_type) / sizeof(icmp_type[0]));
|
||||
i++) {
|
||||
for (i=0; i < nitems(icmp_type); i++) {
|
||||
if (type == icmp_type[i].type)
|
||||
return (&icmp_type[i]);
|
||||
}
|
||||
} else {
|
||||
for (i=0; i < (sizeof (icmp6_type) /
|
||||
sizeof(icmp6_type[0])); i++) {
|
||||
for (i=0; i < nitems(icmp6_type); i++) {
|
||||
if (type == icmp6_type[i].type)
|
||||
return (&icmp6_type[i]);
|
||||
}
|
||||
@ -234,14 +232,12 @@ geticmptypebyname(char *w, sa_family_t af)
|
||||
unsigned int i;
|
||||
|
||||
if (af != AF_INET6) {
|
||||
for (i=0; i < (sizeof (icmp_type) / sizeof(icmp_type[0]));
|
||||
i++) {
|
||||
for (i=0; i < nitems(icmp_type); i++) {
|
||||
if (!strcmp(w, icmp_type[i].name))
|
||||
return (&icmp_type[i]);
|
||||
}
|
||||
} else {
|
||||
for (i=0; i < (sizeof (icmp6_type) /
|
||||
sizeof(icmp6_type[0])); i++) {
|
||||
for (i=0; i < nitems(icmp6_type); i++) {
|
||||
if (!strcmp(w, icmp6_type[i].name))
|
||||
return (&icmp6_type[i]);
|
||||
}
|
||||
@ -255,15 +251,13 @@ geticmpcodebynumber(u_int8_t type, u_int8_t code, sa_family_t af)
|
||||
unsigned int i;
|
||||
|
||||
if (af != AF_INET6) {
|
||||
for (i=0; i < (sizeof (icmp_code) / sizeof(icmp_code[0]));
|
||||
i++) {
|
||||
for (i=0; i < nitems(icmp_code); i++) {
|
||||
if (type == icmp_code[i].type &&
|
||||
code == icmp_code[i].code)
|
||||
return (&icmp_code[i]);
|
||||
}
|
||||
} else {
|
||||
for (i=0; i < (sizeof (icmp6_code) /
|
||||
sizeof(icmp6_code[0])); i++) {
|
||||
for (i=0; i < nitems(icmp6_code); i++) {
|
||||
if (type == icmp6_code[i].type &&
|
||||
code == icmp6_code[i].code)
|
||||
return (&icmp6_code[i]);
|
||||
@ -278,15 +272,13 @@ geticmpcodebyname(u_long type, char *w, sa_family_t af)
|
||||
unsigned int i;
|
||||
|
||||
if (af != AF_INET6) {
|
||||
for (i=0; i < (sizeof (icmp_code) / sizeof(icmp_code[0]));
|
||||
i++) {
|
||||
for (i=0; i < nitems(icmp_code); i++) {
|
||||
if (type == icmp_code[i].type &&
|
||||
!strcmp(w, icmp_code[i].name))
|
||||
return (&icmp_code[i]);
|
||||
}
|
||||
} else {
|
||||
for (i=0; i < (sizeof (icmp6_code) /
|
||||
sizeof(icmp6_code[0])); i++) {
|
||||
for (i=0; i < nitems(icmp6_code); i++) {
|
||||
if (type == icmp6_code[i].type &&
|
||||
!strcmp(w, icmp6_code[i].name))
|
||||
return (&icmp6_code[i]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user