summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2007-04-07 05:59:50 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2007-04-07 05:59:50 +0000
commit2866c6445e55332824efd127a180215b7bdff177 (patch)
treebcc0da8e3ef41db59d8bb15be2b5510be4e09948
parentd38cab9760f6c9263a0fd8393a67c2ac1b7ef595 (diff)
sizeofa will give us the number of elements in an array. use it when
iterating over the pci device ids.
-rw-r--r--sys/dev/ic/silivar.h4
-rw-r--r--sys/dev/pci/sili_pci.c4
2 files changed, 5 insertions, 3 deletions
diff --git a/sys/dev/ic/silivar.h b/sys/dev/ic/silivar.h
index fb34621683e..e1a1e3a0498 100644
--- a/sys/dev/ic/silivar.h
+++ b/sys/dev/ic/silivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: silivar.h,v 1.4 2007/03/31 03:59:53 dlg Exp $ */
+/* $OpenBSD: silivar.h,v 1.5 2007/04/07 05:59:49 dlg Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -16,6 +16,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#define sizeofa(_a) (sizeof(_a) / sizeof((_a)[0]))
+
struct sili_port;
struct sili_softc {
diff --git a/sys/dev/pci/sili_pci.c b/sys/dev/pci/sili_pci.c
index 3a98b894d0e..a0fec08b48c 100644
--- a/sys/dev/pci/sili_pci.c
+++ b/sys/dev/pci/sili_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sili_pci.c,v 1.6 2007/04/06 01:04:52 jsg Exp $ */
+/* $OpenBSD: sili_pci.c,v 1.7 2007/04/07 05:59:49 dlg Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -75,7 +75,7 @@ sili_lookup(struct pci_attach_args *pa)
int i;
const struct sili_device *sd;
- for (i = 0; i < (sizeof(sili_devices) / sizeof(sili_devices[0])); i++) {
+ for (i = 0; i < sizeofa(sili_devices); i++) {
sd = &sili_devices[i];
if (sd->sd_vendor == PCI_VENDOR(pa->pa_id) &&
sd->sd_product == PCI_PRODUCT(pa->pa_id))