diff options
author | araujo <araujo@FreeBSD.org> | 2016-04-19 06:32:35 +0000 |
---|---|---|
committer | araujo <araujo@FreeBSD.org> | 2016-04-19 06:32:35 +0000 |
commit | fd1c51c97be1b9f86fbbecec6ead896e73a35280 (patch) | |
tree | d9b17ec3f4b1c0a6d9681558ca38ab20ea9b6c28 | |
parent | 27483b14411b7e6478fabc678c524c5c50147981 (diff) | |
download | FreeBSD-src-fd1c51c97be1b9f86fbbecec6ead896e73a35280.zip FreeBSD-src-fd1c51c97be1b9f86fbbecec6ead896e73a35280.tar.gz |
Use nitems() from sys/param.h.
MFC after: 2 weeks.
-rw-r--r-- | sbin/pfctl/pfctl_parser.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 2b553ce..22db5ca 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -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]); |