The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=70fad8acae7324525df09b46e3ee2007f3ecf0fe

commit 70fad8acae7324525df09b46e3ee2007f3ecf0fe
Author:     Elyes Haouas <ehao...@noos.fr>
AuthorDate: 2023-11-07 17:38:03 +0000
Commit:     Warner Losh <i...@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 <ehao...@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);
        }

Reply via email to