From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933343AbcAYX0Q (ORCPT ); Mon, 25 Jan 2016 18:26:16 -0500 Received: from smtp310.phy.lolipop.jp ([210.157.22.78]:51564 "EHLO smtp310.phy.lolipop.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932544AbcAYX0O (ORCPT ); Mon, 25 Jan 2016 18:26:14 -0500 X-Greylist: delayed 505 seconds by postgrey-1.27 at vger.kernel.org; Mon, 25 Jan 2016 18:26:14 EST Subject: Re: [PATCH] ALSA: bebob: Use a signed return type for get_formation_index To: Lucas Tanure , Clemens Ladisch , Jaroslav Kysela References: <1453757423-9076-1-git-send-email-tanure@linux.com> Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org From: Takashi Sakamoto X-Enigmail-Draft-Status: N1110 Message-ID: <56A6AD19.1090800@sakamocchi.jp> Date: Tue, 26 Jan 2016 08:17:45 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1453757423-9076-1-git-send-email-tanure@linux.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 Tested-by: Takashi Sakamoto This should go for -stable and 4.5-rc2. CC: stable@vger.kernel.org Regards Takashi Sakamoto