Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Apr 2024 04:27:12 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 93e96d6c87dc - main - rtadvd: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Message-ID:  <202404290427.43T4RCbx044488@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=93e96d6c87dc8dd84cdfc56a155dc0611f55ac86

commit 93e96d6c87dc8dd84cdfc56a155dc0611f55ac86
Author:     Elyes Haouas <ehaouas@noos.fr>
AuthorDate: 2024-04-29 02:55:30 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-04-29 03:24:46 +0000

    rtadvd: 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>
---
 usr.sbin/rtadvd/control.c        | 6 +++---
 usr.sbin/rtadvd/control_server.c | 4 ++--
 usr.sbin/rtadvd/if.c             | 2 +-
 usr.sbin/rtadvd/rtadvd.c         | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/usr.sbin/rtadvd/control.c b/usr.sbin/rtadvd/control.c
index 80af6371a269..54a944833f64 100644
--- a/usr.sbin/rtadvd/control.c
+++ b/usr.sbin/rtadvd/control.c
@@ -27,8 +27,8 @@
  *
  */
 
+#include <sys/param.h>
 #include <sys/queue.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/un.h>
@@ -75,7 +75,7 @@ cm_recv(int fd, char *buf)
 	pfds[0].events = POLLIN;
 
 	for (;;) {
-		i = poll(pfds, sizeof(pfds)/sizeof(pfds[0]),
+		i = poll(pfds, nitems(pfds),
 		    CM_RECV_TIMEOUT);
 
 		if (i == 0)
@@ -131,7 +131,7 @@ cm_recv(int fd, char *buf)
 		    msglen);
 
 		for (;;) {
-			i = poll(pfds, sizeof(pfds)/sizeof(pfds[0]),
+			i = poll(pfds, nitems(pfds),
 			    CM_RECV_TIMEOUT);
 
 			if (i == 0)
diff --git a/usr.sbin/rtadvd/control_server.c b/usr.sbin/rtadvd/control_server.c
index e96a1958dd10..60fdc5ca2ec0 100644
--- a/usr.sbin/rtadvd/control_server.c
+++ b/usr.sbin/rtadvd/control_server.c
@@ -27,8 +27,8 @@
  *
  */
 
+#include <sys/param.h>
 #include <sys/queue.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/un.h>
@@ -527,7 +527,7 @@ cm_getprop(struct ctrl_msg_pl *cp)
 		return (1);
 
 	for (i = 0;
-	     i < sizeof(getprop_dtable) / sizeof(getprop_dtable[0]);
+	     i < nitems(getprop_dtable);
 	     i++) {
 		if (strcmp(cp->cp_key, getprop_dtable[i].dt_comm) == 0)
 			return (getprop_dtable[i].dt_act(cp));
diff --git a/usr.sbin/rtadvd/if.c b/usr.sbin/rtadvd/if.c
index 6212639ba028..e1702a0aa72a 100644
--- a/usr.sbin/rtadvd/if.c
+++ b/usr.sbin/rtadvd/if.c
@@ -642,7 +642,7 @@ getinet6sysctl(int code)
 
 	mib[3] = code;
 	size = sizeof(value);
-	if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &value, &size, NULL, 0)
+	if (sysctl(mib, nitems(mib), &value, &size, NULL, 0)
 	    < 0) {
 		syslog(LOG_ERR, "<%s>: failed to get ip6 sysctl(%d): %s",
 		    __func__, code,
diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c
index aa9038b65e63..fa5640afa96c 100644
--- a/usr.sbin/rtadvd/rtadvd.c
+++ b/usr.sbin/rtadvd/rtadvd.c
@@ -328,7 +328,7 @@ main(int argc, char *argv[])
 			    "<%s> there's no timer. waiting for inputs",
 			    __func__);
 		}
-		if ((i = poll(set, sizeof(set)/sizeof(set[0]),
+		if ((i = poll(set, nitems(set),
 			    timeout ? (timeout->tv_sec * 1000 +
 				timeout->tv_nsec / 1000 / 1000) : INFTIM)) < 0) {
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404290427.43T4RCbx044488>