All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] USB: 6fire: signedness bug in usb6fire_pcm_prepare()
@ 2011-02-07 17:25 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2011-02-07 17:25 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel, Torsten Schenk, kernel-janitors

rt->rate is an unsigned char so it's never equal to -1.  It's not a huge
problem because the invalid rate is caught inside the call to
usb6fire_pcm_set_rate() which returns -EINVAL.  But if we fix the test
then it prints out the correct error message so that's good.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
index 705c88e..ba62c74 100644
--- a/sound/usb/6fire/pcm.c
+++ b/sound/usb/6fire/pcm.c
@@ -493,13 +493,12 @@ static int usb6fire_pcm_prepare(struct snd_pcm_substream *alsa_sub)
 	sub->period_off = 0;
 
 	if (rt->stream_state = STREAM_DISABLED) {
-		rt->rate = -1;
 		for (i = 0; i < ARRAY_SIZE(rates); i++)
 			if (alsa_rt->rate = rates[i]) {
 				rt->rate = i;
 				break;
 			}
-		if (rt->rate = -1) {
+		if (i = ARRAY_SIZE(rates)) {
 			mutex_unlock(&rt->stream_mutex);
 			snd_printk("invalid rate %d in prepare.\n",
 					alsa_rt->rate);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch] USB: 6fire: signedness bug in usb6fire_pcm_prepare()
@ 2011-02-07 17:25 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2011-02-07 17:25 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel, Torsten Schenk, kernel-janitors

rt->rate is an unsigned char so it's never equal to -1.  It's not a huge
problem because the invalid rate is caught inside the call to
usb6fire_pcm_set_rate() which returns -EINVAL.  But if we fix the test
then it prints out the correct error message so that's good.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
index 705c88e..ba62c74 100644
--- a/sound/usb/6fire/pcm.c
+++ b/sound/usb/6fire/pcm.c
@@ -493,13 +493,12 @@ static int usb6fire_pcm_prepare(struct snd_pcm_substream *alsa_sub)
 	sub->period_off = 0;
 
 	if (rt->stream_state == STREAM_DISABLED) {
-		rt->rate = -1;
 		for (i = 0; i < ARRAY_SIZE(rates); i++)
 			if (alsa_rt->rate == rates[i]) {
 				rt->rate = i;
 				break;
 			}
-		if (rt->rate == -1) {
+		if (i == ARRAY_SIZE(rates)) {
 			mutex_unlock(&rt->stream_mutex);
 			snd_printk("invalid rate %d in prepare.\n",
 					alsa_rt->rate);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] USB: 6fire: signedness bug in usb6fire_pcm_prepare()
  2011-02-07 17:25 ` Dan Carpenter
@ 2011-02-07 17:30   ` Takashi Iwai
  -1 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2011-02-07 17:30 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: alsa-devel, Torsten Schenk, kernel-janitors

At Mon, 7 Feb 2011 20:25:19 +0300,
Dan Carpenter wrote:
> 
> rt->rate is an unsigned char so it's never equal to -1.  It's not a huge
> problem because the invalid rate is caught inside the call to
> usb6fire_pcm_set_rate() which returns -EINVAL.  But if we fix the test
> then it prints out the correct error message so that's good.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Applied now.  Thanks.


Takashi

> diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
> index 705c88e..ba62c74 100644
> --- a/sound/usb/6fire/pcm.c
> +++ b/sound/usb/6fire/pcm.c
> @@ -493,13 +493,12 @@ static int usb6fire_pcm_prepare(struct snd_pcm_substream *alsa_sub)
>  	sub->period_off = 0;
>  
>  	if (rt->stream_state = STREAM_DISABLED) {
> -		rt->rate = -1;
>  		for (i = 0; i < ARRAY_SIZE(rates); i++)
>  			if (alsa_rt->rate = rates[i]) {
>  				rt->rate = i;
>  				break;
>  			}
> -		if (rt->rate = -1) {
> +		if (i = ARRAY_SIZE(rates)) {
>  			mutex_unlock(&rt->stream_mutex);
>  			snd_printk("invalid rate %d in prepare.\n",
>  					alsa_rt->rate);
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] USB: 6fire: signedness bug in usb6fire_pcm_prepare()
@ 2011-02-07 17:30   ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2011-02-07 17:30 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: alsa-devel, Torsten Schenk, kernel-janitors

At Mon, 7 Feb 2011 20:25:19 +0300,
Dan Carpenter wrote:
> 
> rt->rate is an unsigned char so it's never equal to -1.  It's not a huge
> problem because the invalid rate is caught inside the call to
> usb6fire_pcm_set_rate() which returns -EINVAL.  But if we fix the test
> then it prints out the correct error message so that's good.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Applied now.  Thanks.


Takashi

> diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
> index 705c88e..ba62c74 100644
> --- a/sound/usb/6fire/pcm.c
> +++ b/sound/usb/6fire/pcm.c
> @@ -493,13 +493,12 @@ static int usb6fire_pcm_prepare(struct snd_pcm_substream *alsa_sub)
>  	sub->period_off = 0;
>  
>  	if (rt->stream_state == STREAM_DISABLED) {
> -		rt->rate = -1;
>  		for (i = 0; i < ARRAY_SIZE(rates); i++)
>  			if (alsa_rt->rate == rates[i]) {
>  				rt->rate = i;
>  				break;
>  			}
> -		if (rt->rate == -1) {
> +		if (i == ARRAY_SIZE(rates)) {
>  			mutex_unlock(&rt->stream_mutex);
>  			snd_printk("invalid rate %d in prepare.\n",
>  					alsa_rt->rate);
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-07 17:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-07 17:25 [patch] USB: 6fire: signedness bug in usb6fire_pcm_prepare() Dan Carpenter
2011-02-07 17:25 ` Dan Carpenter
2011-02-07 17:30 ` Takashi Iwai
2011-02-07 17:30   ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.