linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations
       [not found] <566ABCD9.1060404@users.sourceforge.net>
@ 2015-12-26 18:39 ` SF Markus Elfring
  2015-12-26 18:43   ` [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
                     ` (3 more replies)
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
                   ` (2 subsequent siblings)
  3 siblings, 4 replies; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:39 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 19:30:54 +0100

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (6):
  One variable and jump label less in ocrdma_alloc_ucontext_pd()
  Delete unnecessary variable initialisations in 11 functions
  Returning only value constants in ocrdma_qp_state_change()
  Return a value from a function call in _ocrdma_modify_qp() directly
  Returning only value constants in ocrdma_resize_cq()
  Delete an unnecessary variable in ocrdma_dealloc_pd()

 drivers/infiniband/hw/ocrdma/ocrdma_ah.c    |  2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c    |  7 +++---
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c |  4 +--
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 39 +++++++++++------------------
 4 files changed, 20 insertions(+), 32 deletions(-)

-- 
2.6.3

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

* [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd()
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
@ 2015-12-26 18:43   ` SF Markus Elfring
  2015-12-26 19:41     ` kbuild test robot
       [not found]   ` <567EDED5.4040201-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:43 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 17:16:00 +0100

This issue was detected by using the Coccinelle software.

* Let us return directly if a call of the _ocrdma_alloc_pd()
  function failed.

* Delete the jump label "err" and the local variable "status" then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 583001b..374c839 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -483,19 +483,15 @@ static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,
 				    struct ocrdma_ucontext *uctx,
 				    struct ib_udata *udata)
 {
-	int status = 0;
-
 	uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);
 	if (IS_ERR(uctx->cntxt_pd)) {
-		status = PTR_ERR(uctx->cntxt_pd);
 		uctx->cntxt_pd = NULL;
-		goto err;
+		return PTR_ERR(uctx->cntxt_pd);
 	}
 
 	uctx->cntxt_pd->uctx = uctx;
 	uctx->cntxt_pd->ibpd.device = &dev->ibdev;
-err:
-	return status;
+	return 0;
 }
 
 static int ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)
-- 
2.6.3


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

* [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
       [not found]   ` <567EDED5.4040201-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2015-12-26 18:45     ` SF Markus Elfring
  2015-12-26 18:47     ` [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:45 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 26 Dec 2015 18:18:18 +0100

The variable "status" will be set to an appropriate value a bit later.
Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c    |  2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c    |  4 ++--
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c |  4 ++--
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 12 ++++++------
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index 9820074..98c0abd 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -59,7 +59,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
 			struct ib_ah_attr *attr, union ib_gid *sgid,
 			int pdid, bool *isvlan, u16 vlan_tag)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_eth_vlan eth;
 	struct ocrdma_grh grh;
 	int eth_sz;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 30f67be..6647aa6 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -1089,7 +1089,7 @@ mbx_err:
 static int ocrdma_nonemb_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe,
 				 void *payload_va)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_mbx_rsp *rsp = payload_va;
 
 	if ((mqe->hdr.spcl_sge_cnt_emb & OCRDMA_MQE_HDR_EMB_MASK) >>
@@ -2842,7 +2842,7 @@ int ocrdma_mbx_destroy_srq(struct ocrdma_dev *dev, struct ocrdma_srq *srq)
 static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,
 				      struct ocrdma_dcbx_cfg *dcbxcfg)
 {
-	int status = 0;
+	int status;
 	dma_addr_t pa;
 	struct ocrdma_mqe cmd;
 
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
index 86c303a..119baa3 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
@@ -608,7 +608,7 @@ static char *ocrdma_driver_dbg_stats(struct ocrdma_dev *dev)
 static void ocrdma_update_stats(struct ocrdma_dev *dev)
 {
 	ulong now = jiffies, secs;
-	int status = 0;
+	int status;
 	struct ocrdma_rdma_stats_resp *rdma_stats =
 		      (struct ocrdma_rdma_stats_resp *)dev->stats_mem.va;
 	struct ocrdma_rsrc_stats *rsrc_stats = &rdma_stats->act_rsrc_stats;
@@ -639,7 +639,7 @@ static ssize_t ocrdma_dbgfs_ops_write(struct file *filp,
 {
 	char tmp_str[32];
 	long reset;
-	int status = 0;
+	int status;
 	struct ocrdma_stats *pstats = filp->private_data;
 	struct ocrdma_dev *dev = pstats->dev;
 
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 374c839..aba1b5a 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -419,7 +419,7 @@ static struct ocrdma_pd *_ocrdma_alloc_pd(struct ocrdma_dev *dev,
 					  struct ib_udata *udata)
 {
 	struct ocrdma_pd *pd = NULL;
-	int status = 0;
+	int status;
 
 	pd = kzalloc(sizeof(*pd), GFP_KERNEL);
 	if (!pd)
@@ -468,7 +468,7 @@ static inline int is_ucontext_pd(struct ocrdma_ucontext *uctx,
 static int _ocrdma_dealloc_pd(struct ocrdma_dev *dev,
 			      struct ocrdma_pd *pd)
 {
-	int status = 0;
+	int status;
 
 	if (dev->pd_mgr->pd_prealloc_valid)
 		status = ocrdma_put_pd_num(dev, pd->id, pd->dpp_enabled);
@@ -592,7 +592,7 @@ map_err:
 
 int ocrdma_dealloc_ucontext(struct ib_ucontext *ibctx)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_mm *mm, *tmp;
 	struct ocrdma_ucontext *uctx = get_ocrdma_ucontext(ibctx);
 	struct ocrdma_dev *dev = get_ocrdma_dev(ibctx->device);
@@ -619,7 +619,7 @@ int ocrdma_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
 	unsigned long vm_page = vma->vm_pgoff << PAGE_SHIFT;
 	u64 unmapped_db = (u64) dev->nic_info.unmapped_db;
 	unsigned long len = (vma->vm_end - vma->vm_start);
-	int status = 0;
+	int status;
 	bool found;
 
 	if (vma->vm_start & (PAGE_SIZE - 1))
@@ -1282,7 +1282,7 @@ static int ocrdma_copy_qp_uresp(struct ocrdma_qp *qp,
 				struct ib_udata *udata, int dpp_offset,
 				int dpp_credit_lmt, int srq)
 {
-	int status = 0;
+	int status;
 	u64 usr_db;
 	struct ocrdma_create_qp_uresp uresp;
 	struct ocrdma_pd *pd = qp->pd;
@@ -1946,7 +1946,7 @@ int ocrdma_modify_srq(struct ib_srq *ibsrq,
 		      enum ib_srq_attr_mask srq_attr_mask,
 		      struct ib_udata *udata)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_srq *srq;
 
 	srq = get_ocrdma_srq(ibsrq);
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change()
       [not found]   ` <567EDED5.4040201-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2015-12-26 18:45     ` [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
@ 2015-12-26 18:47     ` SF Markus Elfring
  2015-12-26 18:49     ` [PATCH 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
  2016-01-14 17:18     ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
  3 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 26 Dec 2015 18:28:35 +0100

Return zero at the end without using the local variable "status".

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 6647aa6..9a2b153 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -2110,7 +2110,6 @@ int ocrdma_qp_state_change(struct ocrdma_qp *qp, enum ib_qp_state new_ib_state,
 			   enum ib_qp_state *old_ib_state)
 {
 	unsigned long flags;
-	int status = 0;
 	enum ocrdma_qp_state new_state;
 	new_state = get_ocrdma_qp_state(new_ib_state);
 
@@ -2135,7 +2134,7 @@ int ocrdma_qp_state_change(struct ocrdma_qp *qp, enum ib_qp_state new_ib_state,
 	qp->state = new_state;
 
 	spin_unlock_irqrestore(&qp->q_lock, flags);
-	return status;
+	return 0;
 }
 
 static u32 ocrdma_set_create_qp_mbx_access_flags(struct ocrdma_qp *qp)
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly
       [not found]   ` <567EDED5.4040201-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2015-12-26 18:45     ` [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
  2015-12-26 18:47     ` [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
@ 2015-12-26 18:49     ` SF Markus Elfring
  2016-01-14 17:18     ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
  3 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:49 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 26 Dec 2015 18:40:43 +0100

Return the value from a call of the ocrdma_mbx_modify_qp() function
without using an extra assignment for the local variable "status".

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index aba1b5a..2de39d3 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -1491,9 +1491,7 @@ int _ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 	 */
 	if (status < 0)
 		return status;
-	status = ocrdma_mbx_modify_qp(dev, qp, attr, attr_mask);
-
-	return status;
+	return ocrdma_mbx_modify_qp(dev, qp, attr, attr_mask);
 }
 
 int ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq()
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
  2015-12-26 18:43   ` [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
       [not found]   ` <567EDED5.4040201-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2015-12-26 18:50   ` SF Markus Elfring
  2015-12-26 18:51   ` [PATCH 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
  3 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:50 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 18:54:47 +0100

Return constant integer values without storing them in the local
variable "status".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 2de39d3..7bedf44 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -1120,15 +1120,12 @@ ctx_err:
 int ocrdma_resize_cq(struct ib_cq *ibcq, int new_cnt,
 		     struct ib_udata *udata)
 {
-	int status = 0;
 	struct ocrdma_cq *cq = get_ocrdma_cq(ibcq);
 
-	if (new_cnt < 1 || new_cnt > cq->max_hw_cqe) {
-		status = -EINVAL;
-		return status;
-	}
+	if (new_cnt < 1 || new_cnt > cq->max_hw_cqe)
+		return -EINVAL;
 	ibcq->cqe = new_cnt;
-	return status;
+	return 0;
 }
 
 static void ocrdma_flush_cq(struct ocrdma_cq *cq)
-- 
2.6.3

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

* [PATCH 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2015-12-26 18:50   ` [PATCH 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
@ 2015-12-26 18:51   ` SF Markus Elfring
  3 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:51 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 19:09:23 +0100

1. Return zero in one case directly.

2. Return the value from a call of the _ocrdma_dealloc_pd() function
   without using an extra assignment for the local variable.

3. Remove the variable "status" in this function then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 7bedf44..0f79a01 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -750,7 +750,6 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)
 	struct ocrdma_pd *pd = get_ocrdma_pd(ibpd);
 	struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device);
 	struct ocrdma_ucontext *uctx = NULL;
-	int status = 0;
 	u64 usr_db;
 
 	uctx = pd->uctx;
@@ -764,11 +763,10 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)
 
 		if (is_ucontext_pd(uctx, pd)) {
 			ocrdma_release_ucontext_pd(uctx);
-			return status;
+			return 0;
 		}
 	}
-	status = _ocrdma_dealloc_pd(dev, pd);
-	return status;
+	return _ocrdma_dealloc_pd(dev, pd);
 }
 
 static int ocrdma_alloc_lkey(struct ocrdma_dev *dev, struct ocrdma_mr *mr,
-- 
2.6.3


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

* Re: [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd()
  2015-12-26 18:43   ` [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
@ 2015-12-26 19:41     ` kbuild test robot
  2015-12-26 21:28       ` [PATCH v2 1/6] InfiniBand-ocrdma: One " SF Markus Elfring
  0 siblings, 1 reply; 50+ messages in thread
From: kbuild test robot @ 2015-12-26 19:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kbuild-all, linux-rdma, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors, Julia Lawall

[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
Hi Markus,

[auto build test WARNING on v4.4-rc6]
[also build test WARNING on next-20151223]

url:    https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/InfiniBand-ocrdma-Fine-tuning-for-some-function-implementations/20151227-025304


coccinelle warnings: (new ones prefixed by >>)

>> drivers/infiniband/hw/ocrdma/ocrdma_verbs.c:489:9-16: ERROR: PTR_ERR applied after initialization to constant on line 488

vim +489 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c

   482	static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,
   483					    struct ocrdma_ucontext *uctx,
   484					    struct ib_udata *udata)
   485	{
   486		uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);
   487		if (IS_ERR(uctx->cntxt_pd)) {
 > 488			uctx->cntxt_pd = NULL;
 > 489			return PTR_ERR(uctx->cntxt_pd);
   490		}
   491	
   492		uctx->cntxt_pd->uctx = uctx;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

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

* [PATCH v2 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
  2015-12-26 19:41     ` kbuild test robot
@ 2015-12-26 21:28       ` SF Markus Elfring
  2016-01-11 13:11         ` Selvin Xavier
  0 siblings, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-26 21:28 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: kbuild-all, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 22:18:38 +0100

This issue was detected by using the Coccinelle software.

* Let us return directly if a call of the _ocrdma_alloc_pd()
  function failed.

* Reduce the scope for the local variable "status" to one case
  of an if statement.

* Delete the jump label "err" then.

* Return zero as a constant at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 583001b..7f10cc47 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -483,19 +483,16 @@ static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,
 				    struct ocrdma_ucontext *uctx,
 				    struct ib_udata *udata)
 {
-	int status = 0;
-
 	uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);
 	if (IS_ERR(uctx->cntxt_pd)) {
-		status = PTR_ERR(uctx->cntxt_pd);
+		int status = PTR_ERR(uctx->cntxt_pd);
 		uctx->cntxt_pd = NULL;
-		goto err;
+		return status;
 	}
 
 	uctx->cntxt_pd->uctx = uctx;
 	uctx->cntxt_pd->ibpd.device = &dev->ibdev;
-err:
-	return status;
+	return 0;
 }
 
 static int ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)
-- 
2.6.3


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

* [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
       [not found] <566ABCD9.1060404@users.sourceforge.net>
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
@ 2015-12-27 12:36 ` SF Markus Elfring
  2015-12-27 12:40   ` [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr() SF Markus Elfring
                     ` (3 more replies)
  2016-08-20  6:01 ` [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
  3 siblings, 4 replies; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-27 12:36 UTC (permalink / raw)
  To: linux-rdma, target-devel, Doug Ledford, Hal Rosenstock,
	Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 27 Dec 2015 13:12:10 +0100
Subject: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations

I suggest to return directly instead of using the jump label "err"
in two functions (which are working without clean-up there).

Markus Elfring (2):
  One jump label less in iser_reg_sig_mr()
  One jump label less in isert_reg_sig_mr()

 drivers/infiniband/ulp/iser/iser_memory.c | 5 ++---
 drivers/infiniband/ulp/isert/ib_isert.c   | 7 +++----
 2 files changed, 5 insertions(+), 7 deletions(-)

-- 
2.6.3


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

* [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr()
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
@ 2015-12-27 12:40   ` SF Markus Elfring
  2015-12-27 12:41   ` [PATCH 2/2] InfiniBand-iSER-target: One jump label less in isert_reg_sig_mr() SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-27 12:40 UTC (permalink / raw)
  To: linux-rdma, target-devel, Doug Ledford, Hal Rosenstock,
	Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 27 Dec 2015 11:41:42 +0100

This issue was detected by using the Coccinelle software.

1. Let us return directly if a call of the iser_set_sig_attrs()
   function failed.

2. Delete the jump label "err" then.

3. Return zero as a constant at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/ulp/iser/iser_memory.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
index ea765fb..14e08b3 100644
--- a/drivers/infiniband/ulp/iser/iser_memory.c
+++ b/drivers/infiniband/ulp/iser/iser_memory.c
@@ -443,7 +443,7 @@ iser_reg_sig_mr(struct iscsi_iser_task *iser_task,
 	memset(sig_attrs, 0, sizeof(*sig_attrs));
 	ret = iser_set_sig_attrs(iser_task->sc, sig_attrs);
 	if (ret)
-		goto err;
+		return ret;
 
 	iser_set_prot_checks(iser_task->sc, &sig_attrs->check_mask);
 
@@ -475,8 +475,7 @@ iser_reg_sig_mr(struct iscsi_iser_task *iser_task,
 	iser_dbg("lkey=0x%x rkey=0x%x addr=0x%llx length=%u\n",
 		 sig_reg->sge.lkey, sig_reg->rkey, sig_reg->sge.addr,
 		 sig_reg->sge.length);
-err:
-	return ret;
+	return 0;
 }
 
 static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task,
-- 
2.6.3

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

* [PATCH 2/2] InfiniBand-iSER-target: One jump label less in isert_reg_sig_mr()
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
  2015-12-27 12:40   ` [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr() SF Markus Elfring
@ 2015-12-27 12:41   ` SF Markus Elfring
       [not found]   ` <567FDB4E.2040000-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2015-12-27 15:26   ` Sagi Grimberg
  3 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2015-12-27 12:41 UTC (permalink / raw)
  To: linux-rdma, target-devel, Doug Ledford, Hal Rosenstock,
	Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 27 Dec 2015 12:54:52 +0100

This issue was detected by using the Coccinelle software.

1. Let us return directly if a call of the function "isert_set_sig_attrs"
   or "ib_post_send" failed.

2. Delete the jump label "err" then.

3. Return zero as a constant at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/ulp/isert/ib_isert.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 8a51c3b..9b22db0 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -2660,7 +2660,7 @@ isert_reg_sig_mr(struct isert_conn *isert_conn,
 	memset(&sig_attrs, 0, sizeof(sig_attrs));
 	ret = isert_set_sig_attrs(se_cmd, &sig_attrs);
 	if (ret)
-		goto err;
+		return ret;
 
 	sig_attrs.check_mask = isert_set_prot_checks(se_cmd->prot_checks);
 
@@ -2688,7 +2688,7 @@ isert_reg_sig_mr(struct isert_conn *isert_conn,
 	ret = ib_post_send(isert_conn->qp, wr, &bad_wr);
 	if (ret) {
 		isert_err("fast registration failed, ret:%d\n", ret);
-		goto err;
+		return ret;
 	}
 	fr_desc->ind &= ~ISERT_SIG_KEY_VALID;
 
@@ -2706,8 +2706,7 @@ isert_reg_sig_mr(struct isert_conn *isert_conn,
 	isert_dbg("sig_sge: addr: 0x%llx  length: %u lkey: %x\n",
 		  rdma_wr->ib_sg[SIG].addr, rdma_wr->ib_sg[SIG].length,
 		  rdma_wr->ib_sg[SIG].lkey);
-err:
-	return ret;
+	return 0;
 }
 
 static int
-- 
2.6.3

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

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
       [not found]   ` <567FDB4E.2040000-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2015-12-27 12:43     ` Leon Romanovsky
  2015-12-27 12:52     ` Leon Romanovsky
  2016-01-06 18:47     ` Nicholas A. Bellinger
  2 siblings, 0 replies; 50+ messages in thread
From: Leon Romanovsky @ 2015-12-27 12:43 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	target-devel-u79uwXL29TY76Z2rM5mHXA, Doug Ledford,
	Hal Rosenstock, Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty,
	LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

On Sun, Dec 27, 2015 at 01:36:30PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sun, 27 Dec 2015 13:12:10 +0100
> Subject: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
Just a note for the future submissions (no need to respin), we are using
different subject line: InfiniBand-iSER: --> IB/iser:

> 
> I suggest to return directly instead of using the jump label "err"
> in two functions (which are working without clean-up there).
> 
> Markus Elfring (2):
>   One jump label less in iser_reg_sig_mr()
>   One jump label less in isert_reg_sig_mr()
> 
>  drivers/infiniband/ulp/iser/iser_memory.c | 5 ++---
>  drivers/infiniband/ulp/isert/ib_isert.c   | 7 +++----
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 
> -- 
> 2.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
       [not found]   ` <567FDB4E.2040000-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2015-12-27 12:43     ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations Leon Romanovsky
@ 2015-12-27 12:52     ` Leon Romanovsky
  2016-01-06 18:47     ` Nicholas A. Bellinger
  2 siblings, 0 replies; 50+ messages in thread
From: Leon Romanovsky @ 2015-12-27 12:52 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	target-devel-u79uwXL29TY76Z2rM5mHXA, Doug Ledford,
	Hal Rosenstock, Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty,
	LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

On Sun, Dec 27, 2015 at 01:36:30PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sun, 27 Dec 2015 13:12:10 +0100
> Subject: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
> 
> I suggest to return directly instead of using the jump label "err"
> in two functions (which are working without clean-up there).
> 
> Markus Elfring (2):
>   One jump label less in iser_reg_sig_mr()
>   One jump label less in isert_reg_sig_mr()
Looks good,
Reviewed-by: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

> 
>  drivers/infiniband/ulp/iser/iser_memory.c | 5 ++---
>  drivers/infiniband/ulp/isert/ib_isert.c   | 7 +++----
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 
> -- 
> 2.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
       [not found]   ` <567FDB4E.2040000-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2015-12-27 15:26   ` Sagi Grimberg
  3 siblings, 0 replies; 50+ messages in thread
From: Sagi Grimberg @ 2015-12-27 15:26 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, target-devel, Doug Ledford,
	Hal Rosenstock, Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

Along with Leon's prefix comment:

Acked-by: Sagi Grimberg <sagig@mellanox.com>

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

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
       [not found]   ` <567FDB4E.2040000-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2015-12-27 12:43     ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations Leon Romanovsky
  2015-12-27 12:52     ` Leon Romanovsky
@ 2016-01-06 18:47     ` Nicholas A. Bellinger
  2 siblings, 0 replies; 50+ messages in thread
From: Nicholas A. Bellinger @ 2016-01-06 18:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	target-devel-u79uwXL29TY76Z2rM5mHXA, Doug Ledford,
	Hal Rosenstock, Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty,
	LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

On Sun, 2015-12-27 at 13:36 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sun, 27 Dec 2015 13:12:10 +0100
> Subject: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
> 
> I suggest to return directly instead of using the jump label "err"
> in two functions (which are working without clean-up there).
> 
> Markus Elfring (2):
>   One jump label less in iser_reg_sig_mr()
>   One jump label less in isert_reg_sig_mr()
> 
>  drivers/infiniband/ulp/iser/iser_memory.c | 5 ++---
>  drivers/infiniband/ulp/isert/ib_isert.c   | 7 +++----
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 

Doug, are you going to pick these two minor patches up, or shall I..?

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
  2015-12-26 21:28       ` [PATCH v2 1/6] InfiniBand-ocrdma: One " SF Markus Elfring
@ 2016-01-11 13:11         ` Selvin Xavier
  0 siblings, 0 replies; 50+ messages in thread
From: Selvin Xavier @ 2016-01-11 13:11 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, kbuild-all, LKML, kernel-janitors,
	Julia Lawall

This patch series looks good to me

Thanks,

Acked-by: Selvin Xavier <selvin.xavier@avagotech.com>



On Sun, Dec 27, 2015 at 2:58 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 26 Dec 2015 22:18:38 +0100
>
> This issue was detected by using the Coccinelle software.
>
> * Let us return directly if a call of the _ocrdma_alloc_pd()
>   function failed.
>
> * Reduce the scope for the local variable "status" to one case
>   of an if statement.
>
> * Delete the jump label "err" then.
>
> * Return zero as a constant at the end.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> index 583001b..7f10cc47 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> @@ -483,19 +483,16 @@ static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,
>                                     struct ocrdma_ucontext *uctx,
>                                     struct ib_udata *udata)
>  {
> -       int status = 0;
> -
>         uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);
>         if (IS_ERR(uctx->cntxt_pd)) {
> -               status = PTR_ERR(uctx->cntxt_pd);
> +               int status = PTR_ERR(uctx->cntxt_pd);
>                 uctx->cntxt_pd = NULL;
> -               goto err;
> +               return status;
>         }
>
>         uctx->cntxt_pd->uctx = uctx;
>         uctx->cntxt_pd->ibpd.device = &dev->ibdev;
> -err:
> -       return status;
> +       return 0;
>  }
>
>  static int ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)
> --
> 2.6.3
>

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

* [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations
       [not found]   ` <567EDED5.4040201-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
                       ` (2 preceding siblings ...)
  2015-12-26 18:49     ` [PATCH 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
@ 2016-01-14 17:18     ` SF Markus Elfring
       [not found]       ` <5697D865.5010507-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
                         ` (4 more replies)
  3 siblings, 5 replies; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:18 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Thu, 14 Jan 2016 18:15:54 +0100

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (6):
  One variable and jump label less in ocrdma_alloc_ucontext_pd()
  Delete unnecessary variable initialisations in 11 functions
  Returning only value constants in ocrdma_qp_state_change()
  Return a value from a function call in _ocrdma_modify_qp() directly
  Returning only value constants in ocrdma_resize_cq()
  Delete an unnecessary variable in ocrdma_dealloc_pd()

---

v3: Rebase proposed changes on the source files for the software
    "Linux next-20160114".
    
v2: Unfortunately, the first update step from this series contained
    an inappropriate suggestion.
    Thus fix that.

 drivers/infiniband/hw/ocrdma/ocrdma_ah.c    |  2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c    |  7 +++---
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c |  4 +--
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 39 +++++++++++------------------
 4 files changed, 20 insertions(+), 32 deletions(-)

-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
       [not found]       ` <5697D865.5010507-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2016-01-14 17:38         ` SF Markus Elfring
  2016-01-14 17:50         ` [PATCH v3 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
  1 sibling, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:38 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Thu, 14 Jan 2016 17:17:44 +0100

This issue was detected by using the Coccinelle software.

* Let us return directly if a call of the _ocrdma_alloc_pd()
  function failed.

* Reduce the scope for the local variable "status" to one case
  of an if statement.

* Delete the jump label "err" then.

* Return zero as a constant at the end.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index d4c687b..4caf167 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -483,19 +483,16 @@ static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,
 				    struct ocrdma_ucontext *uctx,
 				    struct ib_udata *udata)
 {
-	int status = 0;
-
 	uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);
 	if (IS_ERR(uctx->cntxt_pd)) {
-		status = PTR_ERR(uctx->cntxt_pd);
+		int status = PTR_ERR(uctx->cntxt_pd);
 		uctx->cntxt_pd = NULL;
-		goto err;
+		return status;
 	}
 
 	uctx->cntxt_pd->uctx = uctx;
 	uctx->cntxt_pd->ibpd.device = &dev->ibdev;
-err:
-	return status;
+	return 0;
 }
 
 static int ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-14 17:18     ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
       [not found]       ` <5697D865.5010507-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2016-01-14 17:43       ` SF Markus Elfring
  2016-01-15 13:20         ` Leon Romanovsky
  2016-01-14 17:45       ` [PATCH v3 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
                         ` (2 subsequent siblings)
  4 siblings, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:43 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Jan 2016 17:47:59 +0100

The variable "status" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c    |  2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c    |  4 ++--
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c |  4 ++--
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 12 ++++++------
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index a343e03..41f0171 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -59,7 +59,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
 			struct ib_ah_attr *attr, union ib_gid *sgid,
 			int pdid, bool *isvlan, u16 vlan_tag)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_eth_vlan eth;
 	struct ocrdma_grh grh;
 	int eth_sz;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 283ca84..159b1d5 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -1113,7 +1113,7 @@ mbx_err:
 static int ocrdma_nonemb_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe,
 				 void *payload_va)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_mbx_rsp *rsp = payload_va;
 
 	if ((mqe->hdr.spcl_sge_cnt_emb & OCRDMA_MQE_HDR_EMB_MASK) >>
@@ -2871,7 +2871,7 @@ int ocrdma_mbx_destroy_srq(struct ocrdma_dev *dev, struct ocrdma_srq *srq)
 static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,
 				      struct ocrdma_dcbx_cfg *dcbxcfg)
 {
-	int status = 0;
+	int status;
 	dma_addr_t pa;
 	struct ocrdma_mqe cmd;
 
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
index 86c303a..119baa3 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
@@ -608,7 +608,7 @@ static char *ocrdma_driver_dbg_stats(struct ocrdma_dev *dev)
 static void ocrdma_update_stats(struct ocrdma_dev *dev)
 {
 	ulong now = jiffies, secs;
-	int status = 0;
+	int status;
 	struct ocrdma_rdma_stats_resp *rdma_stats =
 		      (struct ocrdma_rdma_stats_resp *)dev->stats_mem.va;
 	struct ocrdma_rsrc_stats *rsrc_stats = &rdma_stats->act_rsrc_stats;
@@ -639,7 +639,7 @@ static ssize_t ocrdma_dbgfs_ops_write(struct file *filp,
 {
 	char tmp_str[32];
 	long reset;
-	int status = 0;
+	int status;
 	struct ocrdma_stats *pstats = filp->private_data;
 	struct ocrdma_dev *dev = pstats->dev;
 
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 4caf167..1d90d18 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -419,7 +419,7 @@ static struct ocrdma_pd *_ocrdma_alloc_pd(struct ocrdma_dev *dev,
 					  struct ib_udata *udata)
 {
 	struct ocrdma_pd *pd = NULL;
-	int status = 0;
+	int status;
 
 	pd = kzalloc(sizeof(*pd), GFP_KERNEL);
 	if (!pd)
@@ -468,7 +468,7 @@ static inline int is_ucontext_pd(struct ocrdma_ucontext *uctx,
 static int _ocrdma_dealloc_pd(struct ocrdma_dev *dev,
 			      struct ocrdma_pd *pd)
 {
-	int status = 0;
+	int status;
 
 	if (dev->pd_mgr->pd_prealloc_valid)
 		status = ocrdma_put_pd_num(dev, pd->id, pd->dpp_enabled);
@@ -593,7 +593,7 @@ map_err:
 
 int ocrdma_dealloc_ucontext(struct ib_ucontext *ibctx)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_mm *mm, *tmp;
 	struct ocrdma_ucontext *uctx = get_ocrdma_ucontext(ibctx);
 	struct ocrdma_dev *dev = get_ocrdma_dev(ibctx->device);
@@ -620,7 +620,7 @@ int ocrdma_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
 	unsigned long vm_page = vma->vm_pgoff << PAGE_SHIFT;
 	u64 unmapped_db = (u64) dev->nic_info.unmapped_db;
 	unsigned long len = (vma->vm_end - vma->vm_start);
-	int status = 0;
+	int status;
 	bool found;
 
 	if (vma->vm_start & (PAGE_SIZE - 1))
@@ -1283,7 +1283,7 @@ static int ocrdma_copy_qp_uresp(struct ocrdma_qp *qp,
 				struct ib_udata *udata, int dpp_offset,
 				int dpp_credit_lmt, int srq)
 {
-	int status = 0;
+	int status;
 	u64 usr_db;
 	struct ocrdma_create_qp_uresp uresp;
 	struct ocrdma_pd *pd = qp->pd;
@@ -1947,7 +1947,7 @@ int ocrdma_modify_srq(struct ib_srq *ibsrq,
 		      enum ib_srq_attr_mask srq_attr_mask,
 		      struct ib_udata *udata)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_srq *srq;
 
 	srq = get_ocrdma_srq(ibsrq);
-- 
2.6.3

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

* [PATCH v3 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change()
  2016-01-14 17:18     ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
       [not found]       ` <5697D865.5010507-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2016-01-14 17:43       ` [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
@ 2016-01-14 17:45       ` SF Markus Elfring
  2016-01-14 17:48       ` [PATCH v3 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
  2016-01-14 17:51       ` [PATCH v3 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
  4 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:45 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Jan 2016 17:54:45 +0100

Return zero at the end without using the local variable "status".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 159b1d5..3766927 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -2138,7 +2138,6 @@ int ocrdma_qp_state_change(struct ocrdma_qp *qp, enum ib_qp_state new_ib_state,
 			   enum ib_qp_state *old_ib_state)
 {
 	unsigned long flags;
-	int status = 0;
 	enum ocrdma_qp_state new_state;
 	new_state = get_ocrdma_qp_state(new_ib_state);
 
@@ -2163,7 +2162,7 @@ int ocrdma_qp_state_change(struct ocrdma_qp *qp, enum ib_qp_state new_ib_state,
 	qp->state = new_state;
 
 	spin_unlock_irqrestore(&qp->q_lock, flags);
-	return status;
+	return 0;
 }
 
 static u32 ocrdma_set_create_qp_mbx_access_flags(struct ocrdma_qp *qp)
-- 
2.6.3


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

* [PATCH v3 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly
  2016-01-14 17:18     ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                         ` (2 preceding siblings ...)
  2016-01-14 17:45       ` [PATCH v3 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
@ 2016-01-14 17:48       ` SF Markus Elfring
  2016-01-14 17:51       ` [PATCH v3 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
  4 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:48 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Jan 2016 18:00:23 +0100

Return the value from a call of the ocrdma_mbx_modify_qp() function
without using an extra assignment for the local variable "status".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 1d90d18..5f2a34a 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -1492,9 +1492,7 @@ int _ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 	 */
 	if (status < 0)
 		return status;
-	status = ocrdma_mbx_modify_qp(dev, qp, attr, attr_mask);
-
-	return status;
+	return ocrdma_mbx_modify_qp(dev, qp, attr, attr_mask);
 }
 
 int ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
-- 
2.6.3


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

* [PATCH v3 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq()
       [not found]       ` <5697D865.5010507-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2016-01-14 17:38         ` [PATCH v3 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
@ 2016-01-14 17:50         ` SF Markus Elfring
  1 sibling, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:50 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Thu, 14 Jan 2016 18:04:17 +0100

Return constant integer values without storing them in the local
variable "status".

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 5f2a34a..d87985b 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -1121,15 +1121,12 @@ ctx_err:
 int ocrdma_resize_cq(struct ib_cq *ibcq, int new_cnt,
 		     struct ib_udata *udata)
 {
-	int status = 0;
 	struct ocrdma_cq *cq = get_ocrdma_cq(ibcq);
 
-	if (new_cnt < 1 || new_cnt > cq->max_hw_cqe) {
-		status = -EINVAL;
-		return status;
-	}
+	if (new_cnt < 1 || new_cnt > cq->max_hw_cqe)
+		return -EINVAL;
 	ibcq->cqe = new_cnt;
-	return status;
+	return 0;
 }
 
 static void ocrdma_flush_cq(struct ocrdma_cq *cq)
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()
  2016-01-14 17:18     ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                         ` (3 preceding siblings ...)
  2016-01-14 17:48       ` [PATCH v3 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
@ 2016-01-14 17:51       ` SF Markus Elfring
  4 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:51 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Jan 2016 18:08:08 +0100

1. Return zero in one case directly.

2. Return the value from a call of the _ocrdma_dealloc_pd() function
   without using an extra assignment for the local variable.

3. Remove the variable "status" in this function then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index d87985b..e6e1b51 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -751,7 +751,6 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)
 	struct ocrdma_pd *pd = get_ocrdma_pd(ibpd);
 	struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device);
 	struct ocrdma_ucontext *uctx = NULL;
-	int status = 0;
 	u64 usr_db;
 
 	uctx = pd->uctx;
@@ -765,11 +764,10 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)
 
 		if (is_ucontext_pd(uctx, pd)) {
 			ocrdma_release_ucontext_pd(uctx);
-			return status;
+			return 0;
 		}
 	}
-	status = _ocrdma_dealloc_pd(dev, pd);
-	return status;
+	return _ocrdma_dealloc_pd(dev, pd);
 }
 
 static int ocrdma_alloc_lkey(struct ocrdma_dev *dev, struct ocrdma_mr *mr,
-- 
2.6.3


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

* Re: [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-14 17:43       ` [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
@ 2016-01-15 13:20         ` Leon Romanovsky
       [not found]           ` <20160115132014.GC30615-2ukJVAZIZ/Y@public.gmane.org>
  0 siblings, 1 reply; 50+ messages in thread
From: Leon Romanovsky @ 2016-01-15 13:20 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML, kernel-janitors,
	Julia Lawall

On Thu, Jan 14, 2016 at 06:43:13PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 14 Jan 2016 17:47:59 +0100
> 
> The variable "status" will be set to an appropriate value a bit later.
> Thus omit the explicit initialisation at the beginning.

What did you try to achieve by this patch?

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/infiniband/hw/ocrdma/ocrdma_ah.c    |  2 +-
>  drivers/infiniband/hw/ocrdma/ocrdma_hw.c    |  4 ++--
>  drivers/infiniband/hw/ocrdma/ocrdma_stats.c |  4 ++--
>  drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 12 ++++++------
>  4 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
> index a343e03..41f0171 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
> @@ -59,7 +59,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
>  			struct ib_ah_attr *attr, union ib_gid *sgid,
>  			int pdid, bool *isvlan, u16 vlan_tag)
>  {
> -	int status = 0;
> +	int status;
>  	struct ocrdma_eth_vlan eth;
>  	struct ocrdma_grh grh;
>  	int eth_sz;
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
> index 283ca84..159b1d5 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
> @@ -1113,7 +1113,7 @@ mbx_err:
>  static int ocrdma_nonemb_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe,
>  				 void *payload_va)
>  {
> -	int status = 0;
> +	int status;
>  	struct ocrdma_mbx_rsp *rsp = payload_va;
>  
>  	if ((mqe->hdr.spcl_sge_cnt_emb & OCRDMA_MQE_HDR_EMB_MASK) >>
> @@ -2871,7 +2871,7 @@ int ocrdma_mbx_destroy_srq(struct ocrdma_dev *dev, struct ocrdma_srq *srq)
>  static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,
>  				      struct ocrdma_dcbx_cfg *dcbxcfg)
>  {
> -	int status = 0;
> +	int status;
>  	dma_addr_t pa;
>  	struct ocrdma_mqe cmd;
>  
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
> index 86c303a..119baa3 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
> @@ -608,7 +608,7 @@ static char *ocrdma_driver_dbg_stats(struct ocrdma_dev *dev)
>  static void ocrdma_update_stats(struct ocrdma_dev *dev)
>  {
>  	ulong now = jiffies, secs;
> -	int status = 0;
> +	int status;
>  	struct ocrdma_rdma_stats_resp *rdma_stats =
>  		      (struct ocrdma_rdma_stats_resp *)dev->stats_mem.va;
>  	struct ocrdma_rsrc_stats *rsrc_stats = &rdma_stats->act_rsrc_stats;
> @@ -639,7 +639,7 @@ static ssize_t ocrdma_dbgfs_ops_write(struct file *filp,
>  {
>  	char tmp_str[32];
>  	long reset;
> -	int status = 0;
> +	int status;
>  	struct ocrdma_stats *pstats = filp->private_data;
>  	struct ocrdma_dev *dev = pstats->dev;
>  
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> index 4caf167..1d90d18 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> @@ -419,7 +419,7 @@ static struct ocrdma_pd *_ocrdma_alloc_pd(struct ocrdma_dev *dev,
>  					  struct ib_udata *udata)
>  {
>  	struct ocrdma_pd *pd = NULL;
> -	int status = 0;
> +	int status;
>  
>  	pd = kzalloc(sizeof(*pd), GFP_KERNEL);
>  	if (!pd)
> @@ -468,7 +468,7 @@ static inline int is_ucontext_pd(struct ocrdma_ucontext *uctx,
>  static int _ocrdma_dealloc_pd(struct ocrdma_dev *dev,
>  			      struct ocrdma_pd *pd)
>  {
> -	int status = 0;
> +	int status;
>  
>  	if (dev->pd_mgr->pd_prealloc_valid)
>  		status = ocrdma_put_pd_num(dev, pd->id, pd->dpp_enabled);
> @@ -593,7 +593,7 @@ map_err:
>  
>  int ocrdma_dealloc_ucontext(struct ib_ucontext *ibctx)
>  {
> -	int status = 0;
> +	int status;
>  	struct ocrdma_mm *mm, *tmp;
>  	struct ocrdma_ucontext *uctx = get_ocrdma_ucontext(ibctx);
>  	struct ocrdma_dev *dev = get_ocrdma_dev(ibctx->device);
> @@ -620,7 +620,7 @@ int ocrdma_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
>  	unsigned long vm_page = vma->vm_pgoff << PAGE_SHIFT;
>  	u64 unmapped_db = (u64) dev->nic_info.unmapped_db;
>  	unsigned long len = (vma->vm_end - vma->vm_start);
> -	int status = 0;
> +	int status;
>  	bool found;
>  
>  	if (vma->vm_start & (PAGE_SIZE - 1))
> @@ -1283,7 +1283,7 @@ static int ocrdma_copy_qp_uresp(struct ocrdma_qp *qp,
>  				struct ib_udata *udata, int dpp_offset,
>  				int dpp_credit_lmt, int srq)
>  {
> -	int status = 0;
> +	int status;
>  	u64 usr_db;
>  	struct ocrdma_create_qp_uresp uresp;
>  	struct ocrdma_pd *pd = qp->pd;
> @@ -1947,7 +1947,7 @@ int ocrdma_modify_srq(struct ib_srq *ibsrq,
>  		      enum ib_srq_attr_mask srq_attr_mask,
>  		      struct ib_udata *udata)
>  {
> -	int status = 0;
> +	int status;
>  	struct ocrdma_srq *srq;
>  
>  	srq = get_ocrdma_srq(ibsrq);
> -- 
> 2.6.3
> 
> --
> 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

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
       [not found]           ` <20160115132014.GC30615-2ukJVAZIZ/Y@public.gmane.org>
@ 2016-01-15 14:50             ` SF Markus Elfring
       [not found]               ` <56990733.7000506-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  0 siblings, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-15 14:50 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Leon Romanovsky
  Cc: Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

>> The variable "status" will be set to an appropriate value a bit later.
>> Thus omit the explicit initialisation at the beginning.
> 
> What did you try to achieve by this patch?

I would like to optimise the affected source files a bit.
Would you like to clarify any measurable effects around the implementation
detail when various variables will only be initialised immediately
before they will be read again?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
       [not found]               ` <56990733.7000506-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2016-01-15 15:09                 ` Leon Romanovsky
       [not found]                   ` <20160115150935.GA32346-2ukJVAZIZ/Y@public.gmane.org>
  0 siblings, 1 reply; 50+ messages in thread
From: Leon Romanovsky @ 2016-01-15 15:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

On Fri, Jan 15, 2016 at 03:50:27PM +0100, SF Markus Elfring wrote:
> >> The variable "status" will be set to an appropriate value a bit later.
> >> Thus omit the explicit initialisation at the beginning.
> > 
> > What did you try to achieve by this patch?
> 
> I would like to optimise the affected source files a bit.
> Would you like to clarify any measurable effects around the implementation
> detail when various variables will only be initialised immediately
> before they will be read again?

Compiler will drop this variable initialization by itself because
there are no reads between this variable initialization and write.

I recommend you to take a look on the assembly code and ensure it
by yourself.

The proposed change won't affect performance at all.

> 
> Regards,
> Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
       [not found]                   ` <20160115150935.GA32346-2ukJVAZIZ/Y@public.gmane.org>
@ 2016-01-15 15:26                     ` SF Markus Elfring
       [not found]                       ` <56990FAC.6000506-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  0 siblings, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-15 15:26 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Leon Romanovsky
  Cc: Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

>> Would you like to clarify any measurable effects around the implementation
>> detail when various variables will only be initialised immediately
>> before they will be read again?
> 
> Compiler will drop this variable initialization by itself because
> there are no reads between this variable initialization and write.

Which compiler variants would you to take into account for such an use case?


> I recommend you to take a look on the assembly code and ensure it
> by yourself.

Will any configuration parameters and command arguments become relevant
to improve also a corresponding software comparison?


> The proposed change won't affect performance at all.

Will unneeded variable assignments be really optimised away by default?


By the way:
Will a small source code reduction matter also a bit here?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
       [not found]                       ` <56990FAC.6000506-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2016-01-15 15:59                         ` Leon Romanovsky
       [not found]                           ` <20160115155938.GB32346-2ukJVAZIZ/Y@public.gmane.org>
  0 siblings, 1 reply; 50+ messages in thread
From: Leon Romanovsky @ 2016-01-15 15:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

On Fri, Jan 15, 2016 at 04:26:36PM +0100, SF Markus Elfring wrote:
> >> Would you like to clarify any measurable effects around the implementation
> >> detail when various variables will only be initialised immediately
> >> before they will be read again?
> > 
> > Compiler will drop this variable initialization by itself because
> > there are no reads between this variable initialization and write.
> 
> Which compiler variants would you to take into account for such an use case?

GCC supported it before 1999 when I saw it first time. My assumption
that in 2016 all compilers are doing such optimization now.
I would be glad to hear an example of modern compiler which doesn't
support this simple optimization.

> 
> 
> > I recommend you to take a look on the assembly code and ensure it
> > by yourself.
> 
> Will any configuration parameters and command arguments become relevant
> to improve also a corresponding software comparison?

Please suggest us, you are proposing this change, and not me.

> 
> 
> > The proposed change won't affect performance at all.
> 
> Will unneeded variable assignments be really optimised away by default?

Yes

> 
> 
> By the way:
> Will a small source code reduction matter also a bit here?

If you are interested in saving space of one latter, you need to take into
account git database increase, do you?

> 
> Regards,
> Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
       [not found]                           ` <20160115155938.GB32346-2ukJVAZIZ/Y@public.gmane.org>
@ 2016-01-15 16:10                             ` Dan Carpenter
  2016-01-15 16:24                             ` SF Markus Elfring
  1 sibling, 0 replies; 50+ messages in thread
From: Dan Carpenter @ 2016-01-15 16:10 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

Doing bogus initializations turns off GCC's checking for uninitialized
variables so it's a bad habbit.

On the other hand, GCC's checking is not perfect and it sometimes misses
bugs so these patches have to be reviewed manually which is maybe too
much work to be worthwhile.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
       [not found]                           ` <20160115155938.GB32346-2ukJVAZIZ/Y@public.gmane.org>
  2016-01-15 16:10                             ` Dan Carpenter
@ 2016-01-15 16:24                             ` SF Markus Elfring
       [not found]                               ` <56991D52.8030808-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  1 sibling, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-15 16:24 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Leon Romanovsky
  Cc: Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

> GCC supported it before 1999 when I saw it first time. My assumption
> that in 2016 all compilers are doing such optimization now.

Interesting …


> I would be glad to hear an example of modern compiler which doesn't
> support this simple optimization.

Would you like to take into account any other source code analysis approaches?


>> Will any configuration parameters and command arguments become relevant
>> to improve also a corresponding software comparison?
> 
> Please suggest us, you are proposing this change, and not me.

Which combination of hardware and software versions would you find representative
for a corresponding system check?


>>> The proposed change won't affect performance at all.
>>
>> Will unneeded variable assignments be really optimised away by default?
> 
> Yes

Can it be that this result will depend on special parameters so that data flow
analysis and optimisation will be performed in the way you seem to expect?


> If you are interested in saving space of one latter, you need to take into
> account git database increase, do you?

There are also other aspects to consider:

* Do you insist to initialise a return code at the beginning of every function
  with a non-void return type?

* Does each bit of extra information can result also in unwanted consequences?

* Is this a specific source code review concern?

* Can this software be improved a bit more only if we dare to talk about
  potential update candidates?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
       [not found]                               ` <56991D52.8030808-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2016-01-15 17:00                                 ` Leon Romanovsky
       [not found]                                   ` <20160115170048.GC32346-2ukJVAZIZ/Y@public.gmane.org>
  2016-01-15 18:19                                   ` SF Markus Elfring
  0 siblings, 2 replies; 50+ messages in thread
From: Leon Romanovsky @ 2016-01-15 17:00 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

On Fri, Jan 15, 2016 at 05:24:50PM +0100, SF Markus Elfring wrote:

Since, you didn't answer to my original question, I will repeat it again.
[Q.] What did you try to achieve by this patch?

P.S. This is mailing list for developers and not for patch bots.
We are glad to see patches that clean the code, but they need to
be meaningful. Your automated patches add noise without any real
benefit.

You was suggested to be ignored in MTD mailing list exactly for this
type of patches, did you learn anything from that experience?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
       [not found]                                   ` <20160115170048.GC32346-2ukJVAZIZ/Y@public.gmane.org>
@ 2016-01-15 17:19                                     ` Bart Van Assche
  2016-01-15 17:41                                       ` Leon Romanovsky
  0 siblings, 1 reply; 50+ messages in thread
From: Bart Van Assche @ 2016-01-15 17:19 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

On 01/15/2016 09:00 AM, Leon Romanovsky wrote:
> On Fri, Jan 15, 2016 at 05:24:50PM +0100, SF Markus Elfring wrote:
>
> Since, you didn't answer to my original question, I will repeat it again.
> [Q.] What did you try to achieve by this patch?

Hello Leon,

Have you noticed Dan's reply: "Doing bogus initializations turns off 
GCC's checking for uninitialized variables so it's a bad habit."

Thanks,

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 17:19                                     ` Bart Van Assche
@ 2016-01-15 17:41                                       ` Leon Romanovsky
  0 siblings, 0 replies; 50+ messages in thread
From: Leon Romanovsky @ 2016-01-15 17:41 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: SF Markus Elfring, linux-rdma, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors, Julia Lawall

On Fri, Jan 15, 2016 at 09:19:38AM -0800, Bart Van Assche wrote:
> On 01/15/2016 09:00 AM, Leon Romanovsky wrote:
> >On Fri, Jan 15, 2016 at 05:24:50PM +0100, SF Markus Elfring wrote:
> >
> >Since, you didn't answer to my original question, I will repeat it again.
> >[Q.] What did you try to achieve by this patch?
> 
> Hello Leon,
> 
> Have you noticed Dan's reply: "Doing bogus initializations turns off GCC's
> checking for uninitialized variables so it's a bad habit."

Yes and his second part of that message too, that uninitialized
checks in GCC work as not as expected [1, 2].

Stackoverflow site has a lot examples of these types of bugs [3].
These examples together with Dan's suggestion requires from all
reviewers to be extra cautions when removing variable initialization.

[1] https://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
[2] https://gcc.gnu.org/bugzilla/buglist.cgi?quicksearch=may%20be%20uninitialized
[3] http://stackoverflow.com/questions/27063678/compiler-not-detecting-obviously-uninitialized-variable

> 
> Thanks,
> 
> Bart.
> --
> 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

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 17:00                                 ` Leon Romanovsky
       [not found]                                   ` <20160115170048.GC32346-2ukJVAZIZ/Y@public.gmane.org>
@ 2016-01-15 18:19                                   ` SF Markus Elfring
  2016-01-16  6:18                                     ` Leon Romanovsky
  1 sibling, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-15 18:19 UTC (permalink / raw)
  To: linux-rdma, Leon Romanovsky
  Cc: Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML, kernel-janitors, Julia Lawall

> [Q.] What did you try to achieve by this patch?

I would appreciate a bit more fine-tuning in the affected source files.


> P.S. This is mailing list for developers

Do you try to express any further restrictions?


> and not for patch bots.

Would you like to explain such an information a bit more?


> We are glad to see patches that clean the code, but they need to
> be meaningful.

This is usual.


> Your automated patches add noise without any real benefit.

Are you expecting a kind of special proof?


> You was suggested to be ignored in MTD mailing list exactly
> for this type of patches,

Will the acceptance increase a bit for similar issues over time?


> did you learn anything from that experience?

Will another acknowledgement by Selvin Xavier influence any corresponding
software improvements?


How do you think about to add any further constructive comments
also for the other proposed update steps?

Regards,
Markus

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 18:19                                   ` SF Markus Elfring
@ 2016-01-16  6:18                                     ` Leon Romanovsky
       [not found]                                       ` <20160116061843.GE32346-2ukJVAZIZ/Y@public.gmane.org>
  0 siblings, 1 reply; 50+ messages in thread
From: Leon Romanovsky @ 2016-01-16  6:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML, kernel-janitors,
	Julia Lawall

On Fri, Jan 15, 2016 at 07:19:31PM +0100, SF Markus Elfring wrote:
> > [Q.] What did you try to achieve by this patch?
> 
> I would appreciate a bit more fine-tuning in the affected source files.

Please provide the numbers BEFORE and AFTER your change which can
support that your so called "fine-tuning" worked.

We are waiting to see it together with Tested-By tag to emphasize
that your code was tested on real HW and passed minimal sanity checks.

NAK on this patch.

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

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
       [not found]                                       ` <20160116061843.GE32346-2ukJVAZIZ/Y@public.gmane.org>
@ 2016-01-16  8:30                                         ` SF Markus Elfring
  0 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2016-01-16  8:30 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Leon Romanovsky
  Cc: Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall,
	kbuild-all-JC7UmRfGjtg, ltp-cunTk1MwBs91InPhgRC9rw,
	users-ZwoEplunGu1OwGhvXhtEPSCwEArCW2h5

> Please provide the numbers BEFORE and AFTER your change which can
> support that your so called "fine-tuning" worked.

For which combinations of hardware and software versions would you
like to see corresponding results from detailed system checks
and special benchmarks?


> We are waiting to see it together with Tested-By tag to emphasize
> that your code was tested on real HW and passed minimal sanity checks.

Are any other contributors interested to collaborate for such a task?


> NAK on this patch.

Thanks for your feedback.

Does it mean that you reject (only) the proposed source code adjustments
around the variable "status" in the shown function selection at the moment?

Would you like to clarify the other update steps from this patch series
a bit more?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation
       [not found] <566ABCD9.1060404@users.sourceforge.net>
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
@ 2016-08-20  6:01 ` SF Markus Elfring
       [not found]   ` <ceb39933-438d-920d-f294-ea0ce32fd171-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
  3 siblings, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2016-08-20  6:01 UTC (permalink / raw)
  To: linux-rdma, netdev, Leon Romanovsky, Matan Barak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 Aug 2016 07:50:09 +0200

* Reuse existing functionality from memdup_user() instead of keeping
  duplicate source code.

  This issue was detected by using the Coccinelle software.

* Return directly if this copy operation failed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 6388bc0..bb89f04 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1132,7 +1132,6 @@ static ssize_t data_write(struct file *filp, const char __user *buf,
 	struct mlx5_core_dev *dev = filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	void *ptr;
-	int err;
 
 	if (*pos != 0)
 		return -EINVAL;
@@ -1140,25 +1139,15 @@ static ssize_t data_write(struct file *filp, const char __user *buf,
 	kfree(dbg->in_msg);
 	dbg->in_msg = NULL;
 	dbg->inlen = 0;
-
-	ptr = kzalloc(count, GFP_KERNEL);
-	if (!ptr)
-		return -ENOMEM;
-
-	if (copy_from_user(ptr, buf, count)) {
-		err = -EFAULT;
-		goto out;
-	}
+	ptr = memdup_user(buf, count);
+	if (IS_ERR(ptr))
+		return PTR_ERR(ptr);
 	dbg->in_msg = ptr;
 	dbg->inlen = count;
 
 	*pos = count;
 
 	return count;
-
-out:
-	kfree(ptr);
-	return err;
 }
 
 static ssize_t data_read(struct file *filp, char __user *buf, size_t count,
-- 
2.9.3

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

* Re: [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation
       [not found]   ` <ceb39933-438d-920d-f294-ea0ce32fd171-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2016-08-20  9:32     ` walter harms
  2016-08-23  0:05     ` David Miller
  1 sibling, 0 replies; 50+ messages in thread
From: walter harms @ 2016-08-20  9:32 UTC (permalink / raw)
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	Leon Romanovsky, Matan Barak, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall



Am 20.08.2016 08:01, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sat, 20 Aug 2016 07:50:09 +0200
> 
> * Reuse existing functionality from memdup_user() instead of keeping
>   duplicate source code.
> 
>   This issue was detected by using the Coccinelle software.
> 
> * Return directly if this copy operation failed.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 17 +++--------------
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> index 6388bc0..bb89f04 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> @@ -1132,7 +1132,6 @@ static ssize_t data_write(struct file *filp, const char __user *buf,
>  	struct mlx5_core_dev *dev = filp->private_data;
>  	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
>  	void *ptr;
> -	int err;
>  
>  	if (*pos != 0)
>  		return -EINVAL;
> @@ -1140,25 +1139,15 @@ static ssize_t data_write(struct file *filp, const char __user *buf,
>  	kfree(dbg->in_msg);
>  	dbg->in_msg = NULL;
>  	dbg->inlen = 0;
> -
> -	ptr = kzalloc(count, GFP_KERNEL);
> -	if (!ptr)
> -		return -ENOMEM;
> -
> -	if (copy_from_user(ptr, buf, count)) {
> -		err = -EFAULT;
> -		goto out;
> -	}
> +	ptr = memdup_user(buf, count);
> +	if (IS_ERR(ptr))
> +		return PTR_ERR(ptr);
>  	dbg->in_msg = ptr;
>  	dbg->inlen = count;
>  
>  	*pos = count;
>  

maybe i am missing something here but why do you need ptr ?

The use of count looks even more confusing it is stored in
 dbg->inlen, *pos and is returned.
is that realy needed ?

re,
 wh

>  	return count;
> -
> -out:
> -	kfree(ptr);
> -	return err;
>  }
>  
>  static ssize_t data_read(struct file *filp, char __user *buf, size_t count,
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared()
       [not found] <566ABCD9.1060404@users.sourceforge.net>
                   ` (2 preceding siblings ...)
  2016-08-20  6:01 ` [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-21 17:39 ` SF Markus Elfring
  2016-08-21 17:42   ` [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                     ` (2 more replies)
  3 siblings, 3 replies; 50+ messages in thread
From: SF Markus Elfring @ 2016-08-21 17:39 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 19:34:12 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Use memdup_user()
  Delete an unnecessary initialisation

 include/rdma/ib_verbs.h | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

-- 
2.9.3

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

* [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation
  2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
@ 2016-08-21 17:42   ` SF Markus Elfring
       [not found]   ` <f7bb3caf-81cd-fba9-afc8-5fac72b8a4b3-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2016-08-21 18:03   ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() Joe Perches
  2 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2016-08-21 17:42 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 18:45:22 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 include/rdma/ib_verbs.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6f667dd..033610b 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2205,16 +2205,11 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
 	if (len > USHRT_MAX)
 		return false;
 
-	buf = kmalloc(len, GFP_KERNEL);
-	if (!buf)
+	buf = memdup_user(p, len);
+	if (IS_ERR(buf))
 		return false;
 
-	if (copy_from_user(buf, p, len))
-		goto free;
-
 	ret = !memchr_inv(buf, 0, len);
-
-free:
 	kfree(buf);
 	return ret;
 }
-- 
2.9.3

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

* [PATCH 2/2] IB/core: Delete an unnecessary initialisation in ib_is_udata_cleared()
       [not found]   ` <f7bb3caf-81cd-fba9-afc8-5fac72b8a4b3-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2016-08-21 17:45     ` SF Markus Elfring
  0 siblings, 0 replies; 50+ messages in thread
From: SF Markus Elfring @ 2016-08-21 17:45 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Sean Hefty
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sun, 21 Aug 2016 19:23:12 +0200

The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 include/rdma/ib_verbs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 033610b..0d8100f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2199,7 +2199,7 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
 				       size_t len)
 {
 	const void __user *p = udata->inbuf + offset;
-	bool ret = false;
+	bool ret;
 	u8 *buf;
 
 	if (len > USHRT_MAX)
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared()
  2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
  2016-08-21 17:42   ` [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
       [not found]   ` <f7bb3caf-81cd-fba9-afc8-5fac72b8a4b3-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2016-08-21 18:03   ` Joe Perches
       [not found]     ` <1471802623.3746.1.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
  2 siblings, 1 reply; 50+ messages in thread
From: Joe Perches @ 2016-08-21 18:03 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

On Sun, 2016-08-21 at 19:39 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 19:34:12 +0200
> 
> A few update suggestions were taken into account
> from static source code analysis.

Don't introduce a defect in patch 1 and correct
that introduced defect in patch 2.

This should be a single patch.

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

* Re: IB/core: Fine-tuning for ib_is_udata_cleared()
       [not found]     ` <1471802623.3746.1.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
@ 2016-08-21 19:51       ` SF Markus Elfring
       [not found]         ` <683187e0-2e6a-88c0-f87a-9c5f0489370a-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  0 siblings, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2016-08-21 19:51 UTC (permalink / raw)
  To: Joe Perches, linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford,
	Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

>> A few update suggestions were taken into account
>> from static source code analysis.
> 
> Don't introduce a defect in patch 1 and correct
> that introduced defect in patch 2.

Which detail do you not like here?


> This should be a single patch.

Do any more software software developers would like to get
the proposed changes in a single update step?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: IB/core: Fine-tuning for ib_is_udata_cleared()
       [not found]         ` <683187e0-2e6a-88c0-f87a-9c5f0489370a-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2016-08-21 19:53           ` Joe Perches
       [not found]             ` <1471809188.3746.18.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 50+ messages in thread
From: Joe Perches @ 2016-08-21 19:53 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Doug Ledford, Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

On Sun, 2016-08-21 at 21:51 +0200, SF Markus Elfring wrote:

> > Don't introduce a defect in patch 1 and correct
> > that introduced defect in patch 2.
> Which detail do you not like here?

See above.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: IB/core: Fine-tuning for ib_is_udata_cleared()
       [not found]             ` <1471809188.3746.18.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
@ 2016-08-21 20:15               ` SF Markus Elfring
  2016-08-22  9:46                 ` Yann Droneaud
  0 siblings, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2016-08-21 20:15 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Sean Hefty, LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	Julia Lawall

>>> Don't introduce a defect in patch 1 and correct
>>> that introduced defect in patch 2.
>> Which detail do you not like here?
> 
> See above.

This feedback is not clearer.

I find that the two update steps should work in principle,
shouldn't they?

I guess that we have got different preferences for the shown
patch granularity. Another update variant can follow a bit later
with the changes squashed together.

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: IB/core: Fine-tuning for ib_is_udata_cleared()
  2016-08-21 20:15               ` SF Markus Elfring
@ 2016-08-22  9:46                 ` Yann Droneaud
       [not found]                   ` <1471859215.2764.24.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 50+ messages in thread
From: Yann Droneaud @ 2016-08-22  9:46 UTC (permalink / raw)
  To: SF Markus Elfring, Joe Perches
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty, LKML,
	kernel-janitors, Julia Lawall

Hi,

Le dimanche 21 août 2016 à 22:15 +0200, SF Markus Elfring a écrit :
> > 
> > > 
> > > > 
> > > > Don't introduce a defect in patch 1 and correct
> > > > that introduced defect in patch 2.
> > > Which detail do you not like here?
> > 
> > See above.
> 
> This feedback is not clearer.
> 

It's clear enough: your second patch fixes an issue you introduced in
your first patch by removing the code which made use of the ret
initialization value:

-       if (copy_from_user(buf, p, len))
-               goto free;

> I find that the two update steps should work in principle,
> shouldn't they?
> 

It would be better to squash them here.

Regards.

-- 
Yann Droneaud
OPTEYA

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

* [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation
       [not found]                   ` <1471859215.2764.24.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
@ 2016-08-22 16:30                     ` SF Markus Elfring
  2016-08-23 16:43                       ` Doug Ledford
  0 siblings, 1 reply; 50+ messages in thread
From: SF Markus Elfring @ 2016-08-22 16:30 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Joe Perches, Sean Hefty, Yann Droneaud
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Mon, 22 Aug 2016 18:23:24 +0200

* Reuse existing functionality from memdup_user() instead of keeping
  duplicate source code.

  This issue was detected by using the Coccinelle software.

* The local variable "ret" will be set to an appropriate value a bit later.
  Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---

v2: The desired changes were put into a single patch instead of
    distributing them over two update steps.

 include/rdma/ib_verbs.h | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6f667dd..0d8100f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2199,22 +2199,17 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
 				       size_t len)
 {
 	const void __user *p = udata->inbuf + offset;
-	bool ret = false;
+	bool ret;
 	u8 *buf;
 
 	if (len > USHRT_MAX)
 		return false;
 
-	buf = kmalloc(len, GFP_KERNEL);
-	if (!buf)
+	buf = memdup_user(p, len);
+	if (IS_ERR(buf))
 		return false;
 
-	if (copy_from_user(buf, p, len))
-		goto free;
-
 	ret = !memchr_inv(buf, 0, len);
-
-free:
 	kfree(buf);
 	return ret;
 }
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation
       [not found]   ` <ceb39933-438d-920d-f294-ea0ce32fd171-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2016-08-20  9:32     ` walter harms
@ 2016-08-23  0:05     ` David Miller
  1 sibling, 0 replies; 50+ messages in thread
From: David Miller @ 2016-08-23  0:05 UTC (permalink / raw)
  To: elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	leonro-VPRAkNaXOzVWk0Htik3J/w, matanb-VPRAkNaXOzVWk0Htik3J/w,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, julia.lawall-L2FTfq7BK8M

From: SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 20 Aug 2016 08:01:22 +0200

> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sat, 20 Aug 2016 07:50:09 +0200
> 
> * Reuse existing functionality from memdup_user() instead of keeping
>   duplicate source code.
> 
>   This issue was detected by using the Coccinelle software.
> 
> * Return directly if this copy operation failed.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation
  2016-08-22 16:30                     ` [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-23 16:43                       ` Doug Ledford
  0 siblings, 0 replies; 50+ messages in thread
From: Doug Ledford @ 2016-08-23 16:43 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, Hal Rosenstock, Joe Perches,
	Sean Hefty, Yann Droneaud
  Cc: LKML, kernel-janitors, Julia Lawall


[-- Attachment #1.1: Type: text/plain, Size: 623 bytes --]

On 8/22/2016 12:30 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 Aug 2016 18:23:24 +0200
> 
> * Reuse existing functionality from memdup_user() instead of keeping
>   duplicate source code.
> 
>   This issue was detected by using the Coccinelle software.
> 
> * The local variable "ret" will be set to an appropriate value a bit later.
>   Thus omit the explicit initialisation at the beginning.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


-- 
Doug Ledford <dledford@redhat.com>
    GPG Key ID: 0E572FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

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

end of thread, other threads:[~2016-08-23 16:43 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <566ABCD9.1060404@users.sourceforge.net>
2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
2015-12-26 18:43   ` [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
2015-12-26 19:41     ` kbuild test robot
2015-12-26 21:28       ` [PATCH v2 1/6] InfiniBand-ocrdma: One " SF Markus Elfring
2016-01-11 13:11         ` Selvin Xavier
     [not found]   ` <567EDED5.4040201-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2015-12-26 18:45     ` [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
2015-12-26 18:47     ` [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
2015-12-26 18:49     ` [PATCH 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
2016-01-14 17:18     ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
     [not found]       ` <5697D865.5010507-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2016-01-14 17:38         ` [PATCH v3 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
2016-01-14 17:50         ` [PATCH v3 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
2016-01-14 17:43       ` [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
2016-01-15 13:20         ` Leon Romanovsky
     [not found]           ` <20160115132014.GC30615-2ukJVAZIZ/Y@public.gmane.org>
2016-01-15 14:50             ` SF Markus Elfring
     [not found]               ` <56990733.7000506-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2016-01-15 15:09                 ` Leon Romanovsky
     [not found]                   ` <20160115150935.GA32346-2ukJVAZIZ/Y@public.gmane.org>
2016-01-15 15:26                     ` SF Markus Elfring
     [not found]                       ` <56990FAC.6000506-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2016-01-15 15:59                         ` Leon Romanovsky
     [not found]                           ` <20160115155938.GB32346-2ukJVAZIZ/Y@public.gmane.org>
2016-01-15 16:10                             ` Dan Carpenter
2016-01-15 16:24                             ` SF Markus Elfring
     [not found]                               ` <56991D52.8030808-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2016-01-15 17:00                                 ` Leon Romanovsky
     [not found]                                   ` <20160115170048.GC32346-2ukJVAZIZ/Y@public.gmane.org>
2016-01-15 17:19                                     ` Bart Van Assche
2016-01-15 17:41                                       ` Leon Romanovsky
2016-01-15 18:19                                   ` SF Markus Elfring
2016-01-16  6:18                                     ` Leon Romanovsky
     [not found]                                       ` <20160116061843.GE32346-2ukJVAZIZ/Y@public.gmane.org>
2016-01-16  8:30                                         ` SF Markus Elfring
2016-01-14 17:45       ` [PATCH v3 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
2016-01-14 17:48       ` [PATCH v3 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
2016-01-14 17:51       ` [PATCH v3 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
2015-12-26 18:50   ` [PATCH 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
2015-12-26 18:51   ` [PATCH 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
2015-12-27 12:40   ` [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr() SF Markus Elfring
2015-12-27 12:41   ` [PATCH 2/2] InfiniBand-iSER-target: One jump label less in isert_reg_sig_mr() SF Markus Elfring
     [not found]   ` <567FDB4E.2040000-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2015-12-27 12:43     ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations Leon Romanovsky
2015-12-27 12:52     ` Leon Romanovsky
2016-01-06 18:47     ` Nicholas A. Bellinger
2015-12-27 15:26   ` Sagi Grimberg
2016-08-20  6:01 ` [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
     [not found]   ` <ceb39933-438d-920d-f294-ea0ce32fd171-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2016-08-20  9:32     ` walter harms
2016-08-23  0:05     ` David Miller
2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
2016-08-21 17:42   ` [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
     [not found]   ` <f7bb3caf-81cd-fba9-afc8-5fac72b8a4b3-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2016-08-21 17:45     ` [PATCH 2/2] IB/core: Delete an unnecessary initialisation in ib_is_udata_cleared() SF Markus Elfring
2016-08-21 18:03   ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() Joe Perches
     [not found]     ` <1471802623.3746.1.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2016-08-21 19:51       ` SF Markus Elfring
     [not found]         ` <683187e0-2e6a-88c0-f87a-9c5f0489370a-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2016-08-21 19:53           ` Joe Perches
     [not found]             ` <1471809188.3746.18.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2016-08-21 20:15               ` SF Markus Elfring
2016-08-22  9:46                 ` Yann Droneaud
     [not found]                   ` <1471859215.2764.24.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
2016-08-22 16:30                     ` [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-23 16:43                       ` 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).