1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

ipfw: 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:36:35 +01:00 committed by Warner Losh
parent b561d8f59c
commit c3c816173d
2 changed files with 4 additions and 4 deletions

View File

@ -22,7 +22,7 @@
#define NEW_AQM
#include <sys/limits.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
/* XXX there are several sysctl leftover here */
#include <sys/sysctl.h>
@ -1401,7 +1401,7 @@ ipfw_config_pipe(int ac, char **av)
*/
if (p)
p->bandwidth = -1;
for (j = 0; j < sizeof(fs->par)/sizeof(fs->par[0]); j++)
for (j = 0; j < nitems(fs->par); j++)
fs->par[j] = -1;
while (ac > 0) {
double d;

View File

@ -4035,8 +4035,8 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
rblen = *rbufsize / sizeof(uint32_t);
rblen -= sizeof(struct ip_fw_rule) / sizeof(uint32_t);
ablen = sizeof(actbuf) / sizeof(actbuf[0]);
cblen = sizeof(cmdbuf) / sizeof(cmdbuf[0]);
ablen = nitems(actbuf);
cblen = nitems(cmdbuf);
cblen -= F_INSN_SIZE(ipfw_insn_u32) + 1;
#define CHECK_RBUFLEN(len) { CHECK_LENGTH(rblen, len); rblen -= len; }