summaryrefslogtreecommitdiffstats
path: root/lib/libc/net
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-16 17:52:00 +0000
committerpfg <pfg@FreeBSD.org>2016-04-16 17:52:00 +0000
commit282f928dc777faf3cee67a648bb770bbd54276d0 (patch)
tree9591d290a7b32152d9fdda623974bad433ef861f /lib/libc/net
parentd758bd7be40b8aeb4b09c640dd54153bfe5592ca (diff)
downloadFreeBSD-src-282f928dc777faf3cee67a648bb770bbd54276d0.zip
FreeBSD-src-282f928dc777faf3cee67a648bb770bbd54276d0.tar.gz
libc: make some more use of the nitems() macro.
We have an nitems() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read. Given that it is available already without adding additional headers and other parts of libc already use it, extend a bit more its use.
Diffstat (limited to 'lib/libc/net')
-rw-r--r--lib/libc/net/getaddrinfo.c6
-rw-r--r--lib/libc/net/name6.c4
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index e2eb1a0..88a172c 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -398,7 +398,7 @@ getaddrinfo(const char *hostname, const char *servname,
struct addrinfo *pai;
const struct afd *afd;
const struct explore *ex;
- struct addrinfo *afailist[sizeof(afdl)/sizeof(afdl[0])];
+ struct addrinfo *afailist[nitems(afdl)];
struct addrinfo *afai_unspec;
int found;
int numeric = 0;
@@ -736,13 +736,13 @@ get_addrselectpolicy(struct policyhead *head)
char *buf;
struct in6_addrpolicy *pol, *ep;
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0)
+ if (sysctl(mib, nitems(mib), NULL, &l, NULL, 0) < 0)
return (0);
if (l == 0)
return (0);
if ((buf = malloc(l)) == NULL)
return (0);
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
+ if (sysctl(mib, nitems(mib), buf, &l, NULL, 0) < 0) {
free(buf);
return (0);
}
diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c
index 51e2da15..1d37329 100644
--- a/lib/libc/net/name6.c
+++ b/lib/libc/net/name6.c
@@ -735,11 +735,11 @@ get_addrselectpolicy(struct policyhead *head)
char *buf;
struct in6_addrpolicy *pol, *ep;
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0)
+ if (sysctl(mib, nitems(mib), NULL, &l, NULL, 0) < 0)
return (0);
if ((buf = malloc(l)) == NULL)
return (0);
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
+ if (sysctl(mib, nitems(mib), buf, &l, NULL, 0) < 0) {
free(buf);
return (0);
}
OpenPOWER on IntegriCloud