HomeFreeBSD

sound: Remove nmix variable from mixer_oss_mixerinfo()

Description

sound: Remove nmix variable from mixer_oss_mixerinfo()

nmix is used to compare against oss_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 oss_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.

For example, suppose a system with 3 mixer devices. We call
SNDCTL_MIXERINFO with oss_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.

This is also true in case the mixer device disappears prior to the call
to mixer_oss_mixerinfo().

Simply remove nmix and use the loop counter to both set
oss_mixerinfo->dev and check against it in case a non -1 value is
supplied.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D45135

(cherry picked from commit 2f31a5eb75f1e47b5c49f574e8ce48d2c863e9d3)
(cherry picked from commit 8b4e2ba31d1b171f688cb630f1827ec397ecaacb)

Approved by: re (cperciva)

Details

Provenance
christosAuthored on May 9 2024, 7:07 PM
Reviewer
dev_submerge.ch
Differential Revision
D45135: sound: Remove nmix variable from mixer_oss_mixerinfo()
Parents
rGdcde37c4170b: unbound: Vendor import 1.20.0
Branches
Unknown
Tags
Unknown