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>
This commit is contained in:
Elyes Haouas 2023-11-07 18:38:03 +01:00 committed by Warner Losh
parent 7028e630d6
commit 70fad8acae
2 changed files with 5 additions and 4 deletions

View file

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

View file

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