From patchwork Thu Apr 19 13:53:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 10350895 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 0676F60231 for ; Thu, 19 Apr 2018 14:40:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA1FE28A90 for ; Thu, 19 Apr 2018 14:40:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8B2A28ADD; Thu, 19 Apr 2018 14:40:31 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52A0028AE3 for ; Thu, 19 Apr 2018 14:40:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752593AbeDSOkT (ORCPT ); Thu, 19 Apr 2018 10:40:19 -0400 Received: from gateway31.websitewelcome.com ([192.185.143.31]:23452 "EHLO gateway31.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752876AbeDSOkS (ORCPT ); Thu, 19 Apr 2018 10:40:18 -0400 X-Greylist: delayed 1416 seconds by postgrey-1.27 at vger.kernel.org; Thu, 19 Apr 2018 10:40:18 EDT Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway31.websitewelcome.com (Postfix) with ESMTP id CDDE95A1E0 for ; Thu, 19 Apr 2018 08:53:17 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id 99zxfHSm2QUwq99zxf3Pel; Thu, 19 Apr 2018 08:53:17 -0500 X-Authority-Reason: nr=8 Received: from [189.175.6.211] (port=39794 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1f99zx-001dxw-AF; Thu, 19 Apr 2018 08:53:17 -0500 Date: Thu, 19 Apr 2018 08:53:16 -0500 From: "Gustavo A. R. Silva" To: Masahiro Yamada , Adrian Hunter , Ulf Hansson Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] mmc: sdhci-cadence: fix logically and structurally dead code Message-ID: <20180419135316.GA14790@embeddedor.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.175.6.211 X-Source-L: No X-Exim-ID: 1f99zx-001dxw-AF X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.175.6.211]:39794 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 9 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the code block inside the for loop will never execute more than once, because the function returns inmediately after the first iteration, hence the execution of the code at the second iteration is structurally dead and, code at line 281: return 0; is never reached. Based on the code comments, it seems that the actual intention is to execute the code inside the for loop twice instead of once. So, fix this issue by removing the return statement inside the for loop and replace the "return 0" with "return ret". Addresses-Coverity-ID: 1468009 ("Logically dead code") Addresses-Coverity-ID: 1468002 ("Structurally dead code") Fixes: 213fae74318b ("mmc: sdhci-cadence: send tune request twice to work around errata") Signed-off-by: Gustavo A. R. Silva --- drivers/mmc/host/sdhci-cadence.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c index bc30d16..facbad8 100644 --- a/drivers/mmc/host/sdhci-cadence.c +++ b/drivers/mmc/host/sdhci-cadence.c @@ -275,10 +275,9 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host *host, unsigned int val) !(tmp & SDHCI_CDNS_HRS06_TUNE_UP), 0, 1); - return ret; } - return 0; + return ret; } static int sdhci_cdns_execute_tuning(struct mmc_host *mmc, u32 opcode)