Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: [PATCH 1/5] ALSA: pcm: snd_interval_step: drop the min parameter
Date: Sun, 07 Sep 2014 21:43:07 +0200	[thread overview]
Message-ID: <540CB54B.8080701@ladisch.de> (raw)
In-Reply-To: <540CB520.50909@ladisch.de>

The min parameter was not used by any caller.  And if it were used,
underflows in the calculations could lead to incorrect results.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
---
 sound/core/pcm_lib.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 9acc77e..6fd5e1c 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1113,16 +1113,16 @@ int snd_interval_list(struct snd_interval *i, unsigned int count,

 EXPORT_SYMBOL(snd_interval_list);

-static int snd_interval_step(struct snd_interval *i, unsigned int min, unsigned int step)
+static int snd_interval_step(struct snd_interval *i, unsigned int step)
 {
 	unsigned int n;
 	int changed = 0;
-	n = (i->min - min) % step;
+	n = i->min % step;
 	if (n != 0 || i->openmin) {
 		i->min += step - n;
 		changed = 1;
 	}
-	n = (i->max - min) % step;
+	n = i->max % step;
 	if (n != 0 || i->openmax) {
 		i->max -= n;
 		changed = 1;
@@ -1427,7 +1427,7 @@ static int snd_pcm_hw_rule_step(struct snd_pcm_hw_params *params,
 				struct snd_pcm_hw_rule *rule)
 {
 	unsigned long step = (unsigned long) rule->private;
-	return snd_interval_step(hw_param_interval(params, rule->var), 0, step);
+	return snd_interval_step(hw_param_interval(params, rule->var), step);
 }

 /**

  reply	other threads:[~2014-09-07 19:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-07 19:42 [PATCH 0/5] miscellaneous patches for 3.18 Clemens Ladisch
2014-09-07 19:43 ` Clemens Ladisch [this message]
2014-09-07 19:43 ` [PATCH 0/5] ALSA: pcm: snd_interval_step: fix changes of open intervals Clemens Ladisch
2014-09-07 19:44 ` [PATCH 3/5] ALSA: usb-audio: add MIDI port names for the Yamaha MOTIF XF Clemens Ladisch
2014-09-07 19:45 ` [PATCH 4/5] ALSA: virtuoso: add one more headphone impedance setting Clemens Ladisch
2014-09-07 19:47 ` [PATCH 5/5] ALSA: virtuoso: add Xonar Essence STX II daughterboard support Clemens Ladisch
2014-09-08  9:00 ` [PATCH 0/5] miscellaneous patches for 3.18 Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=540CB54B.8080701@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox