From nobody Fri May 17 19:31:13 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VgxsG13Qhz5Lg07; Fri, 17 May 2024 19:31:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VgxsF6Z3yz4vjn; Fri, 17 May 2024 19:31:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715974273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0EfUPUNeH6AM500P13bCCayMMOjPVBj90YvTD0EmGgE=; b=BGPMUq0ZvjiLB4ftgMXDAh8myhfitCNg9RdNgO0u5K6Ce27yT/3zcNK8ZOjRf1uXEBZZgX 8eyX6FwzUOK+DwlXh00znrrPXFowRlwzMBwxQYCJdJQIcUKN0b6GD8H3TgIVyz2dxzHkhw YhtQQRXVQ0NqFysZczpSwMWpz/T/inM6ReGy6GjdADleWatzXtocFU7BqcLTfR24cP9pxn 6qHU+NWHXwE3ko//NXopzgJF6czt/68aO97shCIZDVq23Q2nFR5UTajL6rdouvRI4Hk4p2 rZGscXohibfGZc8K17eWZR9oOU/vH/0VRLPn14G/gxHYeeJF7AMAnyLNzuwPwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715974273; a=rsa-sha256; cv=none; b=kPqmtEm7D08QIQ7uBr4IWXbGqqsnObz0iiDLVyfstjEwtZCaipm1lAxH8qGEWAKH3Wx9e6 zo9J00tc/aM2Vg0lB62/3/qPwQFOiSl5XnT7astyn875rcQ3rAP/1RPQBbos/usZCRCQlA STY3fjJ4Q4+YUPH8AEkrHNjbnOFNrX5xK4BGjuwrO4oWWmyJqrpHAlLFnX/u2d/foVoT3F oOvp4aMJpyM3ONJc64QSXjeV+QUBqJsq5nDRxHo1j0fFuGR8PRRldLY7DGH4Ybz6YLXWO4 PzK5NpuRetiXitv1gZr+nPncFe09CuQczVho8b5DZiWvoy+3cxgktbOM9WwThA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715974273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0EfUPUNeH6AM500P13bCCayMMOjPVBj90YvTD0EmGgE=; b=olKGf/lW5l0Fw7CwB6wngYoFQQm71qVaOVrGuiXUh389y20FuS4QSNLR/UC1mted+X0+J9 7Ree6Om+5vfm+i+aaSHAGecmdRLfOIZ4hAnpg0w+854G1FrgAPgtHm6dZda62w4FIoh6Yw mffmpOtExfyrFd7cNvWPp4A4q9RKts+4Gbk9fCA9Gs2PXPnQ+bjHsw2PUfl1Q+EnGunp9L KHAomHZ+PFkwcttlAvy1PyGB3ztbwKTfnNJ0hUP5sMQR9zTFrbqMwdB9rrwPw1Bqmzw4he IqvYpgC7309sFUwHQoeaszJyIf6BGbnHGVvj8LTaeRkuG/wfvf1KbrH7zzNnRw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VgxsF6BQ5zvTr; Fri, 17 May 2024 19:31:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44HJVDfA000167; Fri, 17 May 2024 19:31:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44HJVD4V000164; Fri, 17 May 2024 19:31:13 GMT (envelope-from git) Date: Fri, 17 May 2024 19:31:13 GMT Message-Id: <202405171931.44HJVD4V000164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 8b4e2ba31d1b - stable/14 - sound: Remove nmix variable from mixer_oss_mixerinfo() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 8b4e2ba31d1b171f688cb630f1827ec397ecaacb Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=8b4e2ba31d1b171f688cb630f1827ec397ecaacb commit 8b4e2ba31d1b171f688cb630f1827ec397ecaacb Author: Christos Margiolis AuthorDate: 2024-05-09 19:07:48 +0000 Commit: Christos Margiolis CommitDate: 2024-05-17 19:30:36 +0000 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) --- sys/dev/sound/pcm/mixer.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 4e67a0227506..a37b94dce43a 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -1431,7 +1431,7 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi) { struct snddev_info *d; struct snd_mixer *m; - int nmix, i; + int i; /* * If probing the device handling the ioctl, make sure it's a mixer @@ -1442,7 +1442,6 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi) d = NULL; m = NULL; - nmix = 0; /* * There's a 1:1 relationship between mixers and PCM devices, so @@ -1462,7 +1461,7 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi) if (d->mixer_dev != NULL && d->mixer_dev->si_drv1 != NULL && ((mi->dev == -1 && d->mixer_dev == i_dev) || - mi->dev == nmix)) { + mi->dev == i)) { m = d->mixer_dev->si_drv1; mtx_lock(m->lock); @@ -1474,7 +1473,7 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi) * sure to unlock when existing. */ bzero((void *)mi, sizeof(*mi)); - mi->dev = nmix; + mi->dev = i; snprintf(mi->id, sizeof(mi->id), "mixer%d", i); strlcpy(mi->name, m->name, sizeof(mi->name)); mi->modify_counter = m->modify_counter; @@ -1538,8 +1537,7 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi) mi->legacy_device = i; */ mtx_unlock(m->lock); - } else - ++nmix; + } PCM_UNLOCK(d);