Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Apr 2024 04:27:14 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: d1d652c06015 - main - rtadvctl: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Message-ID:  <202404290427.43T4RE3A044533@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=d1d652c060150985e1e580eb57b4b6829f6845c9

commit d1d652c060150985e1e580eb57b4b6829f6845c9
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

    rtadvctl: 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/rtadvctl/rtadvctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/rtadvctl/rtadvctl.c b/usr.sbin/rtadvctl/rtadvctl.c
index 727fa6ee1a52..9fdb643cef10 100644
--- a/usr.sbin/rtadvctl/rtadvctl.c
+++ b/usr.sbin/rtadvctl/rtadvctl.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>
@@ -137,7 +137,7 @@ usage(void)
 {
 	int i;
 
-	for (i = 0; (size_t)i < sizeof(dtable)/sizeof(dtable[0]); i++) {
+	for (i = 0; (size_t)i < nitems(dtable); i++) {
 		if (dtable[i].dt_comm == NULL)
 			break;
 		printf("%s\n", dtable[i].dt_comm);
@@ -172,7 +172,7 @@ main(int argc, char *argv[])
 	if (argc == 0)
 		usage();
 
-	for (i = 0; (size_t)i < sizeof(dtable)/sizeof(dtable[0]); i++) {
+	for (i = 0; (size_t)i < nitems(dtable); i++) {
 		if (dtable[i].dt_comm == NULL ||
 		    strcmp(dtable[i].dt_comm, argv[0]) == 0) {
 			action = dtable[i].dt_act;



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