From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933425AbdERPDY (ORCPT ); Thu, 18 May 2017 11:03:24 -0400 Received: from mga06.intel.com ([134.134.136.31]:45714 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932536AbdERPDU (ORCPT ); Thu, 18 May 2017 11:03:20 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,359,1491289200"; d="scan'208";a="89104326" Date: Thu, 18 May 2017 10:03:17 -0500 From: Chien Tin Tung To: Leon Romanovsky Cc: "Gustavo A. R. Silva" , Faisal Latif , Shiraz Saleem , Doug Ledford , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [infiniband-hw-i40iw] question about identical code for different branches Message-ID: <20170518150317.GA10396@ctung-MOBL3.amr.corp.intel.com> References: <20170517170654.Horde.cfktFjC4G4wPJvJ8X1ZyUvW@gator4166.hostgator.com> <20170518050029.GY3616@mtr-leonro.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170518050029.GY3616@mtr-leonro.local> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thu, May 18, 2017 at 08:00:29AM +0300, Leon Romanovsky wrote: > On Wed, May 17, 2017 at 05:06:54PM -0500, Gustavo A. R. Silva wrote: > > > > Hello everybody, > > > > While looking into Coverity ID 1362263 I ran into the following piece of > > code at drivers/infiniband/hw/i40iw/i40iw_virtchnl.c:445: > > > > 445 if (vchnl_msg->iw_op_code == I40IW_VCHNL_OP_GET_VER) { > > 446 if (vchnl_msg->iw_op_ver != I40IW_VCHNL_OP_GET_VER_V0) > > 447 vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg); > > 448 else > > 449 vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg); > > 450 return I40IW_SUCCESS; > > 451 } > > > > The issue is that lines of code 447 and 449 are identical for different > > branches. > > > > My question here is if one of the branches should be modified, or the entire > > _if_ statement replaced? > > > > Maybe a patch like the following could be applied: > > It looks like that you can replace I40IW_VCHNL_OP_GET_VER_V0 with > I40IW_VCHNL_OP_GET_VER and get rid of all places with > I40IW_VCHNL_OP_GET_VER_V0. No. I40IW_VCHNL_OP_GET_VER is iw_op_code and I40IW_VCHNL_OP_GET_VER_V0 is iw_op_ver two different things. Chien