From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754209AbdEQWHC (ORCPT ); Wed, 17 May 2017 18:07:02 -0400 Received: from gateway21.websitewelcome.com ([192.185.45.176]:29642 "EHLO gateway21.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754167AbdEQWG7 (ORCPT ); Wed, 17 May 2017 18:06:59 -0400 Date: Wed, 17 May 2017 17:06:54 -0500 Message-ID: <20170517170654.Horde.cfktFjC4G4wPJvJ8X1ZyUvW@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: Faisal Latif , Shiraz Saleem , Doug Ledford , Sean Hefty , Hal Rosenstock Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [infiniband-hw-i40iw] question about identical code for different branches User-Agent: Horde Application Framework 5 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline 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: 108.167.133.22 X-Exim-ID: 1dB75r-000W17-C8 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:22792 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 1 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: index f4d1368..48fd327 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_virtchnl.c +++ b/drivers/infiniband/hw/i40iw/i40iw_virtchnl.c @@ -443,10 +443,7 @@ enum i40iw_status_code i40iw_vchnl_recv_pf(struct i40iw_sc_dev *dev, if (!dev->vchnl_up) return I40IW_ERR_NOT_READY; if (vchnl_msg->iw_op_code == I40IW_VCHNL_OP_GET_VER) { - if (vchnl_msg->iw_op_ver != I40IW_VCHNL_OP_GET_VER_V0) - vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg); - else - vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg); + vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg); return I40IW_SUCCESS; } for (iw_vf_idx = 0; iw_vf_idx < I40IW_MAX_PE_ENABLED_VF_COUNT; iw_vf_idx++) { What do you think? I'd really appreciate any comment on this. Thank you! -- Gustavo A. R. Silva