From patchwork Wed Sep 6 19:50:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9941229 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 5D72F602CC for ; Wed, 6 Sep 2017 19:50:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4396D200E7 for ; Wed, 6 Sep 2017 19:50:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37EDA1FF1D; Wed, 6 Sep 2017 19:50:25 +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 313A420144 for ; Wed, 6 Sep 2017 19:50:24 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id A5B91266FCB; Wed, 6 Sep 2017 21:50:22 +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 A2FB7267419; Wed, 6 Sep 2017 21:50:21 +0200 (CEST) Received: from mout.web.de (mout.web.de [212.227.15.4]) by alsa0.perex.cz (Postfix) with ESMTP id 08E03266A8A for ; Wed, 6 Sep 2017 21:50:19 +0200 (CEST) Received: from [192.168.1.2] ([77.182.162.119]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LoLKj-1dEggs3x7J-00gI7g; Wed, 06 Sep 2017 21:50:12 +0200 From: SF Markus Elfring To: alsa-devel@alsa-project.org, Bhumika Goyal , David Howells , Ingo Molnar , Jaroslav Kysela , Takashi Iwai References: Message-ID: <35478693-5c8a-38b8-d2b3-fc8a964d5137@users.sourceforge.net> Date: Wed, 6 Sep 2017 21:50:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:mIaIPnDAqH/J8e7khRkupevjYWmexlhXrQyuTkvymeFxNAWDgTT hsnBtm1eM/j/Z7IGPLFF831sD70+OHH5wCaRt7xJXb5hPZxZ0JuUx4lFzhnvvAQgcDuW5Rs zOCbTk3QzPwWNJxK63TJYHuP8UmGASPLIm3LxMoTz6aIDpLI3uFqeboW2YV4+FXknbCbWg4 V7+AjxjHpSBQkxjEUgong== X-UI-Out-Filterresults: notjunk:1; V01:K0:yiLOVq55ut8=:TjgBqL9ZmxeZ/r9TQPT3Tz j2XVNZKRm5EpOHE9HOAJSIyEK/z5DoL1TQ99jHXWMkFBF4wzch9NQafHgs7DIPxLefZ6+ECyK 7T2+X+YcqwObEkQ9CQgeqaIuJTvLajidiHjt1fEfa5HGBVygNtEM14z860XniN/yFjj2/Nc3q IQ+drP7wEgiu6cJ4cTmsLl7GY579M0mWIyRofwu57L8XRDlF6mWBS46f2NiJt42fhJdfn4H8b RXOQJ5bby99JKtXA0NqhUD0+DIqkuEJ5/HPBuwdl9R5ex5ixGMP9raVmLYxxmI4n/ox5KeLVc A2Vj5C+INBHmFvAAxZkDFE4c1Z5yfiIMLMR3JBPQyXv2xTizZLUoSznVY8rWdc535xnNMFno/ tBpeaueoajwjEIfQDTgHO3qRR0T+5Jg0u0mVLkioLyhBIsyTTu5JD2qMVbMq0O/oHsvY6my/b czCi90FYsyFITKXdjI0PZlyTV4fDTn1V3Ng37uFVNjXEO1AlpPZNghJGaVQKfC0xr24ILIEke Y0G6wVOxpuE7M40aA4hI07fMrjTVE/X+Vq5dAfJHyjPSJel1fU6Q7Wg4aEvAM9515db/OllFo WBfrCeRgM2FtTgNIXNCKa7Q8Ddtw5eqMU5J/4qx35hV4YSPv0L+FmbdK/K0cdn9NEe4cVshq/ kmjpd6lzY2IRnBxJazcx9dDkB/ApjxbeKVxEjEYpqbMP5C7D/2q/P7gp56UGBR2Apzx170WkU 9H2GYtdfbjDvGYK11nWzvz3gGKXKuUJqbf3xZQMyssq5XKjYFG6wTGcGa/FZXHsT4ld5lWGVn p7owhAyZ7buaR5RN67VQG3Zl/+Wi8Jz8NA2i8LOtP9amf+6nUc= Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH 3/3] ALSA: ymfpci: Adjust 17 checks for null pointers 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: Wed, 6 Sep 2017 21:30:37 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written … Thus fix affected source code places. Signed-off-by: Markus Elfring --- sound/pci/ymfpci/ymfpci_main.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 8ca2e41e5827..4da6e43ad007 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -308,7 +308,7 @@ static void snd_ymfpci_pcm_interrupt(struct snd_ymfpci *chip, struct snd_ymfpci_ if ((ypcm = voice->ypcm) == NULL) return; - if (ypcm->substream == NULL) + if (!ypcm->substream) return; spin_lock(&chip->reg_lock); if (ypcm->running) { @@ -396,7 +396,7 @@ static int snd_ymfpci_playback_trigger(struct snd_pcm_substream *substream, int result = 0; spin_lock(&chip->reg_lock); - if (ypcm->voices[0] == NULL) { + if (!ypcm->voices[0]) { result = -EINVAL; goto __unlock; } @@ -405,7 +405,7 @@ static int snd_ymfpci_playback_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_RESUME: chip->ctrl_playback[ypcm->voices[0]->number + 1] = cpu_to_le32(ypcm->voices[0]->bank_addr); - if (ypcm->voices[1] != NULL && !ypcm->use_441_slot) + if (ypcm->voices[1] && !ypcm->use_441_slot) chip->ctrl_playback[ypcm->voices[1]->number + 1] = cpu_to_le32(ypcm->voices[1]->bank_addr); ypcm->running = 1; break; @@ -418,7 +418,7 @@ static int snd_ymfpci_playback_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_SUSPEND: chip->ctrl_playback[ypcm->voices[0]->number + 1] = 0; - if (ypcm->voices[1] != NULL && !ypcm->use_441_slot) + if (ypcm->voices[1] && !ypcm->use_441_slot) chip->ctrl_playback[ypcm->voices[1]->number + 1] = 0; ypcm->running = 0; break; @@ -468,16 +468,16 @@ static int snd_ymfpci_pcm_voice_alloc(struct snd_ymfpci_pcm *ypcm, int voices) { int err; - if (ypcm->voices[1] != NULL && voices < 2) { + if (ypcm->voices[1] && voices < 2) { snd_ymfpci_voice_free(ypcm->chip, ypcm->voices[1]); ypcm->voices[1] = NULL; } - if (voices == 1 && ypcm->voices[0] != NULL) + if (voices == 1 && ypcm->voices[0]) return 0; /* already allocated */ - if (voices == 2 && ypcm->voices[0] != NULL && ypcm->voices[1] != NULL) + if (voices == 2 && ypcm->voices[0] && ypcm->voices[1]) return 0; /* already allocated */ if (voices > 1) { - if (ypcm->voices[0] != NULL && ypcm->voices[1] == NULL) { + if (ypcm->voices[0] && !ypcm->voices[1]) { snd_ymfpci_voice_free(ypcm->chip, ypcm->voices[0]); ypcm->voices[0] = NULL; } @@ -655,7 +655,7 @@ static int snd_ymfpci_playback_hw_free(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_ymfpci_pcm *ypcm; - if (runtime->private_data == NULL) + if (!runtime->private_data) return 0; ypcm = runtime->private_data; @@ -913,7 +913,7 @@ static int snd_ymfpci_playback_open_1(struct snd_pcm_substream *substream) return err; ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL); - if (ypcm == NULL) + if (!ypcm) return -ENOMEM; ypcm->chip = chip; ypcm->type = PLAYBACK_VOICE; @@ -1038,7 +1038,7 @@ static int snd_ymfpci_capture_open(struct snd_pcm_substream *substream, return err; ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL); - if (ypcm == NULL) + if (!ypcm) return -ENOMEM; ypcm->chip = chip; ypcm->type = capture_bank_number + CAPTURE_REC; @@ -1116,7 +1116,7 @@ static int snd_ymfpci_capture_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_ymfpci_pcm *ypcm = runtime->private_data; - if (ypcm != NULL) { + if (ypcm) { chip->capture_substream[ypcm->capture_bank_number] = NULL; snd_ymfpci_hw_stop(chip); } @@ -1310,7 +1310,8 @@ static int snd_ymfpci_spdif_default_put(struct snd_kcontrol *kcontrol, spin_lock_irq(&chip->reg_lock); change = chip->spdif_bits != val; chip->spdif_bits = val; - if ((snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & 1) && chip->pcm_spdif == NULL) + if ((snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & 1) && + !chip->pcm_spdif) snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_bits); spin_unlock_irq(&chip->reg_lock); return change; @@ -2376,7 +2377,7 @@ int snd_ymfpci_create(struct snd_card *card, return err; chip = kzalloc(sizeof(*chip), GFP_KERNEL); - if (chip == NULL) { + if (!chip) { pci_disable_device(pci); return -ENOMEM; } @@ -2437,7 +2438,7 @@ int snd_ymfpci_create(struct snd_card *card, #ifdef CONFIG_PM_SLEEP chip->saved_regs = kmalloc(YDSXGR_NUM_SAVED_REGS * sizeof(u32), GFP_KERNEL); - if (chip->saved_regs == NULL) { + if (!chip->saved_regs) { err = -ENOMEM; goto free_chip; }