Skip to content

Commit

Permalink
ndp: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Browse files Browse the repository at this point in the history
Pull Request: #888
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
  • Loading branch information
ElyesH authored and bsdimp committed Apr 29, 2024
1 parent 83409a9 commit bccbb2f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions usr.sbin/ndp/ndp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ rtrlist(void)
size_t l;
struct timeval now;

if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
if (sysctl(mib, nitems(mib), NULL, &l, NULL, 0) < 0) {
xo_err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
/*NOTREACHED*/
}
Expand All @@ -1182,7 +1182,7 @@ rtrlist(void)
xo_err(1, "malloc");
/*NOTREACHED*/
}
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
if (sysctl(mib, nitems(mib), buf, &l, NULL, 0) < 0) {
xo_err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
/*NOTREACHED*/
}
Expand Down Expand Up @@ -1257,7 +1257,7 @@ plist(void)
int ninflags = opts.nflag ? NI_NUMERICHOST : 0;
char namebuf[NI_MAXHOST];

if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
if (sysctl(mib, nitems(mib), NULL, &l, NULL, 0) < 0) {
xo_err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
/*NOTREACHED*/
}
Expand All @@ -1266,7 +1266,7 @@ plist(void)
xo_err(1, "malloc");
/*NOTREACHED*/
}
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
if (sysctl(mib, nitems(mib), buf, &l, NULL, 0) < 0) {
xo_err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
/*NOTREACHED*/
}
Expand Down

0 comments on commit bccbb2f

Please sign in to comment.