diff --git a/sys/dev/sound/pci/atiixp.c b/sys/dev/sound/pci/atiixp.c --- a/sys/dev/sound/pci/atiixp.c +++ b/sys/dev/sound/pci/atiixp.c @@ -1168,12 +1168,12 @@ static int atiixp_pci_probe(device_t dev) { - int i; + size_t i; uint16_t devid, vendor; vendor = pci_get_vendor(dev); devid = pci_get_device(dev); - for (i = 0; i < sizeof(atiixp_hw) / sizeof(atiixp_hw[0]); i++) { + for (i = 0; i < nitems(atiixp_hw); i++) { if (vendor == atiixp_hw[i].vendor && devid == atiixp_hw[i].devid) { device_set_desc(dev, atiixp_hw[i].desc); diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c --- a/sys/dev/sound/pci/hda/hdaa.c +++ b/sys/dev/sound/pci/hda/hdaa.c @@ -267,7 +267,8 @@ struct hdaa_chan *ch = &devinfo->chans[as->chans[0]]; struct hdaa_widget *w; uint8_t *eld; - int i, total, sub, assume, channels; + int total, sub, assume, channels; + size_t i; uint16_t cpins, upins, tpins; cpins = upins = 0; @@ -347,7 +348,7 @@ printf("\n"); ); /* Look for maximal fitting matrix. */ - for (i = 0; i < sizeof(matrixes) / sizeof(struct matrix); i++) { + for (i = 0; i < nitems(matrixes); i++) { if (as->pinset != 0 && matrixes[i].analog == 0) continue; if ((matrixes[i].m.mask & ~channels) == 0) { @@ -1252,7 +1253,8 @@ static void hdaa_config_fetch(const char *str, uint32_t *on, uint32_t *off) { - int i = 0, j, k, len, inv; + size_t k; + int i = 0, j, len, inv; for (;;) { while (str[i] != '\0' && @@ -1292,7 +1294,8 @@ hdaa_sysctl_quirks(SYSCTL_HANDLER_ARGS) { char buf[256]; - int error, n = 0, i; + int error, n = 0; + size_t i; uint32_t quirks, quirks_off; quirks = *(uint32_t *)oidp->oid_arg1; diff --git a/sys/dev/sound/pci/ich.c b/sys/dev/sound/pci/ich.c --- a/sys/dev/sound/pci/ich.c +++ b/sys/dev/sound/pci/ich.c @@ -860,12 +860,12 @@ static int ich_pci_probe(device_t dev) { - int i; + size_t i; uint16_t devid, vendor; vendor = pci_get_vendor(dev); devid = pci_get_device(dev); - for (i = 0; i < sizeof(ich_devs)/sizeof(ich_devs[0]); i++) { + for (i = 0; i < nitems(ich_devs); i++) { if (vendor == ich_devs[i].vendor && devid == ich_devs[i].devid) { device_set_desc(dev, ich_devs[i].name); diff --git a/sys/dev/sound/pci/maestro3.c b/sys/dev/sound/pci/maestro3.c --- a/sys/dev/sound/pci/maestro3.c +++ b/sys/dev/sound/pci/maestro3.c @@ -488,7 +488,7 @@ DMAC_BLOCKF_SELECTOR); /* set an armload of static initializers */ - for(i = 0 ; i < (sizeof(pv) / sizeof(pv[0])) ; i++) { + for(i = 0 ; i < nitems(pv); i++) { m3_wr_assp_data(sc, ch->dac_data + pv[i].addr, pv[i].val); } @@ -862,7 +862,7 @@ DMAC_PAGE3_SELECTOR + DMAC_BLOCKF_SELECTOR); /* set an armload of static initializers */ - for(i = 0 ; i < (sizeof(rv) / sizeof(rv[0])) ; i++) { + for(i = 0 ; i < nitems(rv); i++) { m3_wr_assp_data(sc, ch->adc_data + rv[i].addr, rv[i].val); } diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -1966,7 +1966,7 @@ struct cdev **dev) { struct snddev_info *d; - int i; + size_t i; if (*dev != NULL) return; @@ -2017,7 +2017,7 @@ char * dsp_unit2name(char *buf, size_t len, struct pcm_channel *ch) { - int i; + size_t i; KASSERT(buf != NULL && len != 0, ("bogus buf=%p len=%ju", buf, (uintmax_t)len)); diff --git a/sys/dev/sound/pcm/feeder_format.c b/sys/dev/sound/pcm/feeder_format.c --- a/sys/dev/sound/pcm/feeder_format.c +++ b/sys/dev/sound/pcm/feeder_format.c @@ -115,16 +115,13 @@ } }; -#define FEEDFORMAT_TAB_SIZE \ - ((int32_t)(sizeof(feed_format_ops) / sizeof(feed_format_ops[0]))) - static int feed_format_init(struct pcm_feeder *f) { struct feed_format_info *info; intpcm_read_t *rd_op; intpcm_write_t *wr_op; - int i; + size_t i; if (f->desc->in == f->desc->out || AFMT_CHANNEL(f->desc->in) != AFMT_CHANNEL(f->desc->out)) @@ -133,7 +130,7 @@ rd_op = NULL; wr_op = NULL; - for (i = 0; i < FEEDFORMAT_TAB_SIZE && + for (i = 0; i < nitems(feed_format_ops) && (rd_op == NULL || wr_op == NULL); i++) { if (rd_op == NULL && AFMT_ENCODING(f->desc->in) == feed_format_ops[i].format) @@ -276,9 +273,9 @@ intpcm_read_t * feeder_format_read_op(uint32_t format) { - int i; + size_t i; - for (i = 0; i < FEEDFORMAT_TAB_SIZE; i++) { + for (i = 0; i < nitems(feed_format_ops); i++) { if (AFMT_ENCODING(format) == feed_format_ops[i].format) return (feed_format_ops[i].read); } @@ -289,9 +286,9 @@ intpcm_write_t * feeder_format_write_op(uint32_t format) { - int i; + size_t i; - for (i = 0; i < FEEDFORMAT_TAB_SIZE; i++) { + for (i = 0; i < nitems(feed_format_ops); i++) { if (AFMT_ENCODING(format) == feed_format_ops[i].format) return (feed_format_ops[i].write); } diff --git a/sys/dev/sound/pcm/feeder_matrix.c b/sys/dev/sound/pcm/feeder_matrix.c --- a/sys/dev/sound/pcm/feeder_matrix.c +++ b/sys/dev/sound/pcm/feeder_matrix.c @@ -230,7 +230,7 @@ { uint32_t i, j; - for (i = 0; i < (sizeof(info->matrix) / sizeof(info->matrix[0])); i++) { + for (i = 0; i < nitems(info->matrix); i++) { for (j = 0; j < (sizeof(info->matrix[i].chn) / sizeof(info->matrix[i].chn[0])); j++) { @@ -679,7 +679,7 @@ m_in->mask != m_out->mask) return (1); - for (i = 0; i < (sizeof(m_in->map) / sizeof(m_in->map[0])); i++) { + for (i = 0; i < nitems(m_in->map); i++) { if (m_in->map[i].type != m_out->map[i].type) return (1); if (m_in->map[i].type == SND_CHN_T_MAX) diff --git a/sys/dev/sound/pcm/feeder_volume.c b/sys/dev/sound/pcm/feeder_volume.c --- a/sys/dev/sound/pcm/feeder_volume.c +++ b/sys/dev/sound/pcm/feeder_volume.c @@ -337,7 +337,7 @@ info = f->data; - for (i = 0; i < (sizeof(info->matrix) / sizeof(info->matrix[0])); i++) { + for (i = 0; i < nitems(info->matrix); i++) { if (i < m->channels) info->matrix[i] = m->map[i].type; else diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -650,7 +650,7 @@ int type, const char *desc) { struct snd_mixer *m; - int i; + size_t i; KASSERT(dev != NULL && cls != NULL && devinfo != NULL, ("%s(): NULL data dev=%p cls=%p devinfo=%p", @@ -671,7 +671,7 @@ m->devinfo = devinfo; m->busy = 0; m->dev = dev; - for (i = 0; i < (sizeof(m->parent) / sizeof(m->parent[0])); i++) { + for (i = 0; i < nitems(m->parent); i++) { m->parent[i] = SOUND_MIXER_NONE; m->child[i] = 0; m->realdev[i] = i; diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -880,7 +880,8 @@ struct snddev_info *d; struct pcm_channel *c; - int i, j, ncards; + int j, ncards; + size_t i; ncards = 0; @@ -958,7 +959,7 @@ * Si->filler is a reserved array, but according to docs each * element should be set to -1. */ - for (i = 0; i < sizeof(si->filler)/sizeof(si->filler[0]); i++) + for (i = 0; i < nitems(si->filler); i++) si->filler[i] = -1; }