From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754652AbcHVHUW (ORCPT ); Mon, 22 Aug 2016 03:20:22 -0400 Received: from mx01-fr.bfs.de ([193.174.231.67]:54586 "EHLO mx01-fr.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752298AbcHVHUU (ORCPT ); Mon, 22 Aug 2016 03:20:20 -0400 Message-ID: <57BAA7AF.10400@bfs.de> Date: Mon, 22 Aug 2016 09:20:15 +0200 From: walter harms Reply-To: wharms@bfs.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.16) Gecko/20101125 SUSE/3.0.11 Thunderbird/3.0.11 MIME-Version: 1.0 To: SF Markus Elfring CC: alsa-devel@alsa-project.org, Jaroslav Kysela , Takashi Iwai , Vinod Koul , LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() References: <566ABCD9.1060404@users.sourceforge.net> <7233eb00-a941-4935-dce2-7cb907272d41@users.sourceforge.net> <03eac1fe-ff33-1759-9c2a-7914f1c6de45@users.sourceforge.net> In-Reply-To: <03eac1fe-ff33-1759-9c2a-7914f1c6de45@users.sourceforge.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 21.08.2016 21:45, schrieb SF Markus Elfring: > From: Markus Elfring > Date: Sun, 21 Aug 2016 21:26:18 +0200 > > Reduce the scope for the local variables to an if branch. > > Signed-off-by: Markus Elfring > --- > sound/core/compress_offload.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c > index 583d407..b43aec5 100644 > --- a/sound/core/compress_offload.c > +++ b/sound/core/compress_offload.c > @@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params) > static int > snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) > { > - struct snd_compr_params *params; > - int retval; > - > if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) { > /* > * we should allow parameter change only when stream has been > * opened not in other cases > */ > + int retval; > + struct snd_compr_params *params; > + > params = memdup_user((void __user *)arg, sizeof(*params)); > if (IS_ERR(params)) > return PTR_ERR(params); > @@ -578,12 +578,12 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) > stream->runtime->state = SNDRV_PCM_STATE_SETUP; > else > stream->runtime->state = SNDRV_PCM_STATE_PREPARED; > +out: > + kfree(params); > + return retval; > } else { > return -EPERM; > } > -out: > - kfree(params); > - return retval; > } > > static int if would make sense to have if (stream->runtime->state != SNDRV_PCM_STATE_OPEN) return -EPERM; and read adjust the indent. just my 2 cents re, wh