From 2866c6445e55332824efd127a180215b7bdff177 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Sat, 7 Apr 2007 05:59:50 +0000 Subject: sizeofa will give us the number of elements in an array. use it when iterating over the pci device ids. --- sys/dev/ic/silivar.h | 4 +++- sys/dev/pci/sili_pci.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'sys/dev') 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 @@ -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 @@ -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)) -- cgit v1.2.3