diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2009-12-15 20:26:22 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2009-12-15 20:26:22 +0000 |
commit | 65ae7942f03b048ffd5a59ab6cf91b8f54112034 (patch) | |
tree | e166fe92b9e777a8a020eb1d9562cc699116f0e8 | |
parent | ab2b3daf8766001738f6d218a9e430fafb2fc8f7 (diff) |
- instead of rolling a macro that is functional equivalent to nitems(),
just use nitems(). (this leaves NENTS() alone for now)
ok deraadt@ krw@
-rw-r--r-- | sys/compat/freebsd/freebsd_file.c | 6 | ||||
-rw-r--r-- | sys/dev/cardbus/cardbus.c | 5 | ||||
-rw-r--r-- | sys/dev/ic/ac97.c | 14 | ||||
-rw-r--r-- | sys/dev/pci/agp.c | 9 | ||||
-rw-r--r-- | sys/dev/pci/ciss_pci.c | 5 | ||||
-rw-r--r-- | sys/netinet6/ip6_input.c | 6 |
6 files changed, 18 insertions, 27 deletions
diff --git a/sys/compat/freebsd/freebsd_file.c b/sys/compat/freebsd/freebsd_file.c index b852c348cac..15168a89e54 100644 --- a/sys/compat/freebsd/freebsd_file.c +++ b/sys/compat/freebsd/freebsd_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: freebsd_file.c,v 1.25 2006/06/25 15:01:53 sturm Exp $ */ +/* $OpenBSD: freebsd_file.c,v 1.26 2009/12/15 20:26:21 jasper Exp $ */ /* $NetBSD: freebsd_file.c,v 1.3 1996/05/03 17:03:09 christos Exp $ */ /* @@ -53,8 +53,6 @@ #include <compat/freebsd/freebsd_syscallargs.h> #include <compat/freebsd/freebsd_util.h> -#define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0])) - const char freebsd_emul_path[] = "/emul/freebsd"; static char * convert_from_freebsd_mount_type(int); @@ -107,7 +105,7 @@ convert_from_freebsd_mount_type(type) #endif }; - if (type < 0 || type >= ARRAY_LENGTH(freebsd_mount_type)) + if (type < 0 || type >= nitems(freebsd_mount_type)) return (NULL); return (freebsd_mount_type[type]); } diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index 76f6decc6eb..02ddbecb951 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cardbus.c,v 1.39 2009/03/29 21:53:52 sthen Exp $ */ +/* $OpenBSD: cardbus.c,v 1.40 2009/12/15 20:26:21 jasper Exp $ */ /* $NetBSD: cardbus.c,v 1.24 2000/04/02 19:11:37 mycroft Exp $ */ /* @@ -885,9 +885,8 @@ tuple_name(int type) "VERS_2", "FORMAT", "GEOMETRY", "BYTEORDER", /* 40-43 */ "DATE", "BATTERY", "ORG", "FORMAT_A" /* 44-47 */ }; -#define NAME_LEN(x) (sizeof(x)/sizeof(x[0])) - if (type > 0 && type < NAME_LEN(tuple_name_s)) + if (type > 0 && type < nitems(tuple_name_s)) return (tuple_name_s[type]); else if (0xff == type) return ("END"); diff --git a/sys/dev/ic/ac97.c b/sys/dev/ic/ac97.c index cef9a9b88f8..c04f01b6822 100644 --- a/sys/dev/ic/ac97.c +++ b/sys/dev/ic/ac97.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ac97.c,v 1.70 2008/10/23 21:50:01 jakemsr Exp $ */ +/* $OpenBSD: ac97.c,v 1.71 2009/12/15 20:26:21 jasper Exp $ */ /* * Copyright (c) 1999, 2000 Constantine Sapuntzakis @@ -310,8 +310,6 @@ const struct ac97_source_info { /* Missing features: Simulated Stereo, POP, Loopback mode */ }; -#define SOURCE_INFO_SIZE (sizeof(source_info)/sizeof(source_info[0])) - /* * Check out http://www.intel.com/technology/computing/audio/index.htm * for information on AC-97 @@ -321,7 +319,7 @@ struct ac97_softc { /* ac97_codec_if must be at the first of ac97_softc. */ struct ac97_codec_if codec_if; struct ac97_host_if *host_if; -#define MAX_SOURCES (2 * SOURCE_INFO_SIZE) +#define MAX_SOURCES (2 * nitems(source_info)) struct ac97_source_info source_info[MAX_SOURCES]; int num_source_info; enum ac97_host_flags host_flags; @@ -504,7 +502,7 @@ const struct ac97_codecid { { 0x03, 0xff, 0, 0, "YMF753-S" }, }; -#define cl(n) n, sizeof(n)/sizeof(n[0]) +#define cl(n) n, nitems(n) const struct ac97_vendorid { u_int32_t id; char * const name; @@ -646,7 +644,7 @@ ac97_setup_defaults(struct ac97_softc *as) bzero(as->shadow_reg, sizeof(as->shadow_reg)); - for (idx = 0; idx < SOURCE_INFO_SIZE; idx++) { + for (idx = 0; idx < nitems(source_info); idx++) { const struct ac97_source_info *si = &source_info[idx]; ac97_write(as, si->reg, si->default_value); @@ -659,7 +657,7 @@ ac97_restore_shadow(struct ac97_codec_if *self) struct ac97_softc *as = (struct ac97_softc *)self; int idx; - for (idx = 0; idx < SOURCE_INFO_SIZE; idx++) { + for (idx = 0; idx < nitems(source_info); idx++) { const struct ac97_source_info *si = &source_info[idx]; ac97_write(as, si->reg, as->shadow_reg[si->reg >> 1]); @@ -708,7 +706,7 @@ ac97_setup_source_info(struct ac97_softc *as) struct ac97_source_info *si, *si2; int idx, ouridx; - for (idx = 0, ouridx = 0; idx < SOURCE_INFO_SIZE; idx++) { + for (idx = 0, ouridx = 0; idx < nitems(source_info); idx++) { si = &as->source_info[ouridx]; if (!ac97_check_capability(as, source_info[idx].req_feature)) diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c index a4359e9a8d4..bc1b1f7b0f5 100644 --- a/sys/dev/pci/agp.c +++ b/sys/dev/pci/agp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp.c,v 1.32 2009/05/10 16:57:44 oga Exp $ */ +/* $OpenBSD: agp.c,v 1.33 2009/12/15 20:26:21 jasper Exp $ */ /*- * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -163,7 +163,6 @@ agp_attach(struct device *parent, struct device *self, void *aux) {2048, 1920}, {4096, 3932} }; -#define agp_max_size (sizeof(agp_max)/sizeof(agp_max[0])) /* * Work out an upper bound for agp memory allocation. This @@ -171,10 +170,10 @@ agp_attach(struct device *parent, struct device *self, void *aux) */ memsize = ptoa(physmem) >> 20; - for (i = 0; i < agp_max_size && memsize > agp_max[i][0]; i++) + for (i = 0; i < nitems(agp_max) && memsize > agp_max[i][0]; i++) ; - if (i == agp_max_size) - i = agp_max_size - 1; + if (i == nitems(agp_max)) + i = nitems(agp_max) - 1; sc->sc_maxmem = agp_max[i][1] << 20; /* diff --git a/sys/dev/pci/ciss_pci.c b/sys/dev/pci/ciss_pci.c index fe0c051978c..b6ce2914be9 100644 --- a/sys/dev/pci/ciss_pci.c +++ b/sys/dev/pci/ciss_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ciss_pci.c,v 1.13 2008/11/17 06:56:56 brad Exp $ */ +/* $OpenBSD: ciss_pci.c,v 1.14 2009/12/15 20:26:21 jasper Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -86,14 +86,13 @@ const struct pci_matchid ciss_pci_devices[] = { { PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_11 }, { PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_12 } }; -#define CISS_PCI_NDEVS sizeof(ciss_pci_devices)/sizeof(ciss_pci_devices[0]) int ciss_pci_match(struct device *parent, void *match, void *aux) { struct pci_attach_args *pa = aux; - return pci_matchbyid(pa, ciss_pci_devices, CISS_PCI_NDEVS); + return pci_matchbyid(pa, ciss_pci_devices, nitems(ciss_pci_devices)); } void diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 40e739c57ea..d66e7599be4 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_input.c,v 1.93 2009/11/19 22:07:17 otto Exp $ */ +/* $OpenBSD: ip6_input.c,v 1.94 2009/12/15 20:26:21 jasper Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -223,17 +223,15 @@ ip6_input(struct mbuf *m) else ip6stat.ip6s_mext1++; } else { -#define M2MMAX (sizeof(ip6stat.ip6s_m2m)/sizeof(ip6stat.ip6s_m2m[0])) if (m->m_next) { if (m->m_flags & M_LOOP) { ip6stat.ip6s_m2m[lo0ifp->if_index]++; /*XXX*/ - } else if (m->m_pkthdr.rcvif->if_index < M2MMAX) + } else if (m->m_pkthdr.rcvif->if_index < nitems(ip6stat.ip6s_m2m)) ip6stat.ip6s_m2m[m->m_pkthdr.rcvif->if_index]++; else ip6stat.ip6s_m2m[0]++; } else ip6stat.ip6s_m1++; -#undef M2MMAX } in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_receive); |