From nobody Thu May 09 19:08:43 2024 X-Original-To: dev-commits-src-main@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 4Vb1kz3nNlz5KK1g; Thu, 09 May 2024 19:08:43 +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 4Vb1kz3FXYz4g4J; Thu, 9 May 2024 19:08:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715281723; 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=WrVSG+zaU2GvNnoOxjIi1a8SO5j6YYnnNYJyZcsOhwQ=; b=Sy5j0Tke4mrIjVfTFTyL09txmW9dLjknSS/PNGZQZsJAYmBIkO51F2o1krJfFrAL9lk2Db bxnFJGOiTKShWa0Bv149jIeDUXzv9pjMXn8IjgsBybqO67JwyQ31244Jxu79ctWMU4aFRi a30NRx7YVd6kYtJEEMO7ITFK+TYJi/XVFlRlnNSlApTqL1N1BZ8120e7ukLPS412Z3soJN 0glmZn5fCv7RPN980b27ua9mnJM53eVuJMTlALu74yJHj3TriMjjlVHhv1BTqd8sl+q1CS D0XZhdEfvNH/SabsN4PqFbeav7RGdK9gY4HkBfh5I5oXvMiCB0in2Cmfr04IzA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715281723; a=rsa-sha256; cv=none; b=LQqxGgk3JTa6LXdPC1EPe+iWEP6HC+LKRKoNcptRr2jMiFlNm/ZHrOhwYaLfNuoZJxgxmp YqheeciF+dY16f3ow3N7/Vt9ek3qmvyEZPaSeFewR8ov9sSw0Rq1u5ON9/6xkDspNuEFQK yko+jgHxe7kP9Ggo8GdIgWv9PJVqBcKReCnAyNfURfJ3m0yp+6S2/U66X8QDecFHKpHjhT VgqbTTTFaLP0qfBn3ouVVNYjR7ZkCxLAzJrg+hr1NeMaDVayWyUVhjhYN9WDdrXQ+bPUT+ ebcMQ8sEcJVU7dQh2iIl5JB5GWzeVi89yhEVdbL1kG8Tv5w9cXYQItwOX9WXuQ== 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=1715281723; 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=WrVSG+zaU2GvNnoOxjIi1a8SO5j6YYnnNYJyZcsOhwQ=; b=i7aeAlW2ct6XAEOxN83Sv7S3bIwpPlRdwPWg93ObYcFDv4I2VPVCXfhxfSLhV8KsW6NJr3 kXQUJoNhxTbFC7ssUFFPFBK9kYbJZNOfEo9NaTVlXXjVMD4qklAjdXfe6XKS+CmbalszAd IVvI4p/znJze7O4nK4jRSo8gUdPkgoak1fLLyv2hZwQvb9h5Cb1+IJi7FN4YrsfdiQ6ms5 dMAvwycSoGQYNQz3j19sYMCzfvkNu6g9kqxvMg9zwMjYPwksirnqxKpbukEUQb1fK9J3x+ flOjvHGP1iP4aljT8V1L/quuQTTTOiK2ix0irm12A79Ejv4v3hNh/oVa1PQSUw== 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 4Vb1kz2rDfz1L09; Thu, 9 May 2024 19:08:43 +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 449J8hC0025686; Thu, 9 May 2024 19:08:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 449J8hnS025683; Thu, 9 May 2024 19:08:43 GMT (envelope-from git) Date: Thu, 9 May 2024 19:08:43 GMT Message-Id: <202405091908.449J8hnS025683@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 2f31a5eb75f1 - main - sound: Remove nmix variable from mixer_oss_mixerinfo() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 2f31a5eb75f1e47b5c49f574e8ce48d2c863e9d3 Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=2f31a5eb75f1e47b5c49f574e8ce48d2c863e9d3 commit 2f31a5eb75f1e47b5c49f574e8ce48d2c863e9d3 Author: Christos Margiolis AuthorDate: 2024-05-09 19:07:48 +0000 Commit: Christos Margiolis CommitDate: 2024-05-09 19:07:48 +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 --- 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);