use devclass_get_maxunit() correctly

This commit is contained in:
cg 2001-06-18 00:10:47 +00:00
parent 4744ea5e98
commit abeb4f288f
3 changed files with 4 additions and 4 deletions

View File

@ -66,7 +66,7 @@ dsp_get_info(dev_t dev)
int unit;
unit = PCMUNIT(dev);
if (unit > devclass_get_maxunit(pcm_devclass))
if (unit >= devclass_get_maxunit(pcm_devclass))
return NULL;
d = devclass_get_softc(pcm_devclass, unit);
@ -1024,7 +1024,7 @@ dsp_clone(void *arg, char *name, int namelen, dev_t *dev)
return;
gotit:
if (unit == -1 || unit > devclass_get_maxunit(pcm_devclass))
if (unit == -1 || unit >= devclass_get_maxunit(pcm_devclass))
return;
cont = 1;

View File

@ -140,7 +140,7 @@ sndstat_prepare(struct sbuf *s)
} else
sbuf_printf(s, "Installed devices:\n");
for (i = 0; i <= devclass_get_maxunit(pcm_devclass); i++) {
for (i = 0; i < devclass_get_maxunit(pcm_devclass); i++) {
d = devclass_get_softc(pcm_devclass, i);
if (!d)
continue;

View File

@ -163,7 +163,7 @@ sysctl_hw_sndunit(SYSCTL_HANDLER_ARGS)
unit = snd_unit;
error = sysctl_handle_int(oidp, &unit, sizeof(unit), req);
if (error == 0 && req->newptr != NULL) {
if (unit < 0 || unit > devclass_get_maxunit(pcm_devclass))
if (unit < 0 || unit >= devclass_get_maxunit(pcm_devclass))
return EINVAL;
d = devclass_get_softc(pcm_devclass, unit);
if (d == NULL || SLIST_EMPTY(&d->channels))