Use nitems() from sys/param.h.

MFC after:	2 weeks.
This commit is contained in:
araujo 2016-04-19 04:42:34 +00:00
parent a03092e883
commit 42055d55ae
2 changed files with 4 additions and 7 deletions

View File

@ -185,22 +185,19 @@ bridge_interfaces(int s, const char *prefix)
printf(" path cost %u", req->ifbr_path_cost);
if (req->ifbr_ifsflags & IFBIF_STP) {
if (req->ifbr_proto <
sizeof(stpproto) / sizeof(stpproto[0]))
if (req->ifbr_proto < nitems(stpproto))
printf(" proto %s", stpproto[req->ifbr_proto]);
else
printf(" <unknown proto %d>",
req->ifbr_proto);
printf("\n%s", pad);
if (req->ifbr_role <
sizeof(stproles) / sizeof(stproles[0]))
if (req->ifbr_role < nitems(stproles))
printf("role %s", stproles[req->ifbr_role]);
else
printf("<unknown role %d>",
req->ifbr_role);
if (req->ifbr_state <
sizeof(stpstates) / sizeof(stpstates[0]))
if (req->ifbr_state < nitems(stpstates))
printf(" state %s", stpstates[req->ifbr_state]);
else
printf(" <unknown state %d>",

View File

@ -291,7 +291,7 @@ lagg_status(int s)
if (0 /* XXX */) {
printf("\tsupported aggregation protocols:\n");
for (i = 0; i < (sizeof(lpr) / sizeof(lpr[0])); i++)
for (i = 0; i < nitems(lpr); i++)
printf("\t\tlaggproto %s\n", lpr[i].lpr_name);
}
}