nmix is used to compare against mixerinfo->dev, which is a user-supplied
value to select the mixer device (if not -1, in which case we'll select
the default one) we want to fetch the information of. It is also used to
set mixerinfo->dev in case it is -1.
However, nmix is at best redundant, since we have the loop counter
already (i), and confusing at worst, in case we hit the "continue" case
in the loop, in which case nmix will not get incremented and we'll end
up fetching the wrong device.
For example, suppose a system with 3 mixer devices. We call
SNDCTL_MIXERINFO with mixerinfo->dev=1, meaning we want to get
information for /dev/mixer1. Suppose /dev/mixer0 detaches while inside
the loop, so we'll hit the loop's "continue" case, and nmix won't get
incremented (i.e will stay 0 for now). At this point nmix counts 1
device less, so when it reaches 1, we'll be fetching /dev/mixer2's
information instead of /dev/mixer1's.
Simply remove nmix and use the loop counter to both set mixerinfo->dev
and check against it in case a non -1 value is supplied.
Sponsored by: The FreeBSD Foundation
MFC after: 1 week