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>
This commit is contained in:
Elyes Haouas 2024-04-28 20:55:30 -06:00 committed by Warner Losh
parent fdbf7cab91
commit 93e96d6c87
4 changed files with 7 additions and 7 deletions

View File

@ -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)

View File

@ -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));

View File

@ -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,

View File

@ -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) {