Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1317313 > unrolled thread

[PATCH] ALSA: bebob: Use a signed return type for get_formation_index

Started byLucas Tanure <tanure@linux.com>
First post2016-01-25 22:40 +0100
Last post2016-01-26 07:10 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ALSA: bebob: Use a signed return type for get_formation_index Lucas Tanure <tanure@linux.com> - 2016-01-25 22:40 +0100
    Re: [PATCH] ALSA: bebob: Use a signed return type for  get_formation_index Takashi Sakamoto <o-takashi@sakamocchi.jp> - 2016-01-26 00:30 +0100
    Re: [alsa-devel] [PATCH] ALSA: bebob: Use a signed return type for get_formation_index Takashi Iwai <tiwai@suse.de> - 2016-01-26 07:10 +0100

#1317313 — [PATCH] ALSA: bebob: Use a signed return type for get_formation_index

FromLucas Tanure <tanure@linux.com>
Date2016-01-25 22:40 +0100
Subject[PATCH] ALSA: bebob: Use a signed return type for get_formation_index
Message-ID<qUX1E-1E8-1@gated-at.bofh.it>
The return type "unsigned int" was used by the get_formation_index function
despite of the aspect that it will eventually return a negative	error code.
So, change to signed int and get index by reference in the parameters.

Done with the help of Coccinelle.

Signed-off-by: Lucas Tanure <tanure@linux.com>
---
 sound/firewire/bebob/bebob_stream.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
index 926e5dc..79940e3 100644
--- a/sound/firewire/bebob/bebob_stream.c
+++ b/sound/firewire/bebob/bebob_stream.c
@@ -47,14 +47,15 @@ static const unsigned int bridgeco_freq_table[] = {
 	[6] = 0x07,
 };
 
-static unsigned int
-get_formation_index(unsigned int rate)
+static int
+get_formation_index(unsigned int rate, unsigned int *index)
 {
 	unsigned int i;
 
 	for (i = 0; i < ARRAY_SIZE(snd_bebob_rate_table); i++) {
 		if (snd_bebob_rate_table[i] == rate)
-			return i;
+			*index = i;
+			return 0;
 	}
 	return -EINVAL;
 }
@@ -425,7 +426,9 @@ make_both_connections(struct snd_bebob *bebob, unsigned int rate)
 		goto end;
 
 	/* confirm params for both streams */
-	index = get_formation_index(rate);
+	err = get_formation_index(rate, &index);
+	if (err < 0)
+		goto end;
 	pcm_channels = bebob->tx_stream_formations[index].pcm;
 	midi_channels = bebob->tx_stream_formations[index].midi;
 	err = amdtp_am824_set_parameters(&bebob->tx_stream, rate,
-- 
2.7.0

[toc] | [next] | [standalone]


#1317402 — Re: [PATCH] ALSA: bebob: Use a signed return type for get_formation_index

FromTakashi Sakamoto <o-takashi@sakamocchi.jp>
Date2016-01-26 00:30 +0100
SubjectRe: [PATCH] ALSA: bebob: Use a signed return type for get_formation_index
Message-ID<qUYK6-2Ts-15@gated-at.bofh.it>
In reply to#1317313
On Jan 26 2016 06:30, Lucas Tanure wrote:
> The return type "unsigned int" was used by the get_formation_index function
> despite of the aspect that it will eventually return a negative	error code.
> So, change to signed int and get index by reference in the parameters.
> 
> Done with the help of Coccinelle.
> 
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
>  sound/firewire/bebob/bebob_stream.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
> index 926e5dc..79940e3 100644
> --- a/sound/firewire/bebob/bebob_stream.c
> +++ b/sound/firewire/bebob/bebob_stream.c
> @@ -47,14 +47,15 @@ static const unsigned int bridgeco_freq_table[] = {
>  	[6] = 0x07,
>  };
>  
> -static unsigned int
> -get_formation_index(unsigned int rate)
> +static int
> +get_formation_index(unsigned int rate, unsigned int *index)
>  {
>  	unsigned int i;
>  
>  	for (i = 0; i < ARRAY_SIZE(snd_bebob_rate_table); i++) {
>  		if (snd_bebob_rate_table[i] == rate)
> -			return i;
> +			*index = i;
> +			return 0;
>  	}
>  	return -EINVAL;
>  }
> @@ -425,7 +426,9 @@ make_both_connections(struct snd_bebob *bebob, unsigned int rate)
>  		goto end;
>  
>  	/* confirm params for both streams */
> -	index = get_formation_index(rate);
> +	err = get_formation_index(rate, &index);
> +	if (err < 0)
> +		goto end;
>  	pcm_channels = bebob->tx_stream_formations[index].pcm;
>  	midi_channels = bebob->tx_stream_formations[index].midi;
>  	err = amdtp_am824_set_parameters(&bebob->tx_stream, rate,

Indeed, it's my mistake.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

This should go for -stable and 4.5-rc2.
CC: stable@vger.kernel.org


Regards

Takashi Sakamoto

[toc] | [prev] | [next] | [standalone]


#1317551 — Re: [alsa-devel] [PATCH] ALSA: bebob: Use a signed return type for get_formation_index

FromTakashi Iwai <tiwai@suse.de>
Date2016-01-26 07:10 +0100
SubjectRe: [alsa-devel] [PATCH] ALSA: bebob: Use a signed return type for get_formation_index
Message-ID<qV4Zb-7Fd-7@gated-at.bofh.it>
In reply to#1317313
On Mon, 25 Jan 2016 22:30:23 +0100,
Lucas Tanure wrote:
> 
> The return type "unsigned int" was used by the get_formation_index function
> despite of the aspect that it will eventually return a negative	error code.
> So, change to signed int and get index by reference in the parameters.
> 
> Done with the help of Coccinelle.
> 
> Signed-off-by: Lucas Tanure <tanure@linux.com>

Applied, thanks.


Takashi

> ---
>  sound/firewire/bebob/bebob_stream.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
> index 926e5dc..79940e3 100644
> --- a/sound/firewire/bebob/bebob_stream.c
> +++ b/sound/firewire/bebob/bebob_stream.c
> @@ -47,14 +47,15 @@ static const unsigned int bridgeco_freq_table[] = {
>  	[6] = 0x07,
>  };
>  
> -static unsigned int
> -get_formation_index(unsigned int rate)
> +static int
> +get_formation_index(unsigned int rate, unsigned int *index)
>  {
>  	unsigned int i;
>  
>  	for (i = 0; i < ARRAY_SIZE(snd_bebob_rate_table); i++) {
>  		if (snd_bebob_rate_table[i] == rate)
> -			return i;
> +			*index = i;
> +			return 0;
>  	}
>  	return -EINVAL;
>  }
> @@ -425,7 +426,9 @@ make_both_connections(struct snd_bebob *bebob, unsigned int rate)
>  		goto end;
>  
>  	/* confirm params for both streams */
> -	index = get_formation_index(rate);
> +	err = get_formation_index(rate, &index);
> +	if (err < 0)
> +		goto end;
>  	pcm_channels = bebob->tx_stream_formations[index].pcm;
>  	midi_channels = bebob->tx_stream_formations[index].midi;
>  	err = amdtp_am824_set_parameters(&bebob->tx_stream, rate,
> -- 
> 2.7.0
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web