From patchwork Mon Aug 22 08:38:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9293203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B433960B16 for ; Mon, 22 Aug 2016 08:38:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3B7128878 for ; Mon, 22 Aug 2016 08:38:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9894B288AE; Mon, 22 Aug 2016 08:38:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B110D28878 for ; Mon, 22 Aug 2016 08:38:56 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7EB5926681E; Mon, 22 Aug 2016 10:38:55 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E1EE72667A9; Mon, 22 Aug 2016 10:38:48 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4457A2667A9; Mon, 22 Aug 2016 10:38:46 +0200 (CEST) Received: from mout.web.de (mout.web.de [212.227.17.11]) by alsa0.perex.cz (Postfix) with ESMTP id 35DE826671C for ; Mon, 22 Aug 2016 10:38:39 +0200 (CEST) Received: from [192.168.1.3] ([77.182.220.187]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LkhBY-1b3WSc3quy-00aX7x; Mon, 22 Aug 2016 10:38:27 +0200 To: alsa-devel@alsa-project.org, Jaroslav Kysela , Joe Perches , Takashi Iwai , Vinod Koul References: <566ABCD9.1060404@users.sourceforge.net> <7233eb00-a941-4935-dce2-7cb907272d41@users.sourceforge.net> <03eac1fe-ff33-1759-9c2a-7914f1c6de45@users.sourceforge.net> <1471809094.3746.17.camel@perches.com> <14b1efe1-3c1c-4c36-bfc2-19947c190412@users.sourceforge.net> From: SF Markus Elfring Message-ID: <89765506-60f0-8319-5806-29476a36f9f3@users.sourceforge.net> Date: Mon, 22 Aug 2016 10:38:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <14b1efe1-3c1c-4c36-bfc2-19947c190412@users.sourceforge.net> X-Provags-ID: V03:K0:V7WRRB3HX/iqgY68TW1HhOdpVpa7RSZg1tBXClqnOLhO5rLh4q2 guc8E0MpHIz+5S28XeqAXYvrtw69LsncBuSPtMjBZ9ZKX81dto/0I5JFPrO0sEjHwI/DkUy CU+aW8BYpKBFr/A9zMi1h2NOeiaGy3uBkL5EM6Aiwx2L9dD4IK9tAb18vGiyt3QaBdrnHRK 3f5LfXD95c23rdomKqLtA== X-UI-Out-Filterresults: notjunk:1; V01:K0:DfSXH52hoE0=:PKJDVYkQMtmTWc0bt6ghfn EGQzA9YC6DUj1HRpy2ZfvdnmCz4UYkO5n7IEe5jPwS3KzDnN0NFWCxSplsvzzYo6IIFymO1I6 4OzNwYvXvfMAXTvCHKdjG6qeKoaqEAGKSdcbyYZbJsb6e9EmfWvH5SdE5dUDvAqYEzNghzq2d vPPACO/E3PDX3G9iCM9g9FrGjIGnFYz/JejX3FyyzEB8+h0CLp5qPdhJtgN/zA0d1eUOfFxFP HT1a2fin3k21NHVatVCRlfXWnFA1OlgUMJAyFXMCpWWaN1vzLLpmumTYwepR9lDAbGAep9sns KOOnZEsGgaH+Y/6fd03TBbrK7iKPWGovA707SppvB++34j23mOv0TjIX0vy8jamcXYPWHVfDp sp8e3Oe5RXTRy3tFGnO81clq/Yk+LmP0rv2IvlexPn9RCaKvIXZ4ZQCU3seBqeEbS/RnDLdwQ MTumSVCqJ6CHhnj2oF6b/uM6Wisfa9xlFYDKOkcGntCaSTwrV3utG96HX6zmGWweqCQ0JV8rR gq8rciXYDDyd0xrmXKHMVz2wgoSqBDPbooQJGncr450MmRpR4+qUDUkrbtF5R9A9D2phIxuon yDdXXNpXAOU9MEHsXmuGe81WsoYAFGX6IySiUdl2lmON79naBuIRVr+962in0iLrkxBZqWgF5 0gutaTiIZrQ8yM+xp2hvnZIq7+OIoScCcECIQuMim9fhX6CaJRBXRqhdnMx1mvab57aEgDgaD c0vnZMw/Cn1IIvhcJ/ZU6FxogoJtXj5ARwpNJnQCUM9bIUkVG+5ipla+5AcZzLJuF12ttc6wg SA+80FW Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH v2 1/2] ALSA: compress: Restructure source code around an if statement in snd_compr_set_params() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 22 Aug 2016 10:01:52 +0200 * Reverse a condition check. * Reduce the indentation one level then for some source code from a previous if branch. Suggested-by: Joe Perches Signed-off-by: Markus Elfring --- sound/core/compress_offload.c | 62 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 2c49848..a10d139 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -548,43 +548,41 @@ 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 - */ - params = kmalloc(sizeof(*params), GFP_KERNEL); - if (!params) - return -ENOMEM; - if (copy_from_user(params, (void __user *)arg, sizeof(*params))) { - retval = -EFAULT; - goto out; - } + if (stream->runtime->state != SNDRV_PCM_STATE_OPEN) + return -EPERM; + /* + * we should allow parameter change only when stream has been + * opened not in other cases + */ + params = kmalloc(sizeof(*params), GFP_KERNEL); + if (!params) + return -ENOMEM; + if (copy_from_user(params, (void __user *)arg, sizeof(*params))) { + retval = -EFAULT; + goto out; + } - retval = snd_compress_check_input(params); - if (retval) - goto out; + retval = snd_compress_check_input(params); + if (retval) + goto out; - retval = snd_compr_allocate_buffer(stream, params); - if (retval) { - retval = -ENOMEM; - goto out; - } + retval = snd_compr_allocate_buffer(stream, params); + if (retval) { + retval = -ENOMEM; + goto out; + } - retval = stream->ops->set_params(stream, params); - if (retval) - goto out; + retval = stream->ops->set_params(stream, params); + if (retval) + goto out; - stream->metadata_set = false; - stream->next_track = false; + stream->metadata_set = false; + stream->next_track = false; - if (stream->direction == SND_COMPRESS_PLAYBACK) - stream->runtime->state = SNDRV_PCM_STATE_SETUP; - else - stream->runtime->state = SNDRV_PCM_STATE_PREPARED; - } else { - return -EPERM; - } + if (stream->direction == SND_COMPRESS_PLAYBACK) + stream->runtime->state = SNDRV_PCM_STATE_SETUP; + else + stream->runtime->state = SNDRV_PCM_STATE_PREPARED; out: kfree(params); return retval;