From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753747AbdHQXwM (ORCPT ); Thu, 17 Aug 2017 19:52:12 -0400 Received: from gateway22.websitewelcome.com ([192.185.46.187]:17809 "EHLO gateway22.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752872AbdHQXwL (ORCPT ); Thu, 17 Aug 2017 19:52:11 -0400 Subject: Re: [PATCH] IB/core: fix duplicated code for different branches To: Leon Romanovsky References: <20170813005235.GA30629@embeddedgus> <20170813063156.GP24282@mtr-leonro.local> Cc: Doug Ledford , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org From: "Gustavo A. R. Silva" Message-ID: <3ca51638-347f-41cc-7698-42f47c4f0c3e@embeddedor.com> Date: Thu, 17 Aug 2017 18:52:03 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20170813063156.GP24282@mtr-leonro.local> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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.152.158.27 X-Exim-ID: 1diUa8-000Vcl-3J X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.1.70]) [189.152.158.27]:47176 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 11 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Leon, On 08/13/2017 01:31 AM, Leon Romanovsky wrote: > On Sat, Aug 12, 2017 at 07:52:35PM -0500, Gustavo A. R. Silva wrote: >> Refactor code to avoid identical code for different branches. >> >> This issue was detected with the help of Coccinelle. >> >> Signed-off-by: Gustavo A. R. Silva >> --- >> drivers/infiniband/core/cm.c | 4 ---- >> 1 file changed, 4 deletions(-) > > I see that you used the same commit message and title for many patches, > it will be better to have description on what exactly you are removing > and why there is no bug in that code. > Thank you for the suggestion. I will add a note saying that it is up to the maintainer to verify whether the code is applicable or not. The intention of the patch is to point out a duplication of code found by a Coccinelle script. I'm also working on similar issues reported by Coverity. It was tested only by compilation as I don't have the proper hardware to test it on. > >> >> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c >> index 2b4d613..b46262f 100644 >> --- a/drivers/infiniband/core/cm.c >> +++ b/drivers/infiniband/core/cm.c >> @@ -590,8 +590,6 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv) >> link = &(*link)->rb_right; >> else if (be64_lt(service_id, cur_cm_id_priv->id.service_id)) >> link = &(*link)->rb_left; >> - else if (be64_gt(service_id, cur_cm_id_priv->id.service_id)) >> - link = &(*link)->rb_right; >> else >> link = &(*link)->rb_right; >> } >> @@ -619,8 +617,6 @@ static struct cm_id_private * cm_find_listen(struct ib_device *device, >> node = node->rb_right; >> else if (be64_lt(service_id, cm_id_priv->id.service_id)) >> node = node->rb_left; >> - else if (be64_gt(service_id, cm_id_priv->id.service_id)) >> - node = node->rb_right; > > You should remove be64_gt() too. > Thank you for pointing it out. >> else >> node = node->rb_right; >> } >> -- >> 2.5.0 >> -- Gustavo A. R. Silva