git: 635037210ea3 - stable/14 - ndp: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Tue, 10 Sep 2024 10:02:47 UTC
The branch stable/14 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=635037210ea3e644c9d76b9627323f5ddf5dc5f5

commit 635037210ea3e644c9d76b9627323f5ddf5dc5f5
Author:     Elyes Haouas <ehaouas@noos.fr>
AuthorDate: 2023-11-07 17:13:02 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-09-10 10:01:48 +0000

    ndp: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
    
    Pull Request: https://github.com/freebsd/freebsd-src/pull/888
    Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
    
    (cherry picked from commit bccbb2fc4bce6c3efc1ba93f222de320db8e020a)
---
 usr.sbin/ndp/ndp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index 4f7c32f0fdf7..56c86e447cd5 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -1166,7 +1166,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*/
 	}
@@ -1177,7 +1177,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*/
 	}
@@ -1252,7 +1252,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*/
 	}
@@ -1261,7 +1261,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*/
 	}