* [PATCH] RDMA/bnxt_re: remove redundant initialization of rc to zero
@ 2017-02-17 15:35 Colin King
[not found] ` <20170217153522.30988-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2017-02-17 15:59 ` Dan Carpenter
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2017-02-17 15:35 UTC (permalink / raw)
To: Selvin Xavier, Devesh Sharma, Somnath Kotur,
Sriharsha Basavapatna, Doug Ledford, Sean Hefty, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA
Cc: kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Colin Ian King <colin.king@canonical.com>
rc is initialized to zero but is then updated by calls to
bnxt_qplib_free_fast_reg_page_list and/or bnxt_qpliob_free_mrw
so the initialization is redundant and can be removed.
Detected with CoverityScan, CID#1408448 ("Unused Value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 33af2e3..17aa087 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -2818,7 +2818,7 @@ int bnxt_re_dereg_mr(struct ib_mr *ib_mr)
{
struct bnxt_re_mr *mr = container_of(ib_mr, struct bnxt_re_mr, ib_mr);
struct bnxt_re_dev *rdev = mr->rdev;
- int rc = 0;
+ int rc;
if (mr->npages && mr->pages) {
rc = bnxt_qplib_free_fast_reg_page_list(&rdev->qplib_res,
--
2.10.2
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <20170217153522.30988-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>]
* Re: [PATCH] RDMA/bnxt_re: remove redundant initialization of rc to zero [not found] ` <20170217153522.30988-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org> @ 2017-02-17 15:55 ` Laurence Oberman 0 siblings, 0 replies; 3+ messages in thread From: Laurence Oberman @ 2017-02-17 15:55 UTC (permalink / raw) To: Colin King Cc: Selvin Xavier, Devesh Sharma, Somnath Kotur, Sriharsha Basavapatna, Doug Ledford, Sean Hefty, Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA ----- Original Message ----- > From: "Colin King" <colin.king@canonical.com> > To: "Selvin Xavier" <selvin.xavier@broadcom.com>, "Devesh Sharma" <devesh.sharma@broadcom.com>, "Somnath Kotur" > <somnath.kotur@broadcom.com>, "Sriharsha Basavapatna" <sriharsha.basavapatna@broadcom.com>, "Doug Ledford" > <dledford@redhat.com>, "Sean Hefty" <sean.hefty@intel.com>, "Hal Rosenstock" <hal.rosenstock@gmail.com>, > linux-rdma@vger.kernel.org > Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org > Sent: Friday, February 17, 2017 10:35:22 AM > Subject: [PATCH] RDMA/bnxt_re: remove redundant initialization of rc to zero > > From: Colin Ian King <colin.king@canonical.com> > > rc is initialized to zero but is then updated by calls to > bnxt_qplib_free_fast_reg_page_list and/or bnxt_qpliob_free_mrw > so the initialization is redundant and can be removed. > > Detected with CoverityScan, CID#1408448 ("Unused Value") > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c > b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > index 33af2e3..17aa087 100644 > --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c > +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > @@ -2818,7 +2818,7 @@ int bnxt_re_dereg_mr(struct ib_mr *ib_mr) > { > struct bnxt_re_mr *mr = container_of(ib_mr, struct bnxt_re_mr, ib_mr); > struct bnxt_re_dev *rdev = mr->rdev; > - int rc = 0; > + int rc; > > if (mr->npages && mr->pages) { > rc = bnxt_qplib_free_fast_reg_page_list(&rdev->qplib_res, > -- > 2.10.2 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Makes sense, looks fine. Reviewed-by: Laurence Oberman <loberman@redhat.com> ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] RDMA/bnxt_re: remove redundant initialization of rc to zero 2017-02-17 15:35 [PATCH] RDMA/bnxt_re: remove redundant initialization of rc to zero Colin King [not found] ` <20170217153522.30988-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org> @ 2017-02-17 15:59 ` Dan Carpenter 1 sibling, 0 replies; 3+ messages in thread From: Dan Carpenter @ 2017-02-17 15:59 UTC (permalink / raw) To: Colin King Cc: Selvin Xavier, Devesh Sharma, Somnath Kotur, Sriharsha Basavapatna, Doug Ledford, Sean Hefty, Hal Rosenstock, linux-rdma, kernel-janitors, linux-kernel drivers/infiniband/hw/bnxt_re/ib_verbs.c 2817 int bnxt_re_dereg_mr(struct ib_mr *ib_mr) 2818 { 2819 struct bnxt_re_mr *mr = container_of(ib_mr, struct bnxt_re_mr, ib_mr); 2820 struct bnxt_re_dev *rdev = mr->rdev; 2821 int rc = 0; It's weird that it would complain about this because initializing variables to bogus values is a prefered style for some people. It's bad style obviously, yes, but it's common and it seems like it would lead to a lot of false postives. 2822 2823 if (mr->npages && mr->pages) { 2824 rc = bnxt_qplib_free_fast_reg_page_list(&rdev->qplib_res, 2825 &mr->qplib_frpl); And then it doesn't complain about this one which seems like a legit bug. 2826 kfree(mr->pages); 2827 mr->npages = 0; 2828 mr->pages = NULL; 2829 } 2830 rc = bnxt_qplib_free_mrw(&rdev->qplib_res, &mr->qplib_mr); 2831 2832 if (!IS_ERR(mr->ib_umem) && mr->ib_umem) 2833 ib_umem_release(mr->ib_umem); 2834 2835 kfree(mr); 2836 atomic_dec(&rdev->mr_count); 2837 return rc; 2838 } regards, dan carpenter ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-17 15:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-17 15:35 [PATCH] RDMA/bnxt_re: remove redundant initialization of rc to zero Colin King
[not found] ` <20170217153522.30988-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2017-02-17 15:55 ` Laurence Oberman
2017-02-17 15:59 ` Dan Carpenter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox