mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Lucas Tanure <tanure@linux.com>,
	Clemens Ladisch <clemens@ladisch.de>,
	Jaroslav Kysela <perex@perex.cz>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: bebob: Use a signed return type for get_formation_index
Date: Tue, 26 Jan 2016 08:17:45 +0900	[thread overview]
Message-ID: <56A6AD19.1090800@sakamocchi.jp> (raw)
In-Reply-To: <1453757423-9076-1-git-send-email-tanure@linux.com>

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

  reply	other threads:[~2016-01-25 23:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-25 21:30 Lucas Tanure
2016-01-25 23:17 ` Takashi Sakamoto [this message]
2016-01-26  6:03 ` [alsa-devel] " 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=56A6AD19.1090800@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tanure@linux.com \
    /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

Powered by JetHome