svn commit: r298411 - in head/sys: cam cam/ata cam/scsi dev/advansys dev/hwpmc dev/pccard dev/sge dev/sound/pci dev/uart kern mips/nlm net netgraph/bluetooth/socket nlm security/audit vm

Pedro F. Giffuni pfg at FreeBSD.org
Thu Apr 21 15:38:31 UTC 2016


Author: pfg
Date: Thu Apr 21 15:38:28 2016
New Revision: 298411
URL: https://svnweb.freebsd.org/changeset/base/298411

Log:
  Remove slightly used const values that can be replaced with nitems().
  
  Suggested by:	jhb

Modified:
  head/sys/cam/ata/ata_xpt.c
  head/sys/cam/cam.c
  head/sys/cam/scsi/scsi_all.c
  head/sys/dev/advansys/adw_pci.c
  head/sys/dev/advansys/adwlib.c
  head/sys/dev/hwpmc/hwpmc_core.c
  head/sys/dev/hwpmc/hwpmc_mpc7xxx.c
  head/sys/dev/hwpmc/hwpmc_uncore.c
  head/sys/dev/hwpmc/hwpmc_xscale.c
  head/sys/dev/pccard/pccard_cis_quirks.c
  head/sys/dev/sge/if_sge.c
  head/sys/dev/sound/pci/emu10kx.c
  head/sys/dev/uart/uart_subr.c
  head/sys/kern/subr_witness.c
  head/sys/mips/nlm/xlp_machdep.c
  head/sys/net/netisr.c
  head/sys/netgraph/bluetooth/socket/ng_btsocket.c
  head/sys/nlm/nlm_prot_impl.c
  head/sys/security/audit/audit_bsm_klib.c
  head/sys/security/audit/bsm_errno.c
  head/sys/vm/vm_pager.c

Modified: head/sys/cam/ata/ata_xpt.c
==============================================================================
--- head/sys/cam/ata/ata_xpt.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/cam/ata/ata_xpt.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -160,9 +160,6 @@ static struct ata_quirk_entry ata_quirk_
 	},
 };
 
-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, str
 	 * 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;

Modified: head/sys/cam/cam.c
==============================================================================
--- head/sys/cam/cam.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/cam/cam.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -105,9 +105,6 @@ const struct cam_status_entry cam_status
 	{ 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));
 }

Modified: head/sys/cam/scsi/scsi_all.c
==============================================================================
--- head/sys/cam/scsi/scsi_all.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/cam/scsi/scsi_all.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -737,9 +737,6 @@ const struct sense_key_table_entry sense
 	{ 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
 		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;
 	}
 

Modified: head/sys/dev/advansys/adw_pci.c
==============================================================================
--- head/sys/dev/advansys/adw_pci.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/dev/advansys/adw_pci.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -121,9 +121,6 @@ struct adw_pci_identity adw_pci_ident_ta
 #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);

Modified: head/sys/dev/advansys/adwlib.c
==============================================================================
--- head/sys/dev/advansys/adwlib.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/dev/advansys/adwlib.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -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_i
 	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 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;
 	}	

Modified: head/sys/dev/hwpmc/hwpmc_core.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_core.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/dev/hwpmc/hwpmc_core.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -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
 		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);
 
 	/*

Modified: head/sys/dev/hwpmc/hwpmc_mpc7xxx.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_mpc7xxx.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/dev/hwpmc/hwpmc_mpc7xxx.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -311,9 +311,6 @@ static struct mpc7xxx_event_code_map mpc
 	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, st
 	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)

Modified: head/sys/dev/hwpmc/hwpmc_uncore.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_uncore.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/dev/hwpmc/hwpmc_uncore.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -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
 		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);
 
 	/*

Modified: head/sys/dev/hwpmc/hwpmc_xscale.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_xscale.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/dev/hwpmc/hwpmc_xscale.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -88,9 +88,6 @@ const struct xscale_event_code_map xscal
 	{ 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, str
 	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)

Modified: head/sys/dev/pccard/pccard_cis_quirks.c
==============================================================================
--- head/sys/dev/pccard/pccard_cis_quirks.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/dev/pccard/pccard_cis_quirks.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -257,9 +257,6 @@ static struct pccard_cis_quirk pccard_ci
 	  &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 de
 	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;

Modified: head/sys/dev/sge/if_sge.c
==============================================================================
--- head/sys/dev/sge/if_sge.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/dev/sge/if_sge.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -276,9 +276,8 @@ sge_get_mac_addr_apc(struct sge_softc *s
 		{ 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 *s
 			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);

Modified: head/sys/dev/sound/pci/emu10kx.c
==============================================================================
--- head/sys/dev/sound/pci/emu10kx.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/dev/sound/pci/emu10kx.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -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;

Modified: head/sys/dev/uart/uart_subr.c
==============================================================================
--- head/sys/dev/uart/uart_subr.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/dev/uart/uart_subr.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -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 *clas
 	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')

Modified: head/sys/kern/subr_witness.c
==============================================================================
--- head/sys/kern/subr_witness.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/kern/subr_witness.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -709,7 +709,6 @@ static struct witness_order_list_entry o
  */
 static struct witness_blessed blessed_list[] = {
 };
-static int blessed_count = nitems(blessed_list);
 #endif
 
 /*
@@ -2059,7 +2058,7 @@ blessed(struct witness *w1, struct witne
 	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)

Modified: head/sys/mips/nlm/xlp_machdep.c
==============================================================================
--- head/sys/mips/nlm/xlp_machdep.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/mips/nlm/xlp_machdep.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -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]) {

Modified: head/sys/net/netisr.c
==============================================================================
--- head/sys/net/netisr.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/net/netisr.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -287,8 +287,6 @@ static const struct netisr_dispatch_tabl
 	{ 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 disp
 	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 ch
 	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;

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket.c
==============================================================================
--- head/sys/netgraph/bluetooth/socket/ng_btsocket.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -213,10 +213,9 @@ static struct protosw		ng_btsocket_proto
 	.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

Modified: head/sys/nlm/nlm_prot_impl.c
==============================================================================
--- head/sys/nlm/nlm_prot_impl.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/nlm/nlm_prot_impl.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -1426,7 +1426,6 @@ nlm_register_services(SVCPOOL *pool, int
 	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
 	}
 
 	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

Modified: head/sys/security/audit/audit_bsm_klib.c
==============================================================================
--- head/sys/security/audit/audit_bsm_klib.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/security/audit/audit_bsm_klib.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -95,7 +95,6 @@ static const struct aue_open_event aue_o
 	{ (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_o
 	{ (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 o
 	 * 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
 	 * 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);
 	}

Modified: head/sys/security/audit/bsm_errno.c
==============================================================================
--- head/sys/security/audit/bsm_errno.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/security/audit/bsm_errno.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -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]);
 	}

Modified: head/sys/vm/vm_pager.c
==============================================================================
--- head/sys/vm/vm_pager.c	Thu Apr 21 15:25:17 2016	(r298410)
+++ head/sys/vm/vm_pager.c	Thu Apr 21 15:38:28 2016	(r298411)
@@ -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) ();
 }


More information about the svn-src-head mailing list