summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-21 15:38:28 +0000
committerpfg <pfg@FreeBSD.org>2016-04-21 15:38:28 +0000
commitfc65edc1cd05de15ef17e14dc54c2bf6c41ccab8 (patch)
tree45622d9ce5a6c394316a37f672cfd0a033c48374
parentfdf39652a42767663d4a74a1a367d193185c51e9 (diff)
downloadFreeBSD-src-fc65edc1cd05de15ef17e14dc54c2bf6c41ccab8.zip
FreeBSD-src-fc65edc1cd05de15ef17e14dc54c2bf6c41ccab8.tar.gz
Remove slightly used const values that can be replaced with nitems().
Suggested by: jhb
-rw-r--r--sys/cam/ata/ata_xpt.c7
-rw-r--r--sys/cam/cam.c5
-rw-r--r--sys/cam/scsi/scsi_all.c7
-rw-r--r--sys/dev/advansys/adw_pci.c5
-rw-r--r--sys/dev/advansys/adwlib.c6
-rw-r--r--sys/dev/hwpmc/hwpmc_core.c6
-rw-r--r--sys/dev/hwpmc/hwpmc_mpc7xxx.c7
-rw-r--r--sys/dev/hwpmc/hwpmc_uncore.c6
-rw-r--r--sys/dev/hwpmc/hwpmc_xscale.c7
-rw-r--r--sys/dev/pccard/pccard_cis_quirks.c5
-rw-r--r--sys/dev/sge/if_sge.c5
-rw-r--r--sys/dev/sound/pci/emu10kx.c7
-rw-r--r--sys/dev/uart/uart_subr.c3
-rw-r--r--sys/kern/subr_witness.c3
-rw-r--r--sys/mips/nlm/xlp_machdep.c3
-rw-r--r--sys/net/netisr.c6
-rw-r--r--sys/netgraph/bluetooth/socket/ng_btsocket.c5
-rw-r--r--sys/nlm/nlm_prot_impl.c3
-rw-r--r--sys/security/audit/audit_bsm_klib.c6
-rw-r--r--sys/security/audit/bsm_errno.c5
-rw-r--r--sys/vm/vm_pager.c4
21 files changed, 34 insertions, 77 deletions
diff --git a/sys/cam/ata/ata_xpt.c b/sys/cam/ata/ata_xpt.c
index 3429bb29a6..3dab055 100644
--- a/sys/cam/ata/ata_xpt.c
+++ b/sys/cam/ata/ata_xpt.c
@@ -160,9 +160,6 @@ static struct ata_quirk_entry ata_quirk_table[] =
},
};
-static const int ata_quirk_table_size =
- sizeof(ata_quirk_table) / sizeof(*ata_quirk_table);
-
static cam_status proberegister(struct cam_periph *periph,
void *arg);
static void probeschedule(struct cam_periph *probe_periph);
@@ -1284,7 +1281,7 @@ ata_find_quirk(struct cam_ed *device)
match = cam_quirkmatch((caddr_t)&device->ident_data,
(caddr_t)ata_quirk_table,
- ata_quirk_table_size,
+ nitems(ata_quirk_table),
sizeof(*ata_quirk_table), ata_identify_match);
if (match == NULL)
@@ -1579,7 +1576,7 @@ ata_alloc_device(struct cam_eb *bus, struct cam_et *target, lun_id_t lun_id)
* Take the default quirk entry until we have inquiry
* data and can determine a better quirk to use.
*/
- quirk = &ata_quirk_table[ata_quirk_table_size - 1];
+ quirk = &ata_quirk_table[nitems(ata_quirk_table) - 1];
device->quirk = (void *)quirk;
device->mintags = 0;
device->maxtags = 0;
diff --git a/sys/cam/cam.c b/sys/cam/cam.c
index 5061dd6..7105a41 100644
--- a/sys/cam/cam.c
+++ b/sys/cam/cam.c
@@ -105,9 +105,6 @@ const struct cam_status_entry cam_status_table[] = {
{ CAM_SCSI_BUSY, "SCSI Bus Busy" },
};
-const int num_cam_status_entries =
- sizeof(cam_status_table)/sizeof(*cam_status_table);
-
#ifdef _KERNEL
SYSCTL_NODE(_kern, OID_AUTO, cam, CTLFLAG_RD, 0, "CAM Subsystem");
@@ -256,7 +253,7 @@ cam_fetch_status_entry(cam_status status)
{
status &= CAM_STATUS_MASK;
return (bsearch(&status, &cam_status_table,
- num_cam_status_entries,
+ nitems(cam_status_table),
sizeof(*cam_status_table),
camstatusentrycomp));
}
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c
index 12be402..40b6db5 100644
--- a/sys/cam/scsi/scsi_all.c
+++ b/sys/cam/scsi/scsi_all.c
@@ -737,9 +737,6 @@ const struct sense_key_table_entry sense_key_table[] =
{ SSD_KEY_COMPLETED, SS_NOP, "COMPLETED" }
};
-const int sense_key_table_size =
- sizeof(sense_key_table)/sizeof(sense_key_table[0]);
-
static struct asc_table_entry quantum_fireball_entries[] = {
{ SST(0x04, 0x0b, SS_START | SSQ_DECREMENT_COUNT | ENXIO,
"Logical unit not ready, initializing cmd. required") }
@@ -3291,14 +3288,14 @@ fetchtableentries(int sense_key, int asc, int ascq,
sense_tables[0] = quirk->sense_key_info;
sense_tables_size[0] = quirk->num_sense_keys;
sense_tables[1] = sense_key_table;
- sense_tables_size[1] = sense_key_table_size;
+ sense_tables_size[1] = nitems(sense_key_table);
num_sense_tables = 2;
} else {
asc_tables[0] = asc_table;
asc_tables_size[0] = asc_table_size;
num_asc_tables = 1;
sense_tables[0] = sense_key_table;
- sense_tables_size[0] = sense_key_table_size;
+ sense_tables_size[0] = nitems(sense_key_table);
num_sense_tables = 1;
}
diff --git a/sys/dev/advansys/adw_pci.c b/sys/dev/advansys/adw_pci.c
index 108647e..f8fa3d0 100644
--- a/sys/dev/advansys/adw_pci.c
+++ b/sys/dev/advansys/adw_pci.c
@@ -121,9 +121,6 @@ struct adw_pci_identity adw_pci_ident_table[] =
#endif
};
-static const int adw_num_pci_devs =
- sizeof(adw_pci_ident_table) / sizeof(*adw_pci_ident_table);
-
#define ADW_PCI_MAX_DMA_ADDR (0xFFFFFFFFUL)
#define ADW_PCI_MAX_DMA_COUNT (0xFFFFFFFFUL)
@@ -173,7 +170,7 @@ adw_find_pci_device(device_t dev)
pci_get_subdevice(dev),
pci_get_subvendor(dev));
- for (i = 0; i < adw_num_pci_devs; i++) {
+ for (i = 0; i < nitems(adw_pci_ident_table); i++) {
entry = &adw_pci_ident_table[i];
if (entry->full_id == (full_id & entry->id_mask))
return (entry);
diff --git a/sys/dev/advansys/adwlib.c b/sys/dev/advansys/adwlib.c
index b820773..e201cdf 100644
--- a/sys/dev/advansys/adwlib.c
+++ b/sys/dev/advansys/adwlib.c
@@ -161,8 +161,6 @@ const struct adw_syncrate adw_syncrates[] =
{ ADW_MC_SDTR_ASYNC, 0, "async" }
};
-const int adw_num_syncrates = sizeof(adw_syncrates) / sizeof(adw_syncrates[0]);
-
static u_int16_t adw_eeprom_read_16(struct adw_softc *adw, int addr);
static void adw_eeprom_write_16(struct adw_softc *adw, int addr,
u_int data);
@@ -817,7 +815,7 @@ adw_find_sdtr(struct adw_softc *adw, u_int period)
if (period == 0)
return ADW_MC_SDTR_ASYNC;
- for (; i < adw_num_syncrates; i++) {
+ for (; i < nitems(adw_syncrates); i++) {
if (period <= adw_syncrates[i].period)
return (adw_syncrates[i].mc_sdtr);
}
@@ -829,7 +827,7 @@ adw_find_period(struct adw_softc *adw, u_int mc_sdtr)
{
int i;
- for (i = 0; i < adw_num_syncrates; i++) {
+ for (i = 0; i < nitems(adw_syncrates); i++) {
if (mc_sdtr == adw_syncrates[i].mc_sdtr)
break;
}
diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c
index f092a21..a54ac27 100644
--- a/sys/dev/hwpmc/hwpmc_core.c
+++ b/sys/dev/hwpmc/hwpmc_core.c
@@ -1894,8 +1894,6 @@ static struct iap_event_descr iap_events[] = {
IAPDESCR(FDH_40H, 0xFD, 0x40, IAP_F_FM | IAP_F_WM | IAP_F_I7),
};
-static const int niap_events = sizeof(iap_events) / sizeof(iap_events[0]);
-
static pmc_value_t
iap_perfctr_value_to_reload_count(pmc_value_t v)
{
@@ -2251,11 +2249,11 @@ iap_allocate_pmc(int cpu, int ri, struct pmc *pm,
break;
}
- for (n = 0, ie = iap_events; n < niap_events; n++, ie++)
+ for (n = 0, ie = iap_events; n < nitems(iap_events); n++, ie++)
if (ie->iap_ev == ev && ie->iap_flags & cpuflag)
break;
- if (n == niap_events)
+ if (n == nitems(iap_events))
return (EINVAL);
/*
diff --git a/sys/dev/hwpmc/hwpmc_mpc7xxx.c b/sys/dev/hwpmc/hwpmc_mpc7xxx.c
index 296bd37..2a2b608 100644
--- a/sys/dev/hwpmc/hwpmc_mpc7xxx.c
+++ b/sys/dev/hwpmc/hwpmc_mpc7xxx.c
@@ -311,9 +311,6 @@ static struct mpc7xxx_event_code_map mpc7xxx_event_codes[] = {
PMC_POWERPC_EVENT(PREFETCH_ENGINE_FULL, 0x20, 57)
};
-const size_t mpc7xxx_event_codes_size =
- sizeof(mpc7xxx_event_codes) / sizeof(mpc7xxx_event_codes[0]);
-
static pmc_value_t
mpc7xxx_pmcn_read(unsigned int pmc)
{
@@ -616,14 +613,14 @@ mpc7xxx_allocate_pmc(int cpu, int ri, struct pmc *pm,
caps = a->pm_caps;
pe = a->pm_ev;
- for (i = 0; i < mpc7xxx_event_codes_size; i++) {
+ for (i = 0; i < nitems(mpc7xxx_event_codes); i++) {
if (mpc7xxx_event_codes[i].pe_ev == pe) {
config = mpc7xxx_event_codes[i].pe_code;
counter = mpc7xxx_event_codes[i].pe_counter_mask;
break;
}
}
- if (i == mpc7xxx_event_codes_size)
+ if (i == nitems(mpc7xxx_event_codes))
return (EINVAL);
if ((counter & (1 << ri)) == 0)
diff --git a/sys/dev/hwpmc/hwpmc_uncore.c b/sys/dev/hwpmc/hwpmc_uncore.c
index 2b24b33e..7050927 100644
--- a/sys/dev/hwpmc/hwpmc_uncore.c
+++ b/sys/dev/hwpmc/hwpmc_uncore.c
@@ -790,8 +790,6 @@ static struct ucp_event_descr ucp_events[] = {
UCPDESCR(86H_01H, 0x86, 0x01, UCP_F_FM | UCP_F_WM)
};
-static const int nucp_events = sizeof(ucp_events) / sizeof(ucp_events[0]);
-
static pmc_value_t
ucp_perfctr_value_to_reload_count(pmc_value_t v)
{
@@ -883,11 +881,11 @@ ucp_allocate_pmc(int cpu, int ri, struct pmc *pm,
return (EINVAL);
}
- for (n = 0, ie = ucp_events; n < nucp_events; n++, ie++)
+ for (n = 0, ie = ucp_events; n < nitems(ucp_events); n++, ie++)
if (ie->ucp_ev == ev && ie->ucp_flags & cpuflag)
break;
- if (n == nucp_events)
+ if (n == nitems(ucp_events))
return (EINVAL);
/*
diff --git a/sys/dev/hwpmc/hwpmc_xscale.c b/sys/dev/hwpmc/hwpmc_xscale.c
index e5df8d0..4a03ea6 100644
--- a/sys/dev/hwpmc/hwpmc_xscale.c
+++ b/sys/dev/hwpmc/hwpmc_xscale.c
@@ -88,9 +88,6 @@ const struct xscale_event_code_map xscale_event_codes[] = {
{ PMC_EV_XSCALE_DATA_BUS_TRANS, 0x48 },
};
-const int xscale_event_codes_size =
- sizeof(xscale_event_codes) / sizeof(xscale_event_codes[0]);
-
/*
* Per-processor information.
*/
@@ -264,13 +261,13 @@ xscale_allocate_pmc(int cpu, int ri, struct pmc *pm,
if (a->pm_class != PMC_CLASS_XSCALE)
return (EINVAL);
pe = a->pm_ev;
- for (i = 0; i < xscale_event_codes_size; i++) {
+ for (i = 0; i < nitems(xscale_event_codes); i++) {
if (xscale_event_codes[i].pe_ev == pe) {
config = xscale_event_codes[i].pe_code;
break;
}
}
- if (i == xscale_event_codes_size)
+ if (i == nitems(xscale_event_codes))
return EINVAL;
/* Generation 1 has fewer events */
if (xscale_gen == 1 && i > PMC_EV_XSCALE_PC_CHANGE)
diff --git a/sys/dev/pccard/pccard_cis_quirks.c b/sys/dev/pccard/pccard_cis_quirks.c
index 1452915..cb07718 100644
--- a/sys/dev/pccard/pccard_cis_quirks.c
+++ b/sys/dev/pccard/pccard_cis_quirks.c
@@ -257,9 +257,6 @@ static struct pccard_cis_quirk pccard_cis_quirks[] = {
&pccard_ndc_nd5100_func0, &pccard_ndc_nd5100_func0_cfe0 },
};
-static int n_pccard_cis_quirks =
- sizeof(pccard_cis_quirks)/sizeof(pccard_cis_quirks[0]);
-
static int
pccard_cis_quirk_match(struct pccard_softc *sc, struct pccard_cis_quirk *q)
{
@@ -289,7 +286,7 @@ void pccard_check_cis_quirks(device_t dev)
pf = NULL;
pf_last = NULL;
- for (i=0; i<n_pccard_cis_quirks; i++) {
+ for (i = 0; i < nitems(pccard_cis_quirks); i++) {
q = &pccard_cis_quirks[i];
if (!pccard_cis_quirk_match(sc, q))
continue;
diff --git a/sys/dev/sge/if_sge.c b/sys/dev/sge/if_sge.c
index f0ef07f..9aefce1 100644
--- a/sys/dev/sge/if_sge.c
+++ b/sys/dev/sge/if_sge.c
@@ -276,9 +276,8 @@ sge_get_mac_addr_apc(struct sge_softc *sc, uint8_t *dest)
{ SIS_VENDORID, 0x0968 }
};
uint8_t reg;
- int busnum, cnt, i, j, numkids;
+ int busnum, i, j, numkids;
- cnt = sizeof(apc_tbls) / sizeof(apc_tbls[0]);
pci = devclass_find("pci");
for (busnum = 0; busnum < devclass_get_maxunit(pci); busnum++) {
bus = devclass_get_device(pci, busnum);
@@ -291,7 +290,7 @@ sge_get_mac_addr_apc(struct sge_softc *sc, uint8_t *dest)
if (pci_get_class(dev) == PCIC_BRIDGE &&
pci_get_subclass(dev) == PCIS_BRIDGE_ISA) {
tp = apc_tbls;
- for (j = 0; j < cnt; j++) {
+ for (j = 0; j < nitems(apc_tbls); j++) {
if (pci_get_vendor(dev) == tp->vid &&
pci_get_device(dev) == tp->did) {
free(kids, M_TEMP);
diff --git a/sys/dev/sound/pci/emu10kx.c b/sys/dev/sound/pci/emu10kx.c
index cb441bb..3d5bfb3 100644
--- a/sys/dev/sound/pci/emu10kx.c
+++ b/sys/dev/sound/pci/emu10kx.c
@@ -564,16 +564,14 @@ emu_getcard(device_t dev)
{
uint16_t device;
uint16_t subdevice;
- int n_cards;
unsigned int thiscard;
int i;
device = pci_read_config(dev, PCIR_DEVICE, /* bytes */ 2);
subdevice = pci_read_config(dev, PCIR_SUBDEV_0, /* bytes */ 2);
- n_cards = sizeof(emu_cards) / sizeof(struct emu_hwinfo);
thiscard = 0;
- for (i = 1; i < n_cards; i++) {
+ for (i = 1; i < nitems(emu_cards); i++) {
if (device == emu_cards[i].device) {
if (subdevice == emu_cards[i].subdevice) {
thiscard = i;
@@ -589,8 +587,7 @@ emu_getcard(device_t dev)
}
}
- n_cards = sizeof(emu_bad_cards) / sizeof(struct emu_hwinfo);
- for (i = 0; i < n_cards; i++) {
+ for (i = 0; i < nitems(emu_cards); i++) {
if (device == emu_bad_cards[i].device) {
if (subdevice == emu_bad_cards[i].subdevice) {
thiscard = 0;
diff --git a/sys/dev/uart/uart_subr.c b/sys/dev/uart/uart_subr.c
index 5516a6c..f3dc50c 100644
--- a/sys/dev/uart/uart_subr.c
+++ b/sys/dev/uart/uart_subr.c
@@ -56,7 +56,6 @@ static struct uart_class *uart_classes[] = {
&uart_s3c2410_class,
#endif
};
-static size_t uart_nclasses = sizeof(uart_classes) / sizeof(uart_classes[0]);
static bus_addr_t
uart_parse_addr(const char **p)
@@ -72,7 +71,7 @@ uart_parse_class(struct uart_class *class, const char **p)
size_t len;
u_int i;
- for (i = 0; i < uart_nclasses; i++) {
+ for (i = 0; i < nitems(uart_classes); i++) {
uc = uart_classes[i];
nm = uart_getname(uc);
if (nm == NULL || *nm == '\0')
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 29c83c0..03e5a50 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -709,7 +709,6 @@ static struct witness_order_list_entry order_lists[] = {
*/
static struct witness_blessed blessed_list[] = {
};
-static int blessed_count = nitems(blessed_list);
#endif
/*
@@ -2059,7 +2058,7 @@ blessed(struct witness *w1, struct witness *w2)
int i;
struct witness_blessed *b;
- for (i = 0; i < blessed_count; i++) {
+ for (i = 0; i < nitems(blessed_list); i++) {
b = &blessed_list[i];
if (strcmp(w1->w_name, b->b_lock1) == 0) {
if (strcmp(w2->w_name, b->b_lock2) == 0)
diff --git a/sys/mips/nlm/xlp_machdep.c b/sys/mips/nlm/xlp_machdep.c
index dde6a74..5f93d6c 100644
--- a/sys/mips/nlm/xlp_machdep.c
+++ b/sys/mips/nlm/xlp_machdep.c
@@ -441,11 +441,10 @@ static vm_paddr_t xlp_mem_excl[] = {
static int
mem_exclude_add(vm_paddr_t *avail, vm_paddr_t mstart, vm_paddr_t mend)
{
- int nreg = sizeof(xlp_mem_excl)/sizeof(xlp_mem_excl[0]);
int i, pos;
pos = 0;
- for (i = 0; i < nreg; i += 2) {
+ for (i = 0; i < nitems(xlp_mem_excl); i += 2) {
if (mstart > xlp_mem_excl[i + 1])
continue;
if (mstart < xlp_mem_excl[i]) {
diff --git a/sys/net/netisr.c b/sys/net/netisr.c
index 6b89a85..14de112 100644
--- a/sys/net/netisr.c
+++ b/sys/net/netisr.c
@@ -287,8 +287,6 @@ static const struct netisr_dispatch_table_entry netisr_dispatch_table[] = {
{ NETISR_DISPATCH_HYBRID, "hybrid" },
{ NETISR_DISPATCH_DIRECT, "direct" },
};
-static const u_int netisr_dispatch_table_len =
- (sizeof(netisr_dispatch_table) / sizeof(netisr_dispatch_table[0]));
static void
netisr_dispatch_policy_to_str(u_int dispatch_policy, char *buffer,
@@ -299,7 +297,7 @@ netisr_dispatch_policy_to_str(u_int dispatch_policy, char *buffer,
u_int i;
str = "unknown";
- for (i = 0; i < netisr_dispatch_table_len; i++) {
+ for (i = 0; i < nitems(netisr_dispatch_table); i++) {
ndtep = &netisr_dispatch_table[i];
if (ndtep->ndte_policy == dispatch_policy) {
str = ndtep->ndte_policy_str;
@@ -315,7 +313,7 @@ netisr_dispatch_policy_from_str(const char *str, u_int *dispatch_policyp)
const struct netisr_dispatch_table_entry *ndtep;
u_int i;
- for (i = 0; i < netisr_dispatch_table_len; i++) {
+ for (i = 0; i < nitems(netisr_dispatch_table); i++) {
ndtep = &netisr_dispatch_table[i];
if (strcmp(ndtep->ndte_policy_str, str) == 0) {
*dispatch_policyp = ndtep->ndte_policy;
diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket.c b/sys/netgraph/bluetooth/socket/ng_btsocket.c
index d0f1246..7190074 100644
--- a/sys/netgraph/bluetooth/socket/ng_btsocket.c
+++ b/sys/netgraph/bluetooth/socket/ng_btsocket.c
@@ -213,10 +213,9 @@ static struct protosw ng_btsocket_protosw[] = {
.pr_usrreqs = &ng_btsocket_sco_usrreqs,
},
};
-#define ng_btsocket_protosw_size \
- (sizeof(ng_btsocket_protosw)/sizeof(ng_btsocket_protosw[0]))
+
#define ng_btsocket_protosw_end \
- &ng_btsocket_protosw[ng_btsocket_protosw_size]
+ &ng_btsocket_protosw[nitems(ng_btsocket_protosw)]
/*
* BLUETOOTH domain
diff --git a/sys/nlm/nlm_prot_impl.c b/sys/nlm/nlm_prot_impl.c
index 28a618a..1814b55 100644
--- a/sys/nlm/nlm_prot_impl.c
+++ b/sys/nlm/nlm_prot_impl.c
@@ -1426,7 +1426,6 @@ nlm_register_services(SVCPOOL *pool, int addr_count, char **addrs)
static void (*dispatchers[])(struct svc_req *, SVCXPRT *) = {
nlm_prog_0, nlm_prog_1, nlm_prog_3, nlm_prog_4
};
- static const int version_count = sizeof(versions) / sizeof(versions[0]);
SVCXPRT **xprts;
char netid[16];
@@ -1446,7 +1445,7 @@ nlm_register_services(SVCPOOL *pool, int addr_count, char **addrs)
}
xprts = malloc(addr_count * sizeof(SVCXPRT *), M_NLM, M_WAITOK|M_ZERO);
- for (i = 0; i < version_count; i++) {
+ for (i = 0; i < nitems(versions); i++) {
for (j = 0; j < addr_count; j++) {
/*
* Create transports for the first version and
diff --git a/sys/security/audit/audit_bsm_klib.c b/sys/security/audit/audit_bsm_klib.c
index b687a15..f44fac9 100644
--- a/sys/security/audit/audit_bsm_klib.c
+++ b/sys/security/audit/audit_bsm_klib.c
@@ -95,7 +95,6 @@ static const struct aue_open_event aue_open[] = {
{ (O_WRONLY | O_CREAT | O_TRUNC), AUE_OPEN_WTC },
{ (O_WRONLY | O_TRUNC), AUE_OPEN_WT },
};
-static const int aue_open_count = sizeof(aue_open) / sizeof(aue_open[0]);
static const struct aue_open_event aue_openat[] = {
{ O_RDONLY, AUE_OPENAT_R },
@@ -111,7 +110,6 @@ static const struct aue_open_event aue_openat[] = {
{ (O_WRONLY | O_CREAT | O_TRUNC), AUE_OPENAT_WTC },
{ (O_WRONLY | O_TRUNC), AUE_OPENAT_WT },
};
-static const int aue_openat_count = sizeof(aue_openat) / sizeof(aue_openat[0]);
/*
* Look up the class for an audit event in the class mapping table.
@@ -296,7 +294,7 @@ audit_flags_and_error_to_openevent(int oflags, int error)
* Need to check only those flags we care about.
*/
oflags = oflags & (O_RDONLY | O_CREAT | O_TRUNC | O_RDWR | O_WRONLY);
- for (i = 0; i < aue_open_count; i++) {
+ for (i = 0; i < nitems(aue_open); i++) {
if (aue_open[i].aoe_flags == oflags)
return (aue_open[i].aoe_event);
}
@@ -312,7 +310,7 @@ audit_flags_and_error_to_openatevent(int oflags, int error)
* Need to check only those flags we care about.
*/
oflags = oflags & (O_RDONLY | O_CREAT | O_TRUNC | O_RDWR | O_WRONLY);
- for (i = 0; i < aue_openat_count; i++) {
+ for (i = 0; i < nitems(aue_openat); i++) {
if (aue_openat[i].aoe_flags == oflags)
return (aue_openat[i].aoe_event);
}
diff --git a/sys/security/audit/bsm_errno.c b/sys/security/audit/bsm_errno.c
index bb746b5..9506025 100644
--- a/sys/security/audit/bsm_errno.c
+++ b/sys/security/audit/bsm_errno.c
@@ -699,14 +699,13 @@ static const struct bsm_errno bsm_errnos[] = {
#endif
ES("Not permitted in capability mode") },
};
-static const int bsm_errnos_count = sizeof(bsm_errnos) / sizeof(bsm_errnos[0]);
static const struct bsm_errno *
bsm_lookup_errno_local(int local_errno)
{
int i;
- for (i = 0; i < bsm_errnos_count; i++) {
+ for (i = 0; i < nitems(bsm_errnos); i++) {
if (bsm_errnos[i].be_local_errno == local_errno)
return (&bsm_errnos[i]);
}
@@ -733,7 +732,7 @@ bsm_lookup_errno_bsm(u_char bsm_errno)
{
int i;
- for (i = 0; i < bsm_errnos_count; i++) {
+ for (i = 0; i < nitems(bsm_errnos); i++) {
if (bsm_errnos[i].be_bsm_errno == bsm_errno)
return (&bsm_errnos[i]);
}
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c
index 7a1e6ae..fccd1c8 100644
--- a/sys/vm/vm_pager.c
+++ b/sys/vm/vm_pager.c
@@ -165,8 +165,6 @@ struct pagerops *pagertab[] = {
&mgtdevicepagerops, /* OBJT_MGTDEVICE */
};
-static const int npagers = sizeof(pagertab) / sizeof(pagertab[0]);
-
/*
* Kernel address space for mapping pages.
* Used by pagers where KVAs are needed for IO.
@@ -189,7 +187,7 @@ vm_pager_init()
/*
* Initialize known pagers
*/
- for (pgops = pagertab; pgops < &pagertab[npagers]; pgops++)
+ for (pgops = pagertab; pgops < &pagertab[nitems(pagertab)]; pgops++)
if ((*pgops)->pgo_init != NULL)
(*(*pgops)->pgo_init) ();
}
OpenPOWER on IntegriCloud