Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp407642pxx; Thu, 29 Oct 2020 05:38:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyK5FM6S5TSG+5zQhwL4KYSgs88qQ+W6vMdL6SuwuOxycA64y69ahuFGEwYsGzfyTDJnqsG X-Received: by 2002:a17:907:a8d:: with SMTP id by13mr3642515ejc.295.1603975129963; Thu, 29 Oct 2020 05:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603975129; cv=none; d=google.com; s=arc-20160816; b=yv5uPOXrTeQDKvYswA0ccS/D4zF0ihn0ECGQm1MikfLi90831oxjEyLSeNlz1tFlRT GJg19TzausWc4v88A36TVcdIWVGlhOGBXMMngdoH6BtNo7cKb5fYc/iJBXtRbCbUlyjR 27OUwEC7G/JlMob6SjdDoyUgpz1UjEHTcb0/KOcz2es/4+N7mE6hBE7V7kyNCiTotl8t 9XM1FzTeNbiow6e4+tsxpVzvsHt8Mt3UvRvJNDm3nX1c6NaFqzRG7XJILPDwYFIUakHs BMwa56ew3jRtVpgoeqkDvEIgCoTMDa6V/GMYc4hS5b1k1zY77iaGOV7KssKS28I91UGP rRzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=UrnBu5qO7obnSOoUffRo85UR2VUdl4IGgFq1pOtEkW4=; b=PQmuGpWxe+7zXw6FSOv8X3bfEgWRscKrVsviHLl9jCZI1WyPUA2k+THC79VA+k5dLj bnJD6GHSF96y5hS2o6iCfXJft1Uuh2g1bS9sBWJGbNNwSLNjZCyX8oG82y2ncg+DhL+E Z8a6QnxDtmUNEh5PGEoNG5f/T4kss+ObBrcUelhslxHcEeXos2wXU5J/lZLQTo0rJdzE Wro11V3nPu5xoKnAO3KhRAnQM8Qj2S+0+AgWnxWEs0VDrhLfU4rUDqdtWO5sa9q8tpUx klML83uLt3qIrxxXT+v2GwZsEVFa4V6pNUunhk8ipnrJ/CkMJFImJLzbLJPFaZcsG6pg i3XQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si2020537edd.30.2020.10.29.05.38.26; Thu, 29 Oct 2020 05:38:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726452AbgJ2MfB (ORCPT + 99 others); Thu, 29 Oct 2020 08:35:01 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:51992 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbgJ2MfA (ORCPT ); Thu, 29 Oct 2020 08:35:00 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kY78f-0049Z4-HE; Thu, 29 Oct 2020 13:34:45 +0100 Date: Thu, 29 Oct 2020 13:34:45 +0100 From: Andrew Lunn To: Zou Wei Cc: peppe.cavallaro@st.com, alexandre.torgue@st.com, joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org, mcoquelin.stm32@gmail.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] net: stmmac: platform: remove useless if/else Message-ID: <20201029123445.GH933237@lunn.ch> References: <1603938832-53705-1-git-send-email-zou_wei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1603938832-53705-1-git-send-email-zou_wei@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 29, 2020 at 10:33:52AM +0800, Zou Wei wrote: > Fix the following coccinelle report: > > ./drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:233:6-8: > WARNING: possible condition with no effect (if == else) > > Both branches are the same, so remove the else if/else altogether. > > Reported-by: Hulk Robot > Signed-off-by: Zou Wei > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c > index af34a4c..f6c69d0 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c > @@ -230,8 +230,6 @@ static int stmmac_mtl_setup(struct platform_device *pdev, > plat->tx_sched_algorithm = MTL_TX_ALGORITHM_WFQ; > else if (of_property_read_bool(tx_node, "snps,tx-sched-dwrr")) > plat->tx_sched_algorithm = MTL_TX_ALGORITHM_DWRR; > - else if (of_property_read_bool(tx_node, "snps,tx-sched-sp")) > - plat->tx_sched_algorithm = MTL_TX_ALGORITHM_SP; > else > plat->tx_sched_algorithm = MTL_TX_ALGORITHM_SP; I actually prefer the original code. Code is also documentation. It documents the fact, if "snps,tx-sched-sp" is in device tree, we use MTL_TX_ALGORITHM_SP, but otherwise we default to MTL_TX_ALGORITHM_SP. As with my suggestion for forcedeth, i would move the default setting to before the whole if/else if/else block to document it is the default. Or just consider this a false positive and leave it alone. I can see value in the coccinelle script, but it is going to have a lot of false positive cases, so i'm not sure there is value in working around them all. Andrew