From patchwork Tue Nov 14 15:46:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10057855 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 1547C60231 for ; Tue, 14 Nov 2017 15:47:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03B0428F70 for ; Tue, 14 Nov 2017 15:47:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBEAF29710; Tue, 14 Nov 2017 15:47:06 +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=ham 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 945FF28794 for ; Tue, 14 Nov 2017 15:47:04 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id BD7B3266E78; Tue, 14 Nov 2017 16:47:00 +0100 (CET) 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 15C3D266E79; Tue, 14 Nov 2017 16:47:00 +0100 (CET) Received: from mout.web.de (mout.web.de [212.227.15.14]) by alsa0.perex.cz (Postfix) with ESMTP id 9D89C266A73 for ; Tue, 14 Nov 2017 16:46:56 +0100 (CET) Received: from [192.168.1.3] ([77.181.57.53]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MbMg8-1eXOiZ3nZU-00ImKj; Tue, 14 Nov 2017 16:46:16 +0100 To: alsa-devel@alsa-project.org, Bhumika Goyal , Jaroslav Kysela , Takashi Iwai , Takashi Sakamoto From: SF Markus Elfring Message-ID: <8c7233f8-c8e5-8b22-5b58-233f7b6cab1d@users.sourceforge.net> Date: Tue, 14 Nov 2017 16:46:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:TxANsCGGJCFA2ZhHmOwJZG1RtzzZtjTtq06t5YebdB33euE5S3Y lEXtFL5c7SgmXS0+CNYmfTfvAk9iFYMWP1NfUMcT8JlzzJXzz81WqsI2NU+CMdI3RcnEcGo gtsWms7NDQC+PKwZUzXKpFf5oPf79s7fKJh8QDzcKRSp13dJ0GYXXY5XpNcbd8N6GMUg9DE qFp7gIYDypJnXU0jMvYoA== X-UI-Out-Filterresults: notjunk:1; V01:K0:UIY6gQcwh4A=:e3As26kZqxjO12EhVpg0YF vT2NHzzpImI8YKvPdfnPBmyF4nW19DUagXqqJUgirO4SuAk+j+uYKz9iJ2NkWjOMzRUpRZSIv LqyupF677F63gIV3FZFnY3HzVC3CnqmIzHMU/m38YYWD1hKPsrNtCLa+fC3qyHDWn7F9EJRwI Uxam9gWC8iB/qapGAxEcv+tfF8nXasIR2EWq4l/jzM/8R6ZBT0P3y2dakQiFwfvHKLABya3ej 1obN5ZX1gBd6qg2kGCTaNxqBxmb9EOnWTWLMTdS2YuRW2LUi2G6SI63zeAexyRu3UqSLt9JOq dtnF50+86V5kFwa9AOcnhKggF3npjyK0nErGBDu/uqU+CX4XQpP4to/TKVhH2V298K1VlltE+ cRx3X+FoPoDpX+ydVlaNZ5NJJO8H+oFVdb4ff0rPX5xhSAPXS6AJyKE7DHrhSPWKjvWWTOy5S VJQalaFQvNCEgFV2RrCQz+jOUkoH/i8rP9MSTjVg7jXZkKNwg6BYDtSt5xtyUpn2HFDlalsra OkRKaP1MGOsqpfbFh3evLdwmH0mx+vWNm4udSvLg6DaP4K1Ux3o/Eg11KhduRM/VSHsr489Gm mz/7n4Xb36jDq/sAyfrq5/+1la/N3hU+mXu7pF2c+yyE6tCTBwwpEJswJFxlDaeBgzM4isEqS 7eLHb425XtZYsyDgS9IcxKFjZgSxzdgMZ9Ly5Drm5qUVDXIaLfL8w6oD6Z9zS1lVqFZtIyktU rng2dzZRQDKQt1olwlVGdIVzxA0rgKo64plcRoAAFE6GP/IsfxBFEiU1rCkzEVhg6oWI5TTe8 VWo7m1iB1Xln+85x8C5geU8sNjcHcJdsHAtWM5fwJO4Cm7CnZc= Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH] ALSA: emu10k1: Use common error handling code in two functions 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: Tue, 14 Nov 2017 16:40:32 +0100 * Add jump targets so that a bit of exception handling can be better reused at the end of these functions. This issue was detected by using the Coccinelle software. * The script "checkpatch.pl" pointed information out like the following. ERROR: do not use assignment in if condition Thus fix ten affected source code places. Signed-off-by: Markus Elfring --- sound/pci/emu10k1/emu10k1x.c | 62 +++++++++++++++++++++----------------------- sound/pci/emu10k1/emupcm.c | 31 +++++++++++++--------- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 2c2b12a06177..4f700907b566 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -1569,38 +1569,33 @@ static int snd_emu10k1x_probe(struct pci_dev *pci, if (err < 0) return err; - if ((err = snd_emu10k1x_create(card, pci, &chip)) < 0) { - snd_card_free(card); - return err; - } + err = snd_emu10k1x_create(card, pci, &chip); + if (err < 0) + goto free_card; - if ((err = snd_emu10k1x_pcm(chip, 0)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_emu10k1x_pcm(chip, 1)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_emu10k1x_pcm(chip, 2)) < 0) { - snd_card_free(card); - return err; - } + err = snd_emu10k1x_pcm(chip, 0); + if (err < 0) + goto free_card; - if ((err = snd_emu10k1x_ac97(chip)) < 0) { - snd_card_free(card); - return err; - } + err = snd_emu10k1x_pcm(chip, 1); + if (err < 0) + goto free_card; - if ((err = snd_emu10k1x_mixer(chip)) < 0) { - snd_card_free(card); - return err; - } + err = snd_emu10k1x_pcm(chip, 2); + if (err < 0) + goto free_card; + + err = snd_emu10k1x_ac97(chip); + if (err < 0) + goto free_card; + + err = snd_emu10k1x_mixer(chip); + if (err < 0) + goto free_card; - if ((err = snd_emu10k1x_midi(chip)) < 0) { - snd_card_free(card); - return err; - } + err = snd_emu10k1x_midi(chip); + if (err < 0) + goto free_card; snd_emu10k1x_proc_init(chip); @@ -1609,14 +1604,17 @@ static int snd_emu10k1x_probe(struct pci_dev *pci, sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->port, chip->irq); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + err = snd_card_register(card); + if (err < 0) + goto free_card; pci_set_drvdata(pci, card); dev++; return 0; + +free_card: + snd_card_free(card); + return err; } static void snd_emu10k1x_remove(struct pci_dev *pci) diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 2683b9717215..088741f90f91 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -1143,23 +1143,26 @@ static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream) runtime->private_data = epcm; runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_playback; - if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) { - kfree(epcm); - return err; - } - if ((err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX)) < 0) { - kfree(epcm); - return err; - } + err = snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + if (err < 0) + goto free_pcm; + + err = snd_pcm_hw_constraint_minmax(runtime, + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, + 256, + UINT_MAX); + if (err < 0) + goto free_pcm; + if (emu->card_capabilities->emu_model && emu->emu1010.internal_clock == 0) sample_rate = 44100; else sample_rate = 48000; err = snd_pcm_hw_rule_noresample(runtime, sample_rate); - if (err < 0) { - kfree(epcm); - return err; - } + if (err < 0) + goto free_pcm; + mix = &emu->pcm_mixer[substream->number]; for (i = 0; i < 4; i++) mix->send_routing[0][i] = mix->send_routing[1][i] = mix->send_routing[2][i] = i; @@ -1170,6 +1173,10 @@ static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream) mix->epcm = epcm; snd_emu10k1_pcm_mixer_notify(emu, substream->number, 1); return 0; + +free_pcm: + kfree(epcm); + return err; } static int snd_emu10k1_playback_close(struct snd_pcm_substream *substream)