linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [infiniband-hw-i40iw] question about identical code for different branches
@ 2017-05-17 22:06 Gustavo A. R. Silva
  2017-05-18  5:00 ` Leon Romanovsky
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-17 22:06 UTC (permalink / raw)
  To: Faisal Latif, Shiraz Saleem, Doug Ledford, Sean Hefty, Hal Rosenstock
  Cc: linux-rdma, linux-kernel


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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-06-01 22:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17 22:06 [infiniband-hw-i40iw] question about identical code for different branches Gustavo A. R. Silva
2017-05-18  5:00 ` Leon Romanovsky
2017-05-18 15:03   ` Chien Tin Tung
2017-05-18  6:00 ` Yuval Shaia
2017-05-18 14:35 ` Saleem, Shiraz
2017-05-18 17:54   ` Gustavo A. R. Silva
2017-05-18 18:11     ` [PATCH] infiniband: hw: i40iw: fix duplicated " Gustavo A. R. Silva
2017-05-19 16:59       ` Shiraz Saleem
2017-06-01 22:27       ` Doug Ledford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).