Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Apr 2024 04:27:30 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: 70fad8acae73 - main - ipf: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Message-ID:  <202404290427.43T4RUvB045236@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=70fad8acae7324525df09b46e3ee2007f3ecf0fe

commit 70fad8acae7324525df09b46e3ee2007f3ecf0fe
Author:     Elyes Haouas <ehaouas@noos.fr>
AuthorDate: 2023-11-07 17:38:03 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-04-29 04:21:09 +0000

    ipf: 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>
---
 sbin/ipf/common/lexer.c  | 5 +++--
 sbin/ipf/libipf/facpri.c | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/sbin/ipf/common/lexer.c b/sbin/ipf/common/lexer.c
index 5a898c72032d..d1980765ef93 100644
--- a/sbin/ipf/common/lexer.c
+++ b/sbin/ipf/common/lexer.c
@@ -10,6 +10,7 @@
 # include "netinet/ip_scan.h"
 #endif
 #include <sys/ioctl.h>
+#include <sys/param.h>
 #include <syslog.h>
 #ifdef	TEST_LEXER
 # define	NO_YACC
@@ -675,7 +676,7 @@ yysetfixeddict(wordtab_t *newdict)
 	if (yydebug)
 		printf("yysetfixeddict(%lx)\n", (u_long)newdict);
 
-	if (yysavedepth == sizeof(yysavewords)/sizeof(yysavewords[0])) {
+	if (yysavedepth == nitems(yysavewords)) {
 		fprintf(stderr, "%d: at maximum dictionary depth\n",
 			yylineNum);
 		return;
@@ -694,7 +695,7 @@ yysetdict(wordtab_t *newdict)
 	if (yydebug)
 		printf("yysetdict(%lx)\n", (u_long)newdict);
 
-	if (yysavedepth == sizeof(yysavewords)/sizeof(yysavewords[0])) {
+	if (yysavedepth == nitems(yysavewords)) {
 		fprintf(stderr, "%d: at maximum dictionary depth\n",
 			yylineNum);
 		return;
diff --git a/sbin/ipf/libipf/facpri.c b/sbin/ipf/libipf/facpri.c
index 9f66cedc7df5..9325a03c8dc3 100644
--- a/sbin/ipf/libipf/facpri.c
+++ b/sbin/ipf/libipf/facpri.c
@@ -10,7 +10,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <limits.h>
-#include <sys/types.h>
+#include <sys/param.h>
 #if !defined(__SVR4) && !defined(__svr4__)
 #include <strings.h>
 #endif
@@ -76,7 +76,7 @@ fac_toname(int facpri)
 
 	fac = facpri & LOG_FACMASK;
 	j = fac >> 3;
-	if (j < (sizeof(facs)/sizeof(facs[0]))) {
+	if (j < nitems(facs)) {
 		if (facs[j].value == fac)
 			return (facs[j].name);
 	}



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