All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations
@ 2017-02-18 20:45 ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:45 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 21:34:32 +0100

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

Markus Elfring (29):
  Use kcalloc() in mlx4_ib_alloc_pv_bufs()
  Improve another size determination in mlx4_ib_alloc_pv_bufs()
  Improve another size determination in mlx4_ib_alloc_demux_ctx()
  Improve another size determination in alloc_pv_object()
  Fix a typo in a comment line
  Delete three unnecessary return statements
  Split a condition check in handle_slaves_guid_change()
  Delete an unnecessary check before the function call "kfree" in free_pv_object()
  Move an assignment out of a check in forward_trap()
  Enclose 15 expressions for the sizeof operator by parentheses
  Use kmalloc_array() in three functions
  Enclose 17 expressions for the sizeof operator by parentheses
  Split a condition check in five functions
  Delete an unnecessary variable in __mlx4_ib_query_gid()
  Delete an unnecessary return statement in do_slave_init()
  Improve another size determination in do_slave_init()
  Improve another size determination in mlx4_ib_add()
  Delete an unnecessary variable initialisation in mlx4_ib_add()
  Delete an unnecessary variable assignment in mlx4_ib_add()
  Delete an error message for a failed memory allocation in mlx4_ib_add()
  Delete unnecessary braces in mlx4_ib_add()
  Use kmalloc_array() in alloc_proxy_bufs()
  Improve size determinations in create_qp_common()
  Delete unwanted spaces behind usages of the sizeof operator
  Add spaces for better code readability
  Enclose 14 expressions for the sizeof operator by parentheses
  Use kmalloc_array() in create_kernel_qp()
  Less function calls in create_kernel_qp() after error detection
  Use kmalloc_array() in create_srq_kernel()

 drivers/infiniband/hw/mlx4/mad.c  |  72 ++++++++--------
 drivers/infiniband/hw/mlx4/main.c | 164 ++++++++++++++++++++----------------
 drivers/infiniband/hw/mlx4/qp.c   | 173 +++++++++++++++++++-------------------
 drivers/infiniband/hw/mlx5/qp.c   |  66 ++++++++++-----
 drivers/infiniband/hw/mlx5/srq.c  |   5 +-
 5 files changed, 261 insertions(+), 219 deletions(-)

-- 
2.11.1

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

* [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations
@ 2017-02-18 20:45 ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:45 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 21:34:32 +0100

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

Markus Elfring (29):
  Use kcalloc() in mlx4_ib_alloc_pv_bufs()
  Improve another size determination in mlx4_ib_alloc_pv_bufs()
  Improve another size determination in mlx4_ib_alloc_demux_ctx()
  Improve another size determination in alloc_pv_object()
  Fix a typo in a comment line
  Delete three unnecessary return statements
  Split a condition check in handle_slaves_guid_change()
  Delete an unnecessary check before the function call "kfree" in free_pv_object()
  Move an assignment out of a check in forward_trap()
  Enclose 15 expressions for the sizeof operator by parentheses
  Use kmalloc_array() in three functions
  Enclose 17 expressions for the sizeof operator by parentheses
  Split a condition check in five functions
  Delete an unnecessary variable in __mlx4_ib_query_gid()
  Delete an unnecessary return statement in do_slave_init()
  Improve another size determination in do_slave_init()
  Improve another size determination in mlx4_ib_add()
  Delete an unnecessary variable initialisation in mlx4_ib_add()
  Delete an unnecessary variable assignment in mlx4_ib_add()
  Delete an error message for a failed memory allocation in mlx4_ib_add()
  Delete unnecessary braces in mlx4_ib_add()
  Use kmalloc_array() in alloc_proxy_bufs()
  Improve size determinations in create_qp_common()
  Delete unwanted spaces behind usages of the sizeof operator
  Add spaces for better code readability
  Enclose 14 expressions for the sizeof operator by parentheses
  Use kmalloc_array() in create_kernel_qp()
  Less function calls in create_kernel_qp() after error detection
  Use kmalloc_array() in create_srq_kernel()

 drivers/infiniband/hw/mlx4/mad.c  |  72 ++++++++--------
 drivers/infiniband/hw/mlx4/main.c | 164 ++++++++++++++++++++----------------
 drivers/infiniband/hw/mlx4/qp.c   | 173 +++++++++++++++++++-------------------
 drivers/infiniband/hw/mlx5/qp.c   |  66 ++++++++++-----
 drivers/infiniband/hw/mlx5/srq.c  |   5 +-
 5 files changed, 261 insertions(+), 219 deletions(-)

-- 
2.11.1


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

* [PATCH 01/29] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 20:47     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 17 Feb 2017 20:00:34 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index db564ccc0f92..61bd81baeb29 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1600,8 +1600,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -EINVAL;
 
 	tun_qp = &ctx->qp[qp_type];
-
-	tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS,
+	tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
+			       sizeof(*tun_qp->ring),
 			       GFP_KERNEL);
 	if (!tun_qp->ring)
 		return -ENOMEM;
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 01/29] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs()
@ 2017-02-18 20:47     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:47 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 20:00:34 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index db564ccc0f92..61bd81baeb29 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1600,8 +1600,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -EINVAL;
 
 	tun_qp = &ctx->qp[qp_type];
-
-	tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS,
+	tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
+			       sizeof(*tun_qp->ring),
 			       GFP_KERNEL);
 	if (!tun_qp->ring)
 		return -ENOMEM;
-- 
2.11.1

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

* [PATCH 01/29] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs()
@ 2017-02-18 20:47     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 20:00:34 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index db564ccc0f92..61bd81baeb29 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1600,8 +1600,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -EINVAL;
 
 	tun_qp = &ctx->qp[qp_type];
-
-	tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS,
+	tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
+			       sizeof(*tun_qp->ring),
 			       GFP_KERNEL);
 	if (!tun_qp->ring)
 		return -ENOMEM;
-- 
2.11.1


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

* [PATCH 02/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_pv_bufs()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 20:49     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:49 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 17 Feb 2017 20:05:38 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 61bd81baeb29..858da8746d49 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1607,7 +1607,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -ENOMEM;
 
 	tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
-				  sizeof (struct mlx4_ib_tun_tx_buf),
+				  sizeof(*tun_qp->tx_ring),
 				  GFP_KERNEL);
 	if (!tun_qp->tx_ring) {
 		kfree(tun_qp->ring);
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 02/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_pv_bufs()
@ 2017-02-18 20:49     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:49 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 20:05:38 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 61bd81baeb29..858da8746d49 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1607,7 +1607,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -ENOMEM;
 
 	tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
-				  sizeof (struct mlx4_ib_tun_tx_buf),
+				  sizeof(*tun_qp->tx_ring),
 				  GFP_KERNEL);
 	if (!tun_qp->tx_ring) {
 		kfree(tun_qp->ring);
-- 
2.11.1

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

* [PATCH 02/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_pv_bufs()
@ 2017-02-18 20:49     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:49 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 20:05:38 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 61bd81baeb29..858da8746d49 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1607,7 +1607,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -ENOMEM;
 
 	tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
-				  sizeof (struct mlx4_ib_tun_tx_buf),
+				  sizeof(*tun_qp->tx_ring),
 				  GFP_KERNEL);
 	if (!tun_qp->tx_ring) {
 		kfree(tun_qp->ring);
-- 
2.11.1


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

* [PATCH 03/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_demux_ctx()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 20:50     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:50 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 17 Feb 2017 20:15:02 +0100

Replace the specification of a data type by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 858da8746d49..284634d36b1c 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -2150,7 +2150,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 	int i;
 
 	ctx->tun = kcalloc(dev->dev->caps.sqp_demux,
-			   sizeof (struct mlx4_ib_demux_pv_ctx *), GFP_KERNEL);
+			   sizeof(*ctx->tun), GFP_KERNEL);
 	if (!ctx->tun)
 		return -ENOMEM;
 
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 03/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_demux_ctx()
@ 2017-02-18 20:50     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:50 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 20:15:02 +0100

Replace the specification of a data type by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 858da8746d49..284634d36b1c 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -2150,7 +2150,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 	int i;
 
 	ctx->tun = kcalloc(dev->dev->caps.sqp_demux,
-			   sizeof (struct mlx4_ib_demux_pv_ctx *), GFP_KERNEL);
+			   sizeof(*ctx->tun), GFP_KERNEL);
 	if (!ctx->tun)
 		return -ENOMEM;
 
-- 
2.11.1

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

* [PATCH 03/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_demux_ctx()
@ 2017-02-18 20:50     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:50 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 20:15:02 +0100

Replace the specification of a data type by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 858da8746d49..284634d36b1c 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -2150,7 +2150,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 	int i;
 
 	ctx->tun = kcalloc(dev->dev->caps.sqp_demux,
-			   sizeof (struct mlx4_ib_demux_pv_ctx *), GFP_KERNEL);
+			   sizeof(*ctx->tun), GFP_KERNEL);
 	if (!ctx->tun)
 		return -ENOMEM;
 
-- 
2.11.1


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

* [PATCH 04/29] IB/mlx4: Improve another size determination in alloc_pv_object()
  2017-02-18 20:45 ` SF Markus Elfring
@ 2017-02-18 20:51   ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:51 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 20:20:43 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 284634d36b1c..ea4892b0f39e 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1948,7 +1948,7 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
 	struct mlx4_ib_demux_pv_ctx *ctx;
 
 	*ret_ctx = NULL;
-	ctx = kzalloc(sizeof (struct mlx4_ib_demux_pv_ctx), GFP_KERNEL);
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;
 
-- 
2.11.1

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

* [PATCH 04/29] IB/mlx4: Improve another size determination in alloc_pv_object()
@ 2017-02-18 20:51   ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:51 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 20:20:43 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 284634d36b1c..ea4892b0f39e 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1948,7 +1948,7 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
 	struct mlx4_ib_demux_pv_ctx *ctx;
 
 	*ret_ctx = NULL;
-	ctx = kzalloc(sizeof (struct mlx4_ib_demux_pv_ctx), GFP_KERNEL);
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;
 
-- 
2.11.1


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

* [PATCH 05/29] IB/mlx4: Fix a typo in a comment line
  2017-02-18 20:45 ` SF Markus Elfring
@ 2017-02-18 20:52   ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:52 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 20:48:59 +0100

Add a missing character in this description and adjust
the comment formatting.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index ea4892b0f39e..d8c27e3ed69a 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1559,8 +1559,10 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
 		}
 	}
 
-	/* We are using standard ib_core services to send the mad, so generate a
-	 * stadard address handle by decoding the tunnelled mlx4_ah fields */
+	/*
+	 * We are using standard ib_core services to send the mad, so generate
+	 * a standard address handle by decoding the tunnelled mlx4_ah fields.
+	 */
 	memcpy(&ah.av, &tunnel->hdr.av, sizeof (struct mlx4_av));
 	ah.ibah.device = ctx->ib_dev;
 
-- 
2.11.1


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

* [PATCH 05/29] IB/mlx4: Fix a typo in a comment line
@ 2017-02-18 20:52   ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:52 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 20:48:59 +0100

Add a missing character in this description and adjust
the comment formatting.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index ea4892b0f39e..d8c27e3ed69a 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1559,8 +1559,10 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
 		}
 	}
 
-	/* We are using standard ib_core services to send the mad, so generate a
-	 * stadard address handle by decoding the tunnelled mlx4_ah fields */
+	/*
+	 * We are using standard ib_core services to send the mad, so generate
+	 * a standard address handle by decoding the tunnelled mlx4_ah fields.
+	 */
 	memcpy(&ah.av, &tunnel->hdr.av, sizeof (struct mlx4_av));
 	ah.ibah.device = ctx->ib_dev;
 
-- 
2.11.1


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

* [PATCH 06/29] IB/mlx4: Delete three unnecessary return statements
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 20:54     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:54 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 17 Feb 2017 21:34:27 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in the affected functions.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index d8c27e3ed69a..cf33efce69d2 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1173,7 +1173,6 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 out:
 	kfree(in_mad);
 	kfree(out_mad);
-	return;
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
@@ -2140,7 +2139,6 @@ void mlx4_ib_tunnels_update_work(struct work_struct *work)
 	mlx4_ib_tunnels_update(dmxw->dev, dmxw->slave, (int) dmxw->port,
 			       dmxw->do_init);
 	kfree(dmxw);
-	return;
 }
 
 static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
@@ -2268,7 +2266,6 @@ static void mlx4_ib_master_tunnels(struct mlx4_ib_dev *dev, int do_init)
 	/* initialize or tear down tunnel QPs for the master */
 	for (i = 0; i < dev->dev->caps.num_ports; i++)
 		mlx4_ib_tunnels_update(dev, mlx4_master_func_num(dev->dev), i + 1, do_init);
-	return;
 }
 
 int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev)
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 06/29] IB/mlx4: Delete three unnecessary return statements
@ 2017-02-18 20:54     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:54 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 21:34:27 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in the affected functions.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index d8c27e3ed69a..cf33efce69d2 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1173,7 +1173,6 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 out:
 	kfree(in_mad);
 	kfree(out_mad);
-	return;
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
@@ -2140,7 +2139,6 @@ void mlx4_ib_tunnels_update_work(struct work_struct *work)
 	mlx4_ib_tunnels_update(dmxw->dev, dmxw->slave, (int) dmxw->port,
 			       dmxw->do_init);
 	kfree(dmxw);
-	return;
 }
 
 static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
@@ -2268,7 +2266,6 @@ static void mlx4_ib_master_tunnels(struct mlx4_ib_dev *dev, int do_init)
 	/* initialize or tear down tunnel QPs for the master */
 	for (i = 0; i < dev->dev->caps.num_ports; i++)
 		mlx4_ib_tunnels_update(dev, mlx4_master_func_num(dev->dev), i + 1, do_init);
-	return;
 }
 
 int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev)
-- 
2.11.1

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

* [PATCH 06/29] IB/mlx4: Delete three unnecessary return statements
@ 2017-02-18 20:54     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:54 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 21:34:27 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in the affected functions.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index d8c27e3ed69a..cf33efce69d2 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1173,7 +1173,6 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 out:
 	kfree(in_mad);
 	kfree(out_mad);
-	return;
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
@@ -2140,7 +2139,6 @@ void mlx4_ib_tunnels_update_work(struct work_struct *work)
 	mlx4_ib_tunnels_update(dmxw->dev, dmxw->slave, (int) dmxw->port,
 			       dmxw->do_init);
 	kfree(dmxw);
-	return;
 }
 
 static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
@@ -2268,7 +2266,6 @@ static void mlx4_ib_master_tunnels(struct mlx4_ib_dev *dev, int do_init)
 	/* initialize or tear down tunnel QPs for the master */
 	for (i = 0; i < dev->dev->caps.num_ports; i++)
 		mlx4_ib_tunnels_update(dev, mlx4_master_func_num(dev->dev), i + 1, do_init);
-	return;
 }
 
 int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev)
-- 
2.11.1


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

* [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 20:55     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:55 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 17 Feb 2017 21:41:25 +0100

The kfree() function was called in up to two cases by the
handle_slaves_guid_change() function during error handling even if
the passed variable contained a null pointer.

* Split a condition check for memory allocation failures.

* Adjust jump targets according to the Linux coding style convention.

* Delete an initialisation for these variables at the beginning
  which became unnecessary with this refactoring.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index cf33efce69d2..75b6522b3a8f 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1128,17 +1128,20 @@ static void propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
 static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 				      u32 guid_tbl_blk_num, u32 change_bitmap)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad  = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	u16 i;
 
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
 	in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
+	if (!in_mad)
+		return;
+
 	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad)
+		goto free_in_mad;
 
 	guid_tbl_blk_num  *= 4;
 
@@ -1171,8 +1174,9 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	}
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change()
@ 2017-02-18 20:55     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:55 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 21:41:25 +0100

The kfree() function was called in up to two cases by the
handle_slaves_guid_change() function during error handling even if
the passed variable contained a null pointer.

* Split a condition check for memory allocation failures.

* Adjust jump targets according to the Linux coding style convention.

* Delete an initialisation for these variables at the beginning
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/mad.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index cf33efce69d2..75b6522b3a8f 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1128,17 +1128,20 @@ static void propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
 static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 				      u32 guid_tbl_blk_num, u32 change_bitmap)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad  = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	u16 i;
 
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
 	in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
+	if (!in_mad)
+		return;
+
 	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad)
+		goto free_in_mad;
 
 	guid_tbl_blk_num  *= 4;
 
@@ -1171,8 +1174,9 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	}
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
-- 
2.11.1

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

* [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change()
@ 2017-02-18 20:55     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:55 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 21:41:25 +0100

The kfree() function was called in up to two cases by the
handle_slaves_guid_change() function during error handling even if
the passed variable contained a null pointer.

* Split a condition check for memory allocation failures.

* Adjust jump targets according to the Linux coding style convention.

* Delete an initialisation for these variables at the beginning
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/mad.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index cf33efce69d2..75b6522b3a8f 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1128,17 +1128,20 @@ static void propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
 static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 				      u32 guid_tbl_blk_num, u32 change_bitmap)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad  = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	u16 i;
 
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
 	in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
+	if (!in_mad)
+		return;
+
 	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad)
+		goto free_in_mad;
 
 	guid_tbl_blk_num  *= 4;
 
@@ -1171,8 +1174,9 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	}
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
-- 
2.11.1


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

* [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 20:56     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:56 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 17 Feb 2017 22:06:24 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: kfree(NULL) is safe and this check is probably not required

Thus fix the affected source code place.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 75b6522b3a8f..9518b7244269 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1966,10 +1966,8 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
 
 static void free_pv_object(struct mlx4_ib_dev *dev, int slave, int port)
 {
-	if (dev->sriov.demux[port - 1].tun[slave]) {
-		kfree(dev->sriov.demux[port - 1].tun[slave]);
-		dev->sriov.demux[port - 1].tun[slave] = NULL;
-	}
+	kfree(dev->sriov.demux[port - 1].tun[slave]);
+	dev->sriov.demux[port - 1].tun[slave] = NULL;
 }
 
 static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object()
@ 2017-02-18 20:56     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:56 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 22:06:24 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: kfree(NULL) is safe and this check is probably not required

Thus fix the affected source code place.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 75b6522b3a8f..9518b7244269 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1966,10 +1966,8 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
 
 static void free_pv_object(struct mlx4_ib_dev *dev, int slave, int port)
 {
-	if (dev->sriov.demux[port - 1].tun[slave]) {
-		kfree(dev->sriov.demux[port - 1].tun[slave]);
-		dev->sriov.demux[port - 1].tun[slave] = NULL;
-	}
+	kfree(dev->sriov.demux[port - 1].tun[slave]);
+	dev->sriov.demux[port - 1].tun[slave] = NULL;
 }
 
 static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
-- 
2.11.1

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

* [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_objec
@ 2017-02-18 20:56     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:56 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 22:06:24 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: kfree(NULL) is safe and this check is probably not required

Thus fix the affected source code place.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 75b6522b3a8f..9518b7244269 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1966,10 +1966,8 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
 
 static void free_pv_object(struct mlx4_ib_dev *dev, int slave, int port)
 {
-	if (dev->sriov.demux[port - 1].tun[slave]) {
-		kfree(dev->sriov.demux[port - 1].tun[slave]);
-		dev->sriov.demux[port - 1].tun[slave] = NULL;
-	}
+	kfree(dev->sriov.demux[port - 1].tun[slave]);
+	dev->sriov.demux[port - 1].tun[slave] = NULL;
 }
 
 static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
-- 
2.11.1


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

* [PATCH 09/29] IB/mlx4: Move an assignment out of a check in forward_trap()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 20:57     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:57 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 17 Feb 2017 22:22:53 +0100

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code place.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 9518b7244269..860fec8b9601 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -401,7 +401,8 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
 		memcpy(send_buf->mad, mad, sizeof *mad);
-		if ((send_buf->ah = dev->sm_ah[port_num - 1]))
+		send_buf->ah = dev->sm_ah[port_num - 1];
+		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
 		else
 			ret = -EINVAL;
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 09/29] IB/mlx4: Move an assignment out of a check in forward_trap()
@ 2017-02-18 20:57     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:57 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 22:22:53 +0100

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/mad.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 9518b7244269..860fec8b9601 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -401,7 +401,8 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
 		memcpy(send_buf->mad, mad, sizeof *mad);
-		if ((send_buf->ah = dev->sm_ah[port_num - 1]))
+		send_buf->ah = dev->sm_ah[port_num - 1];
+		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
 		else
 			ret = -EINVAL;
-- 
2.11.1

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

* [PATCH 09/29] IB/mlx4: Move an assignment out of a check in forward_trap()
@ 2017-02-18 20:57     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:57 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Feb 2017 22:22:53 +0100

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/mad.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 9518b7244269..860fec8b9601 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -401,7 +401,8 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
 		memcpy(send_buf->mad, mad, sizeof *mad);
-		if ((send_buf->ah = dev->sm_ah[port_num - 1]))
+		send_buf->ah = dev->sm_ah[port_num - 1];
+		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
 		else
 			ret = -EINVAL;
-- 
2.11.1


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

* [PATCH 10/29] IB/mlx4: Enclose 15 expressions for the sizeof operator by parentheses
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 20:58     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:58 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 09:54:15 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

WARNING: sizeof … should be sizeof(…)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/hw/mlx4/mad.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 860fec8b9601..b26817f0669f 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -195,7 +195,7 @@ static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)
 	if (!dev->send_agent[port_num - 1][0])
 		return;
 
-	memset(&ah_attr, 0, sizeof ah_attr);
+	memset(&ah_attr, 0, sizeof(ah_attr));
 	ah_attr.dlid     = lid;
 	ah_attr.sl       = sl;
 	ah_attr.port_num = port_num;
@@ -400,7 +400,7 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 * it's OK for our devices).
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
-		memcpy(send_buf->mad, mad, sizeof *mad);
+		memcpy(send_buf->mad, mad, sizeof(*mad));
 		send_buf->ah = dev->sm_ah[port_num - 1];
 		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
@@ -555,7 +555,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 
 	/* create ah. Just need an empty one with the port num for the post send.
 	 * The driver will set the force loopback bit in post_send */
-	memset(&attr, 0, sizeof attr);
+	memset(&attr, 0, sizeof(attr));
 	attr.port_num = port;
 	if (is_eth) {
 		union ib_gid sgid;
@@ -590,8 +590,8 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 
 	/* copy over to tunnel buffer */
 	if (grh)
-		memcpy(&tun_mad->grh, grh, sizeof *grh);
-	memcpy(&tun_mad->mad, mad, sizeof *mad);
+		memcpy(&tun_mad->grh, grh, sizeof(*grh));
+	memcpy(&tun_mad->mad, mad, sizeof(*mad));
 
 	/* adjust tunnel data */
 	tun_mad->hdr.pkey_index = cpu_to_be16(tun_pkey_ix);
@@ -961,7 +961,7 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	}
 	mutex_unlock(&dev->counters_table[port_num - 1].mutex);
 	if (stats_avail) {
-		memset(out_mad->data, 0, sizeof out_mad->data);
+		memset(out_mad->data, 0, sizeof(out_mad->data));
 		switch (counter_stats.counter_mode & 0xf) {
 		case 0:
 			edit_counter(&counter_stats,
@@ -1136,11 +1136,11 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
-	in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
+	in_mad  = kmalloc(sizeof(*in_mad), GFP_KERNEL);
 	if (!in_mad)
 		return;
 
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!out_mad)
 		goto free_in_mad;
 
@@ -1149,8 +1149,8 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	for (i = 0; i < 4; i++) {
 		if (change_bitmap && (!((change_bitmap >> (8 * i)) & 0xff)))
 			continue;
-		memset(in_mad, 0, sizeof *in_mad);
-		memset(out_mad, 0, sizeof *out_mad);
+		memset(in_mad, 0, sizeof(*in_mad));
+		memset(out_mad, 0, sizeof(*out_mad));
 
 		in_mad->base_version  = 1;
 		in_mad->mgmt_class    = IB_MGMT_CLASS_SUBN_LID_ROUTED;
@@ -1421,7 +1421,7 @@ int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
 				   sizeof (struct mlx4_mad_snd_buf),
 				   DMA_TO_DEVICE);
 
-	memcpy(&sqp_mad->payload, mad, sizeof *mad);
+	memcpy(&sqp_mad->payload, mad, sizeof(*mad));
 
 	ib_dma_sync_single_for_device(&dev->ib_dev,
 				      sqp->tx_ring[wire_tx_ix].buf.map,
@@ -1804,7 +1804,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 
 	tun_qp = &ctx->qp[qp_type];
 
-	memset(&qp_init_attr, 0, sizeof qp_init_attr);
+	memset(&qp_init_attr, 0, sizeof(qp_init_attr));
 	qp_init_attr.init_attr.send_cq = ctx->cq;
 	qp_init_attr.init_attr.recv_cq = ctx->cq;
 	qp_init_attr.init_attr.sq_sig_type = IB_SIGNAL_ALL_WR;
@@ -1837,7 +1837,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 		return ret;
 	}
 
-	memset(&attr, 0, sizeof attr);
+	memset(&attr, 0, sizeof(attr));
 	attr.qp_state = IB_QPS_INIT;
 	ret = 0;
 	if (create_tun)
@@ -2184,7 +2184,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 		goto err_mcg;
 	}
 
-	snprintf(name, sizeof name, "mlx4_ibt%d", port);
+	snprintf(name, sizeof(name), "mlx4_ibt%d", port);
 	ctx->wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
 	if (!ctx->wq) {
 		pr_err("Failed to create tunnelling WQ for port %d\n", port);
@@ -2192,7 +2192,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 		goto err_wq;
 	}
 
-	snprintf(name, sizeof name, "mlx4_ibud%d", port);
+	snprintf(name, sizeof(name), "mlx4_ibud%d", port);
 	ctx->ud_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
 	if (!ctx->ud_wq) {
 		pr_err("Failed to create up/down WQ for port %d\n", port);
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 10/29] IB/mlx4: Enclose 15 expressions for the sizeof operator by parentheses
@ 2017-02-18 20:58     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:58 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 09:54:15 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

WARNING: sizeof … should be sizeof(…)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/mad.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 860fec8b9601..b26817f0669f 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -195,7 +195,7 @@ static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)
 	if (!dev->send_agent[port_num - 1][0])
 		return;
 
-	memset(&ah_attr, 0, sizeof ah_attr);
+	memset(&ah_attr, 0, sizeof(ah_attr));
 	ah_attr.dlid     = lid;
 	ah_attr.sl       = sl;
 	ah_attr.port_num = port_num;
@@ -400,7 +400,7 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 * it's OK for our devices).
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
-		memcpy(send_buf->mad, mad, sizeof *mad);
+		memcpy(send_buf->mad, mad, sizeof(*mad));
 		send_buf->ah = dev->sm_ah[port_num - 1];
 		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
@@ -555,7 +555,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 
 	/* create ah. Just need an empty one with the port num for the post send.
 	 * The driver will set the force loopback bit in post_send */
-	memset(&attr, 0, sizeof attr);
+	memset(&attr, 0, sizeof(attr));
 	attr.port_num = port;
 	if (is_eth) {
 		union ib_gid sgid;
@@ -590,8 +590,8 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 
 	/* copy over to tunnel buffer */
 	if (grh)
-		memcpy(&tun_mad->grh, grh, sizeof *grh);
-	memcpy(&tun_mad->mad, mad, sizeof *mad);
+		memcpy(&tun_mad->grh, grh, sizeof(*grh));
+	memcpy(&tun_mad->mad, mad, sizeof(*mad));
 
 	/* adjust tunnel data */
 	tun_mad->hdr.pkey_index = cpu_to_be16(tun_pkey_ix);
@@ -961,7 +961,7 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	}
 	mutex_unlock(&dev->counters_table[port_num - 1].mutex);
 	if (stats_avail) {
-		memset(out_mad->data, 0, sizeof out_mad->data);
+		memset(out_mad->data, 0, sizeof(out_mad->data));
 		switch (counter_stats.counter_mode & 0xf) {
 		case 0:
 			edit_counter(&counter_stats,
@@ -1136,11 +1136,11 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
-	in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
+	in_mad  = kmalloc(sizeof(*in_mad), GFP_KERNEL);
 	if (!in_mad)
 		return;
 
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!out_mad)
 		goto free_in_mad;
 
@@ -1149,8 +1149,8 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	for (i = 0; i < 4; i++) {
 		if (change_bitmap && (!((change_bitmap >> (8 * i)) & 0xff)))
 			continue;
-		memset(in_mad, 0, sizeof *in_mad);
-		memset(out_mad, 0, sizeof *out_mad);
+		memset(in_mad, 0, sizeof(*in_mad));
+		memset(out_mad, 0, sizeof(*out_mad));
 
 		in_mad->base_version  = 1;
 		in_mad->mgmt_class    = IB_MGMT_CLASS_SUBN_LID_ROUTED;
@@ -1421,7 +1421,7 @@ int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
 				   sizeof (struct mlx4_mad_snd_buf),
 				   DMA_TO_DEVICE);
 
-	memcpy(&sqp_mad->payload, mad, sizeof *mad);
+	memcpy(&sqp_mad->payload, mad, sizeof(*mad));
 
 	ib_dma_sync_single_for_device(&dev->ib_dev,
 				      sqp->tx_ring[wire_tx_ix].buf.map,
@@ -1804,7 +1804,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 
 	tun_qp = &ctx->qp[qp_type];
 
-	memset(&qp_init_attr, 0, sizeof qp_init_attr);
+	memset(&qp_init_attr, 0, sizeof(qp_init_attr));
 	qp_init_attr.init_attr.send_cq = ctx->cq;
 	qp_init_attr.init_attr.recv_cq = ctx->cq;
 	qp_init_attr.init_attr.sq_sig_type = IB_SIGNAL_ALL_WR;
@@ -1837,7 +1837,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 		return ret;
 	}
 
-	memset(&attr, 0, sizeof attr);
+	memset(&attr, 0, sizeof(attr));
 	attr.qp_state = IB_QPS_INIT;
 	ret = 0;
 	if (create_tun)
@@ -2184,7 +2184,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 		goto err_mcg;
 	}
 
-	snprintf(name, sizeof name, "mlx4_ibt%d", port);
+	snprintf(name, sizeof(name), "mlx4_ibt%d", port);
 	ctx->wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
 	if (!ctx->wq) {
 		pr_err("Failed to create tunnelling WQ for port %d\n", port);
@@ -2192,7 +2192,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 		goto err_wq;
 	}
 
-	snprintf(name, sizeof name, "mlx4_ibud%d", port);
+	snprintf(name, sizeof(name), "mlx4_ibud%d", port);
 	ctx->ud_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
 	if (!ctx->ud_wq) {
 		pr_err("Failed to create up/down WQ for port %d\n", port);
-- 
2.11.1

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

* [PATCH 10/29] IB/mlx4: Enclose 15 expressions for the sizeof operator by parentheses
@ 2017-02-18 20:58     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:58 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 09:54:15 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

WARNING: sizeof … should be sizeof(…)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/mad.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 860fec8b9601..b26817f0669f 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -195,7 +195,7 @@ static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)
 	if (!dev->send_agent[port_num - 1][0])
 		return;
 
-	memset(&ah_attr, 0, sizeof ah_attr);
+	memset(&ah_attr, 0, sizeof(ah_attr));
 	ah_attr.dlid     = lid;
 	ah_attr.sl       = sl;
 	ah_attr.port_num = port_num;
@@ -400,7 +400,7 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 * it's OK for our devices).
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
-		memcpy(send_buf->mad, mad, sizeof *mad);
+		memcpy(send_buf->mad, mad, sizeof(*mad));
 		send_buf->ah = dev->sm_ah[port_num - 1];
 		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
@@ -555,7 +555,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 
 	/* create ah. Just need an empty one with the port num for the post send.
 	 * The driver will set the force loopback bit in post_send */
-	memset(&attr, 0, sizeof attr);
+	memset(&attr, 0, sizeof(attr));
 	attr.port_num = port;
 	if (is_eth) {
 		union ib_gid sgid;
@@ -590,8 +590,8 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 
 	/* copy over to tunnel buffer */
 	if (grh)
-		memcpy(&tun_mad->grh, grh, sizeof *grh);
-	memcpy(&tun_mad->mad, mad, sizeof *mad);
+		memcpy(&tun_mad->grh, grh, sizeof(*grh));
+	memcpy(&tun_mad->mad, mad, sizeof(*mad));
 
 	/* adjust tunnel data */
 	tun_mad->hdr.pkey_index = cpu_to_be16(tun_pkey_ix);
@@ -961,7 +961,7 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	}
 	mutex_unlock(&dev->counters_table[port_num - 1].mutex);
 	if (stats_avail) {
-		memset(out_mad->data, 0, sizeof out_mad->data);
+		memset(out_mad->data, 0, sizeof(out_mad->data));
 		switch (counter_stats.counter_mode & 0xf) {
 		case 0:
 			edit_counter(&counter_stats,
@@ -1136,11 +1136,11 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
-	in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
+	in_mad  = kmalloc(sizeof(*in_mad), GFP_KERNEL);
 	if (!in_mad)
 		return;
 
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!out_mad)
 		goto free_in_mad;
 
@@ -1149,8 +1149,8 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	for (i = 0; i < 4; i++) {
 		if (change_bitmap && (!((change_bitmap >> (8 * i)) & 0xff)))
 			continue;
-		memset(in_mad, 0, sizeof *in_mad);
-		memset(out_mad, 0, sizeof *out_mad);
+		memset(in_mad, 0, sizeof(*in_mad));
+		memset(out_mad, 0, sizeof(*out_mad));
 
 		in_mad->base_version  = 1;
 		in_mad->mgmt_class    = IB_MGMT_CLASS_SUBN_LID_ROUTED;
@@ -1421,7 +1421,7 @@ int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
 				   sizeof (struct mlx4_mad_snd_buf),
 				   DMA_TO_DEVICE);
 
-	memcpy(&sqp_mad->payload, mad, sizeof *mad);
+	memcpy(&sqp_mad->payload, mad, sizeof(*mad));
 
 	ib_dma_sync_single_for_device(&dev->ib_dev,
 				      sqp->tx_ring[wire_tx_ix].buf.map,
@@ -1804,7 +1804,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 
 	tun_qp = &ctx->qp[qp_type];
 
-	memset(&qp_init_attr, 0, sizeof qp_init_attr);
+	memset(&qp_init_attr, 0, sizeof(qp_init_attr));
 	qp_init_attr.init_attr.send_cq = ctx->cq;
 	qp_init_attr.init_attr.recv_cq = ctx->cq;
 	qp_init_attr.init_attr.sq_sig_type = IB_SIGNAL_ALL_WR;
@@ -1837,7 +1837,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 		return ret;
 	}
 
-	memset(&attr, 0, sizeof attr);
+	memset(&attr, 0, sizeof(attr));
 	attr.qp_state = IB_QPS_INIT;
 	ret = 0;
 	if (create_tun)
@@ -2184,7 +2184,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 		goto err_mcg;
 	}
 
-	snprintf(name, sizeof name, "mlx4_ibt%d", port);
+	snprintf(name, sizeof(name), "mlx4_ibt%d", port);
 	ctx->wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
 	if (!ctx->wq) {
 		pr_err("Failed to create tunnelling WQ for port %d\n", port);
@@ -2192,7 +2192,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 		goto err_wq;
 	}
 
-	snprintf(name, sizeof name, "mlx4_ibud%d", port);
+	snprintf(name, sizeof(name), "mlx4_ibud%d", port);
 	ctx->ud_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
 	if (!ctx->ud_wq) {
 		pr_err("Failed to create up/down WQ for port %d\n", port);
-- 
2.11.1


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

* [PATCH 11/29] IB/mlx4: Use kmalloc_array() in three functions
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 20:59     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:59 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 10:32:32 +0100

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index ba6af84cc236..350c9148340e 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -304,7 +304,9 @@ static int mlx4_ib_add_gid(struct ib_device *device,
 		ctx->refcount++;
 	}
 	if (!ret && hw_update) {
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -359,7 +361,9 @@ static int mlx4_ib_del_gid(struct ib_device *device,
 	if (!ret && hw_update) {
 		int i;
 
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -2828,9 +2832,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 			goto err_counter;
 
 		ibdev->ib_uc_qpns_bitmap =
-			kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
-				sizeof(long),
-				GFP_KERNEL);
+			kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
+				      sizeof(long),
+				      GFP_KERNEL);
 		if (!ibdev->ib_uc_qpns_bitmap)
 			goto err_steer_qp_release;
 
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 11/29] IB/mlx4: Use kmalloc_array() in three functions
@ 2017-02-18 20:59     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:59 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 10:32:32 +0100

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index ba6af84cc236..350c9148340e 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -304,7 +304,9 @@ static int mlx4_ib_add_gid(struct ib_device *device,
 		ctx->refcount++;
 	}
 	if (!ret && hw_update) {
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -359,7 +361,9 @@ static int mlx4_ib_del_gid(struct ib_device *device,
 	if (!ret && hw_update) {
 		int i;
 
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -2828,9 +2832,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 			goto err_counter;
 
 		ibdev->ib_uc_qpns_bitmap =
-			kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
-				sizeof(long),
-				GFP_KERNEL);
+			kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
+				      sizeof(long),
+				      GFP_KERNEL);
 		if (!ibdev->ib_uc_qpns_bitmap)
 			goto err_steer_qp_release;
 
-- 
2.11.1

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

* [PATCH 11/29] IB/mlx4: Use kmalloc_array() in three functions
@ 2017-02-18 20:59     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 20:59 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 10:32:32 +0100

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index ba6af84cc236..350c9148340e 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -304,7 +304,9 @@ static int mlx4_ib_add_gid(struct ib_device *device,
 		ctx->refcount++;
 	}
 	if (!ret && hw_update) {
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -359,7 +361,9 @@ static int mlx4_ib_del_gid(struct ib_device *device,
 	if (!ret && hw_update) {
 		int i;
 
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -2828,9 +2832,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 			goto err_counter;
 
 		ibdev->ib_uc_qpns_bitmap -			kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
-				sizeof(long),
-				GFP_KERNEL);
+			kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
+				      sizeof(long),
+				      GFP_KERNEL);
 		if (!ibdev->ib_uc_qpns_bitmap)
 			goto err_steer_qp_release;
 
-- 
2.11.1


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

* [PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses
  2017-02-18 20:45 ` SF Markus Elfring
@ 2017-02-18 21:00   ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:00 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 11:28:41 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

WARNING: sizeof … should be sizeof(…)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 350c9148340e..b3b5ded85166 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -457,8 +457,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 
 	resp.response_length = offsetof(typeof(resp), response_length) +
 		sizeof(resp.response_length);
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	err = -ENOMEM;
 	if (!in_mad || !out_mad)
 		goto out;
@@ -471,8 +471,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	if (err)
 		goto out;
 
-	memset(props, 0, sizeof *props);
-
+	memset(props, 0, sizeof(*props));
 	have_ib_ports = num_ib_ports(dev->dev);
 
 	props->fw_ver = dev->dev->caps.fw_ver;
@@ -595,8 +594,8 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -771,8 +770,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -908,8 +907,8 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -1280,7 +1279,7 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
 	struct mlx4_ib_pd *pd;
 	int err;
 
-	pd = kmalloc(sizeof *pd, GFP_KERNEL);
+	pd = kmalloc(sizeof(*pd), GFP_KERNEL);
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 
@@ -1319,7 +1318,7 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev,
 	if (!(to_mdev(ibdev)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
 		return ERR_PTR(-ENOSYS);
 
-	xrcd = kmalloc(sizeof *xrcd, GFP_KERNEL);
+	xrcd = kmalloc(sizeof(*xrcd), GFP_KERNEL);
 	if (!xrcd)
 		return ERR_PTR(-ENOMEM);
 
@@ -1367,7 +1366,7 @@ static int add_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
 	struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
 	struct mlx4_ib_gid_entry *ge;
 
-	ge = kzalloc(sizeof *ge, GFP_KERNEL);
+	ge = kzalloc(sizeof(*ge), GFP_KERNEL);
 	if (!ge)
 		return -ENOMEM;
 
@@ -2089,8 +2088,8 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -2600,7 +2599,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	if (num_ports == 0)
 		return NULL;
 
-	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
+	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
 	if (!ibdev) {
 		dev_err(&dev->persist->pdev->dev,
 			"Device struct alloc failed\n");
@@ -3301,12 +3300,12 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
 		break;
 
 	case MLX4_DEV_EVENT_PORT_MGMT_CHANGE:
-		ew = kmalloc(sizeof *ew, GFP_ATOMIC);
+		ew = kmalloc(sizeof(*ew), GFP_ATOMIC);
 		if (!ew)
 			break;
 
 		INIT_WORK(&ew->work, handle_port_mgmt_change_event);
-		memcpy(&ew->ib_eqe, eqe, sizeof *eqe);
+		memcpy(&ew->ib_eqe, eqe, sizeof(*eqe));
 		ew->ib_dev = ibdev;
 		/* need to queue only for port owner, which uses GEN_EQE */
 		if (mlx4_is_master(dev))
-- 
2.11.1

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

* [PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses
@ 2017-02-18 21:00   ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:00 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 11:28:41 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

WARNING: sizeof … should be sizeof(…)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 350c9148340e..b3b5ded85166 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -457,8 +457,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 
 	resp.response_length = offsetof(typeof(resp), response_length) +
 		sizeof(resp.response_length);
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	err = -ENOMEM;
 	if (!in_mad || !out_mad)
 		goto out;
@@ -471,8 +471,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	if (err)
 		goto out;
 
-	memset(props, 0, sizeof *props);
-
+	memset(props, 0, sizeof(*props));
 	have_ib_ports = num_ib_ports(dev->dev);
 
 	props->fw_ver = dev->dev->caps.fw_ver;
@@ -595,8 +594,8 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -771,8 +770,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -908,8 +907,8 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -1280,7 +1279,7 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
 	struct mlx4_ib_pd *pd;
 	int err;
 
-	pd = kmalloc(sizeof *pd, GFP_KERNEL);
+	pd = kmalloc(sizeof(*pd), GFP_KERNEL);
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 
@@ -1319,7 +1318,7 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev,
 	if (!(to_mdev(ibdev)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
 		return ERR_PTR(-ENOSYS);
 
-	xrcd = kmalloc(sizeof *xrcd, GFP_KERNEL);
+	xrcd = kmalloc(sizeof(*xrcd), GFP_KERNEL);
 	if (!xrcd)
 		return ERR_PTR(-ENOMEM);
 
@@ -1367,7 +1366,7 @@ static int add_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
 	struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
 	struct mlx4_ib_gid_entry *ge;
 
-	ge = kzalloc(sizeof *ge, GFP_KERNEL);
+	ge = kzalloc(sizeof(*ge), GFP_KERNEL);
 	if (!ge)
 		return -ENOMEM;
 
@@ -2089,8 +2088,8 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -2600,7 +2599,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	if (num_ports = 0)
 		return NULL;
 
-	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
+	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
 	if (!ibdev) {
 		dev_err(&dev->persist->pdev->dev,
 			"Device struct alloc failed\n");
@@ -3301,12 +3300,12 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
 		break;
 
 	case MLX4_DEV_EVENT_PORT_MGMT_CHANGE:
-		ew = kmalloc(sizeof *ew, GFP_ATOMIC);
+		ew = kmalloc(sizeof(*ew), GFP_ATOMIC);
 		if (!ew)
 			break;
 
 		INIT_WORK(&ew->work, handle_port_mgmt_change_event);
-		memcpy(&ew->ib_eqe, eqe, sizeof *eqe);
+		memcpy(&ew->ib_eqe, eqe, sizeof(*eqe));
 		ew->ib_dev = ibdev;
 		/* need to queue only for port owner, which uses GEN_EQE */
 		if (mlx4_is_master(dev))
-- 
2.11.1


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

* [PATCH 13/29] IB/mlx4: Split a condition check in five functions
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:01     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:01 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 14:43:34 +0100

The kfree() function was called in up to two cases during error handling
even if the passed variable contained a null pointer.

* Split a condition check for memory allocation failures.

* Adjust jump targets according to the Linux coding style convention.

* Delete initialisations for variables at the beginning
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/hw/mlx4/main.c | 90 +++++++++++++++++++++++++--------------
 1 file changed, 59 insertions(+), 31 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b3b5ded85166..c0c299ffa0f6 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -432,8 +432,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 				struct ib_udata *uhw)
 {
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int err;
 	int have_ib_ports;
 	struct mlx4_uverbs_ex_query_device cmd;
@@ -458,10 +458,14 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	resp.response_length = offsetof(typeof(resp), response_length) +
 		sizeof(resp.response_length);
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	err = -ENOMEM;
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
@@ -570,9 +574,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 			goto out;
 	}
 out:
-	kfree(in_mad);
 	kfree(out_mad);
-
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -588,16 +592,21 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num)
 static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 			      struct ib_port_attr *props, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int ext_active_speed;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -670,8 +679,9 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 		 props->active_speed = IB_SPEED_SDR;
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -763,17 +773,22 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
 int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 			union ib_gid *gid, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
-	int err = -ENOMEM;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
+	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
 	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -811,8 +826,9 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 out:
 	if (clear)
 		memset(gid->raw + 8, 0, 8);
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -902,15 +918,20 @@ static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
 int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 			 u16 *pkey, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PKEY_TABLE;
@@ -927,8 +948,9 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 	*pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -2083,15 +2105,20 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 
 static int init_node_data(struct mlx4_ib_dev *dev)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
@@ -2114,8 +2141,9 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 13/29] IB/mlx4: Split a condition check in five functions
@ 2017-02-18 21:01     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:01 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 14:43:34 +0100

The kfree() function was called in up to two cases during error handling
even if the passed variable contained a null pointer.

* Split a condition check for memory allocation failures.

* Adjust jump targets according to the Linux coding style convention.

* Delete initialisations for variables at the beginning
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 90 +++++++++++++++++++++++++--------------
 1 file changed, 59 insertions(+), 31 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b3b5ded85166..c0c299ffa0f6 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -432,8 +432,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 				struct ib_udata *uhw)
 {
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int err;
 	int have_ib_ports;
 	struct mlx4_uverbs_ex_query_device cmd;
@@ -458,10 +458,14 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	resp.response_length = offsetof(typeof(resp), response_length) +
 		sizeof(resp.response_length);
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	err = -ENOMEM;
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
@@ -570,9 +574,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 			goto out;
 	}
 out:
-	kfree(in_mad);
 	kfree(out_mad);
-
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -588,16 +592,21 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num)
 static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 			      struct ib_port_attr *props, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int ext_active_speed;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -670,8 +679,9 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 		 props->active_speed = IB_SPEED_SDR;
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -763,17 +773,22 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
 int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 			union ib_gid *gid, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
-	int err = -ENOMEM;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
+	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
 	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -811,8 +826,9 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 out:
 	if (clear)
 		memset(gid->raw + 8, 0, 8);
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -902,15 +918,20 @@ static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
 int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 			 u16 *pkey, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PKEY_TABLE;
@@ -927,8 +948,9 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 	*pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -2083,15 +2105,20 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 
 static int init_node_data(struct mlx4_ib_dev *dev)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
@@ -2114,8 +2141,9 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
-- 
2.11.1

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

* [PATCH 13/29] IB/mlx4: Split a condition check in five functions
@ 2017-02-18 21:01     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:01 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 14:43:34 +0100

The kfree() function was called in up to two cases during error handling
even if the passed variable contained a null pointer.

* Split a condition check for memory allocation failures.

* Adjust jump targets according to the Linux coding style convention.

* Delete initialisations for variables at the beginning
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 90 +++++++++++++++++++++++++--------------
 1 file changed, 59 insertions(+), 31 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b3b5ded85166..c0c299ffa0f6 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -432,8 +432,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 				struct ib_udata *uhw)
 {
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int err;
 	int have_ib_ports;
 	struct mlx4_uverbs_ex_query_device cmd;
@@ -458,10 +458,14 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	resp.response_length = offsetof(typeof(resp), response_length) +
 		sizeof(resp.response_length);
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	err = -ENOMEM;
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
@@ -570,9 +574,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 			goto out;
 	}
 out:
-	kfree(in_mad);
 	kfree(out_mad);
-
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -588,16 +592,21 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num)
 static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 			      struct ib_port_attr *props, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int ext_active_speed;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -670,8 +679,9 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 		 props->active_speed = IB_SPEED_SDR;
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -763,17 +773,22 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
 int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 			union ib_gid *gid, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
-	int err = -ENOMEM;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
+	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
 	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -811,8 +826,9 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 out:
 	if (clear)
 		memset(gid->raw + 8, 0, 8);
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -902,15 +918,20 @@ static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
 int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 			 u16 *pkey, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PKEY_TABLE;
@@ -927,8 +948,9 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 	*pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -2083,15 +2105,20 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 
 static int init_node_data(struct mlx4_ib_dev *dev)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
@@ -2114,8 +2141,9 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
-- 
2.11.1


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

* [PATCH 14/29] IB/mlx4: Delete an unnecessary variable in __mlx4_ib_query_gid()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:02     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:02 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 15:04:50 +0100

* Call the function "memset" directly in an if branch without using
  an intermediate variable.

* Delete the local variable "clear" which became unnecessary with
  this refactoring.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index c0c299ffa0f6..89bbb61d62f5 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -777,7 +777,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	struct ib_smp *out_mad;
 	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
@@ -806,8 +805,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	if (mlx4_is_mfunc(dev->dev) && !netw_view) {
 		if (index) {
 			/* For any index > 0, return the null guid */
+			memset(gid->raw + 8, 0, 8);
 			err = 0;
-			clear = 1;
 			goto out;
 		}
 	}
@@ -824,8 +823,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
 
 out:
-	if (clear)
-		memset(gid->raw + 8, 0, 8);
 	kfree(out_mad);
 free_in_mad:
 	kfree(in_mad);
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 14/29] IB/mlx4: Delete an unnecessary variable in __mlx4_ib_query_gid()
@ 2017-02-18 21:02     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:02 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:04:50 +0100

* Call the function "memset" directly in an if branch without using
  an intermediate variable.

* Delete the local variable "clear" which became unnecessary with
  this refactoring.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index c0c299ffa0f6..89bbb61d62f5 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -777,7 +777,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	struct ib_smp *out_mad;
 	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
@@ -806,8 +805,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	if (mlx4_is_mfunc(dev->dev) && !netw_view) {
 		if (index) {
 			/* For any index > 0, return the null guid */
+			memset(gid->raw + 8, 0, 8);
 			err = 0;
-			clear = 1;
 			goto out;
 		}
 	}
@@ -824,8 +823,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
 
 out:
-	if (clear)
-		memset(gid->raw + 8, 0, 8);
 	kfree(out_mad);
 free_in_mad:
 	kfree(in_mad);
-- 
2.11.1

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

* [PATCH 14/29] IB/mlx4: Delete an unnecessary variable in __mlx4_ib_query_gid()
@ 2017-02-18 21:02     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:02 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:04:50 +0100

* Call the function "memset" directly in an if branch without using
  an intermediate variable.

* Delete the local variable "clear" which became unnecessary with
  this refactoring.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index c0c299ffa0f6..89bbb61d62f5 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -777,7 +777,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	struct ib_smp *out_mad;
 	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
@@ -806,8 +805,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	if (mlx4_is_mfunc(dev->dev) && !netw_view) {
 		if (index) {
 			/* For any index > 0, return the null guid */
+			memset(gid->raw + 8, 0, 8);
 			err = 0;
-			clear = 1;
 			goto out;
 		}
 	}
@@ -824,8 +823,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
 
 out:
-	if (clear)
-		memset(gid->raw + 8, 0, 8);
 	kfree(out_mad);
 free_in_mad:
 	kfree(in_mad);
-- 
2.11.1


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

* [PATCH 15/29] IB/mlx4: Delete an unnecessary return statement in do_slave_init()
  2017-02-18 20:45 ` SF Markus Elfring
@ 2017-02-18 21:03   ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:03 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:16:54 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement here.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 89bbb61d62f5..b2b472977a39 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -3131,7 +3131,6 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 	}
 out:
 	kfree(dm);
-	return;
 }
 
 static void mlx4_ib_handle_catas_error(struct mlx4_ib_dev *ibdev)
-- 
2.11.1


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

* [PATCH 15/29] IB/mlx4: Delete an unnecessary return statement in do_slave_init()
@ 2017-02-18 21:03   ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:03 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:16:54 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement here.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 89bbb61d62f5..b2b472977a39 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -3131,7 +3131,6 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 	}
 out:
 	kfree(dm);
-	return;
 }
 
 static void mlx4_ib_handle_catas_error(struct mlx4_ib_dev *ibdev)
-- 
2.11.1


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

* [PATCH 16/29] IB/mlx4: Improve another size determination in do_slave_init()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:04     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:04 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 15:25:19 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b2b472977a39..b78f17623121 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -3106,7 +3106,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		return;
 
 	for (i = 0; i < ports; i++) {
-		dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC);
+		dm[i] = kmalloc(sizeof(*dm[i]), GFP_ATOMIC);
 		if (!dm[i]) {
 			while (--i >= 0)
 				kfree(dm[i]);
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 16/29] IB/mlx4: Improve another size determination in do_slave_init()
@ 2017-02-18 21:04     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:04 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:25:19 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b2b472977a39..b78f17623121 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -3106,7 +3106,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		return;
 
 	for (i = 0; i < ports; i++) {
-		dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC);
+		dm[i] = kmalloc(sizeof(*dm[i]), GFP_ATOMIC);
 		if (!dm[i]) {
 			while (--i >= 0)
 				kfree(dm[i]);
-- 
2.11.1

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

* [PATCH 16/29] IB/mlx4: Improve another size determination in do_slave_init()
@ 2017-02-18 21:04     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:04 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:25:19 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b2b472977a39..b78f17623121 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -3106,7 +3106,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		return;
 
 	for (i = 0; i < ports; i++) {
-		dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC);
+		dm[i] = kmalloc(sizeof(*dm[i]), GFP_ATOMIC);
 		if (!dm[i]) {
 			while (--i >= 0)
 				kfree(dm[i]);
-- 
2.11.1


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

* [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:05     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:05 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 15:43:54 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b78f17623121..f3194f2a6e62 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2825,9 +2825,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	}
 	if (mlx4_is_bonded(dev))
 		for (i = 1; i < ibdev->num_ports ; ++i) {
-			new_counter_index =
-					kmalloc(sizeof(struct counter_index),
-						GFP_KERNEL);
+			new_counter_index = kmalloc(sizeof(*new_counter_index),
+						    GFP_KERNEL);
 			if (!new_counter_index)
 				goto err_counter;
 			new_counter_index->index = counter_index;
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add()
@ 2017-02-18 21:05     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:05 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:43:54 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b78f17623121..f3194f2a6e62 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2825,9 +2825,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	}
 	if (mlx4_is_bonded(dev))
 		for (i = 1; i < ibdev->num_ports ; ++i) {
-			new_counter_index =
-					kmalloc(sizeof(struct counter_index),
-						GFP_KERNEL);
+			new_counter_index = kmalloc(sizeof(*new_counter_index),
+						    GFP_KERNEL);
 			if (!new_counter_index)
 				goto err_counter;
 			new_counter_index->index = counter_index;
-- 
2.11.1

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

* [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add()
@ 2017-02-18 21:05     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:05 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:43:54 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index b78f17623121..f3194f2a6e62 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2825,9 +2825,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	}
 	if (mlx4_is_bonded(dev))
 		for (i = 1; i < ibdev->num_ports ; ++i) {
-			new_counter_index -					kmalloc(sizeof(struct counter_index),
-						GFP_KERNEL);
+			new_counter_index = kmalloc(sizeof(*new_counter_index),
+						    GFP_KERNEL);
 			if (!new_counter_index)
 				goto err_counter;
 			new_counter_index->index = counter_index;
-- 
2.11.1


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

* [PATCH 18/29] IB/mlx4: Delete an unnecessary variable initialisation in mlx4_ib_add()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:06     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:06 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 15:52:31 +0100

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

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index f3194f2a6e62..4e08e4d57181 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2612,7 +2612,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	int num_req_counters;
 	int allocated;
 	u32 counter_index;
-	struct counter_index *new_counter_index = NULL;
+	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
 
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 18/29] IB/mlx4: Delete an unnecessary variable initialisation in mlx4_ib_add()
@ 2017-02-18 21:06     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:06 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:52:31 +0100

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

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index f3194f2a6e62..4e08e4d57181 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2612,7 +2612,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	int num_req_counters;
 	int allocated;
 	u32 counter_index;
-	struct counter_index *new_counter_index = NULL;
+	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
 
-- 
2.11.1

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

* [PATCH 18/29] IB/mlx4: Delete an unnecessary variable initialisation in mlx4_ib_add()
@ 2017-02-18 21:06     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:06 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 15:52:31 +0100

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

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index f3194f2a6e62..4e08e4d57181 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2612,7 +2612,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	int num_req_counters;
 	int allocated;
 	u32 counter_index;
-	struct counter_index *new_counter_index = NULL;
+	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
 
-- 
2.11.1


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

* [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:08     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:08 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 16:00:28 +0100

Delete an assignment for the local variable "num_ports" at the beginning
because it was initialised with the same value.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 4e08e4d57181..21b88d5ceda4 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2615,8 +2615,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
-
-	num_ports = 0;
 	mlx4_foreach_ib_transport_port(i, dev)
 		num_ports++;
 
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add()
@ 2017-02-18 21:08     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:08 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:00:28 +0100

Delete an assignment for the local variable "num_ports" at the beginning
because it was initialised with the same value.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 4e08e4d57181..21b88d5ceda4 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2615,8 +2615,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
-
-	num_ports = 0;
 	mlx4_foreach_ib_transport_port(i, dev)
 		num_ports++;
 
-- 
2.11.1

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

* [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add()
@ 2017-02-18 21:08     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:08 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:00:28 +0100

Delete an assignment for the local variable "num_ports" at the beginning
because it was initialised with the same value.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 4e08e4d57181..21b88d5ceda4 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2615,8 +2615,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
-
-	num_ports = 0;
 	mlx4_foreach_ib_transport_port(i, dev)
 		num_ports++;
 
-- 
2.11.1


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

* [PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:10     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:10 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 16:15:20 +0100

Omit an extra message for a memory allocation failure in this function.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/hw/mlx4/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 21b88d5ceda4..33b46c463ffa 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2623,11 +2623,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		return NULL;
 
 	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
-	if (!ibdev) {
-		dev_err(&dev->persist->pdev->dev,
-			"Device struct alloc failed\n");
+	if (!ibdev)
 		return NULL;
-	}
 
 	iboe = &ibdev->iboe;
 
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add()
@ 2017-02-18 21:10     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:10 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:15:20 +0100

Omit an extra message for a memory allocation failure in this function.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 21b88d5ceda4..33b46c463ffa 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2623,11 +2623,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		return NULL;
 
 	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
-	if (!ibdev) {
-		dev_err(&dev->persist->pdev->dev,
-			"Device struct alloc failed\n");
+	if (!ibdev)
 		return NULL;
-	}
 
 	iboe = &ibdev->iboe;
 
-- 
2.11.1

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

* [PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add()
@ 2017-02-18 21:10     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:10 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:15:20 +0100

Omit an extra message for a memory allocation failure in this function.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 21b88d5ceda4..33b46c463ffa 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2623,11 +2623,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		return NULL;
 
 	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
-	if (!ibdev) {
-		dev_err(&dev->persist->pdev->dev,
-			"Device struct alloc failed\n");
+	if (!ibdev)
 		return NULL;
-	}
 
 	iboe = &ibdev->iboe;
 
-- 
2.11.1


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

* [PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add()
  2017-02-18 20:45 ` SF Markus Elfring
@ 2017-02-18 21:11   ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:11 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:32:41 +0100

Do not use curly brackets at one source code place
where a single statement should be sufficient.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 33b46c463ffa..b950538e036e 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2898,9 +2898,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		}
 		if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
 			err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
-			if (err) {
+			if (err)
 				goto err_notif;
-			}
 		}
 	}
 
-- 
2.11.1

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

* [PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add()
@ 2017-02-18 21:11   ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:11 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:32:41 +0100

Do not use curly brackets at one source code place
where a single statement should be sufficient.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 33b46c463ffa..b950538e036e 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2898,9 +2898,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		}
 		if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
 			err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
-			if (err) {
+			if (err)
 				goto err_notif;
-			}
 		}
 	}
 
-- 
2.11.1


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

* [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:12     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:12 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 16:56:52 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 7d76f769233c..11fec4a8fae5 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 {
 	int i;
 
-	qp->sqp_proxy_rcv =
-		kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
-			GFP_KERNEL);
+	qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
+					  sizeof(*qp->sqp_proxy_rcv),
+					  GFP_KERNEL);
 	if (!qp->sqp_proxy_rcv)
 		return -ENOMEM;
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs()
@ 2017-02-18 21:12     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:12 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:56:52 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 7d76f769233c..11fec4a8fae5 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 {
 	int i;
 
-	qp->sqp_proxy_rcv =
-		kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
-			GFP_KERNEL);
+	qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
+					  sizeof(*qp->sqp_proxy_rcv),
+					  GFP_KERNEL);
 	if (!qp->sqp_proxy_rcv)
 		return -ENOMEM;
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
-- 
2.11.1

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

* [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs()
@ 2017-02-18 21:12     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:12 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 16:56:52 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 7d76f769233c..11fec4a8fae5 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 {
 	int i;
 
-	qp->sqp_proxy_rcv -		kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
-			GFP_KERNEL);
+	qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
+					  sizeof(*qp->sqp_proxy_rcv),
+					  GFP_KERNEL);
 	if (!qp->sqp_proxy_rcv)
 		return -ENOMEM;
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
-- 
2.11.1


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

* [PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common()
  2017-02-18 20:45 ` SF Markus Elfring
@ 2017-02-18 21:13   ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:13 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 18:29:30 +0100

Replace the specification of two data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determinations a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 11fec4a8fae5..cc7bd257a1fd 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
 		if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI ||
 		    (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
 				MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
-			sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
+			sqp = kzalloc(sizeof(*sqp), gfp);
 			if (!sqp)
 				return -ENOMEM;
 			qp = &sqp->qp;
 			qp->pri.vid = 0xFFFF;
 			qp->alt.vid = 0xFFFF;
 		} else {
-			qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
+			qp = kzalloc(sizeof(*qp), gfp);
 			if (!qp)
 				return -ENOMEM;
 			qp->pri.vid = 0xFFFF;
-- 
2.11.1

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

* [PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common()
@ 2017-02-18 21:13   ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:13 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 18:29:30 +0100

Replace the specification of two data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determinations a bit safer according to the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 11fec4a8fae5..cc7bd257a1fd 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
 		if (qp_type = MLX4_IB_QPT_SMI || qp_type = MLX4_IB_QPT_GSI ||
 		    (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
 				MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
-			sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
+			sqp = kzalloc(sizeof(*sqp), gfp);
 			if (!sqp)
 				return -ENOMEM;
 			qp = &sqp->qp;
 			qp->pri.vid = 0xFFFF;
 			qp->alt.vid = 0xFFFF;
 		} else {
-			qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
+			qp = kzalloc(sizeof(*qp), gfp);
 			if (!qp)
 				return -ENOMEM;
 			qp->pri.vid = 0xFFFF;
-- 
2.11.1


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

* [PATCH 24/29] IB/mlx4: Delete unwanted spaces behind usages of the sizeof operator
  2017-02-18 20:45 ` SF Markus Elfring
@ 2017-02-18 21:14   ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:14 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 18:33:00 +0100

* Replace the source code "sizeof (" by "sizeof("
  according to the Linux coding style convention.

* Adjust indentation at a few places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/qp.c | 128 ++++++++++++++++++++--------------------
 1 file changed, 63 insertions(+), 65 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index cc7bd257a1fd..47a647c1d94f 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -340,39 +340,39 @@ static int send_wqe_overhead(enum mlx4_ib_qp_type type, u32 flags)
 	 */
 	switch (type) {
 	case MLX4_IB_QPT_UD:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg) +
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg) +
 			((flags & MLX4_IB_QP_LSO) ? MLX4_IB_LSO_HEADER_SPARE : 0);
 	case MLX4_IB_QPT_PROXY_SMI_OWNER:
 	case MLX4_IB_QPT_PROXY_SMI:
 	case MLX4_IB_QPT_PROXY_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg) + 64;
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg) + 64;
 	case MLX4_IB_QPT_TUN_SMI_OWNER:
 	case MLX4_IB_QPT_TUN_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg);
 
 	case MLX4_IB_QPT_UC:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_raddr_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_raddr_seg);
 	case MLX4_IB_QPT_RC:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_masked_atomic_seg) +
-			sizeof (struct mlx4_wqe_raddr_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_masked_atomic_seg) +
+			sizeof(struct mlx4_wqe_raddr_seg);
 	case MLX4_IB_QPT_SMI:
 	case MLX4_IB_QPT_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
 			ALIGN(MLX4_IB_UD_HEADER_SIZE +
 			      DIV_ROUND_UP(MLX4_IB_UD_HEADER_SIZE,
 					   MLX4_INLINE_ALIGN) *
-			      sizeof (struct mlx4_wqe_inline_seg),
-			      sizeof (struct mlx4_wqe_data_seg)) +
+			      sizeof(struct mlx4_wqe_inline_seg),
+			      sizeof(struct mlx4_wqe_data_seg)) +
 			ALIGN(4 +
-			      sizeof (struct mlx4_wqe_inline_seg),
-			      sizeof (struct mlx4_wqe_data_seg));
+			      sizeof(struct mlx4_wqe_inline_seg),
+			      sizeof(struct mlx4_wqe_data_seg));
 	default:
-		return sizeof (struct mlx4_wqe_ctrl_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg);
 	}
 }
 
@@ -396,7 +396,8 @@ static int set_rq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 
 		qp->rq.wqe_cnt	 = roundup_pow_of_two(max(1U, cap->max_recv_wr));
 		qp->rq.max_gs	 = roundup_pow_of_two(max(1U, cap->max_recv_sge));
-		qp->rq.wqe_shift = ilog2(qp->rq.max_gs * sizeof (struct mlx4_wqe_data_seg));
+		qp->rq.wqe_shift = ilog2(qp->rq.max_gs
+					 * sizeof(struct mlx4_wqe_data_seg));
 	}
 
 	/* leave userspace return values as they were, so as not to break ABI */
@@ -424,7 +425,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	if (cap->max_send_wr  > (dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE) ||
 	    cap->max_send_sge > min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg) ||
 	    cap->max_inline_data + send_wqe_overhead(type, qp->flags) +
-	    sizeof (struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
+	    sizeof(struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
 		return -EINVAL;
 
 	/*
@@ -436,8 +437,8 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	    cap->max_send_sge + 2 > dev->dev->caps.max_sq_sg)
 		return -EINVAL;
 
-	s = max(cap->max_send_sge * sizeof (struct mlx4_wqe_data_seg),
-		cap->max_inline_data + sizeof (struct mlx4_wqe_inline_seg)) +
+	s = max(cap->max_send_sge * sizeof(struct mlx4_wqe_data_seg),
+		cap->max_inline_data + sizeof(struct mlx4_wqe_inline_seg)) +
 		send_wqe_overhead(type, qp->flags);
 
 	if (s > dev->dev->caps.max_sq_desc_sz)
@@ -507,7 +508,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	qp->sq.max_gs = (min(dev->dev->caps.max_sq_desc_sz,
 			     (qp->sq_max_wqes_per_wr << qp->sq.wqe_shift)) -
 			 send_wqe_overhead(type, qp->flags)) /
-		sizeof (struct mlx4_wqe_data_seg);
+		sizeof(struct mlx4_wqe_data_seg);
 
 	qp->buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) +
 		(qp->sq.wqe_cnt << qp->sq.wqe_shift);
@@ -561,13 +562,13 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 		return -ENOMEM;
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
 		qp->sqp_proxy_rcv[i].addr =
-			kmalloc(sizeof (struct mlx4_ib_proxy_sqp_hdr),
+			kmalloc(sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				GFP_KERNEL);
 		if (!qp->sqp_proxy_rcv[i].addr)
 			goto err;
 		qp->sqp_proxy_rcv[i].map =
 			ib_dma_map_single(dev, qp->sqp_proxy_rcv[i].addr,
-					  sizeof (struct mlx4_ib_proxy_sqp_hdr),
+					  sizeof(struct mlx4_ib_proxy_sqp_hdr),
 					  DMA_FROM_DEVICE);
 		if (ib_dma_mapping_error(dev, qp->sqp_proxy_rcv[i].map)) {
 			kfree(qp->sqp_proxy_rcv[i].addr);
@@ -580,7 +581,7 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 	while (i > 0) {
 		--i;
 		ib_dma_unmap_single(dev, qp->sqp_proxy_rcv[i].map,
-				    sizeof (struct mlx4_ib_proxy_sqp_hdr),
+				    sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				    DMA_FROM_DEVICE);
 		kfree(qp->sqp_proxy_rcv[i].addr);
 	}
@@ -595,7 +596,7 @@ static void free_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
 		ib_dma_unmap_single(dev, qp->sqp_proxy_rcv[i].map,
-				    sizeof (struct mlx4_ib_proxy_sqp_hdr),
+				    sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				    DMA_FROM_DEVICE);
 		kfree(qp->sqp_proxy_rcv[i].addr);
 	}
@@ -2318,7 +2319,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	/* for proxy-qp0 sends, need to add in size of tunnel header */
 	/* for tunnel-qp0 sends, tunnel header is already in s/g list */
 	if (sqp->qp.mlx4_ib_qp_type == MLX4_IB_QPT_PROXY_SMI_OWNER)
-		send_size += sizeof (struct mlx4_ib_tunnel_header);
+		send_size += sizeof(struct mlx4_ib_tunnel_header);
 
 	ib_ud_header_init(send_size, 1, 0, 0, 0, 0, 0, 0, &sqp->ud_header);
 
@@ -2400,7 +2401,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	}
 
 	*mlx_seg_len =
-	ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + header_size, 16);
+	ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + header_size, 16);
 	return 0;
 }
 
@@ -2678,7 +2679,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 	}
 
 	*mlx_seg_len =
-		ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + header_size, 16);
+		ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + header_size, 16);
 	return 0;
 }
 
@@ -2769,7 +2770,7 @@ static void set_masked_atomic_seg(struct mlx4_wqe_masked_atomic_seg *aseg,
 static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
 			     struct ib_ud_wr *wr)
 {
-	memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof (struct mlx4_av));
+	memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof(struct mlx4_av));
 	dseg->dqpn = cpu_to_be32(wr->remote_qpn);
 	dseg->qkey = cpu_to_be32(wr->remote_qkey);
 	dseg->vlan = to_mah(wr->ah)->av.eth.vlan;
@@ -2791,7 +2792,7 @@ static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev,
 	sqp_av.sl_tclass_flowlabel = av->ib.sl_tclass_flowlabel &
 			cpu_to_be32(0xf0000000);
 
-	memcpy(dseg->av, &sqp_av, sizeof (struct mlx4_av));
+	memcpy(dseg->av, &sqp_av, sizeof(struct mlx4_av));
 	if (qpt == MLX4_IB_QPT_PROXY_GSI)
 		dseg->dqpn = cpu_to_be32(dev->dev->caps.qp1_tunnel[port - 1]);
 	else
@@ -2817,10 +2818,10 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 
 	spc = MLX4_INLINE_ALIGN -
 		((unsigned long) (inl + 1) & (MLX4_INLINE_ALIGN - 1));
-	if (sizeof (hdr) <= spc) {
-		memcpy(inl + 1, &hdr, sizeof (hdr));
+	if (sizeof(hdr) <= spc) {
+		memcpy(inl + 1, &hdr, sizeof(hdr));
 		wmb();
-		inl->byte_count = cpu_to_be32(1 << 31 | sizeof (hdr));
+		inl->byte_count = cpu_to_be32(1 << 31 | sizeof(hdr));
 		i = 1;
 	} else {
 		memcpy(inl + 1, &hdr, spc);
@@ -2828,14 +2829,14 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 		inl->byte_count = cpu_to_be32(1 << 31 | spc);
 
 		inl = (void *) (inl + 1) + spc;
-		memcpy(inl + 1, (void *) &hdr + spc, sizeof (hdr) - spc);
+		memcpy(inl + 1, (void *) &hdr + spc, sizeof(hdr) - spc);
 		wmb();
-		inl->byte_count = cpu_to_be32(1 << 31 | (sizeof (hdr) - spc));
+		inl->byte_count = cpu_to_be32(1 << 31 | (sizeof(hdr) - spc));
 		i = 2;
 	}
 
 	*mlx_seg_len =
-		ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + sizeof (hdr), 16);
+		ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + sizeof(hdr), 16);
 }
 
 static void set_mlx_icrc_seg(void *dseg)
@@ -3022,27 +3023,23 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			case IB_WR_MASKED_ATOMIC_FETCH_AND_ADD:
 				set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
 					      atomic_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
 				set_atomic_seg(wqe, atomic_wr(wr));
-				wqe  += sizeof (struct mlx4_wqe_atomic_seg);
-
-				size += (sizeof (struct mlx4_wqe_raddr_seg) +
-					 sizeof (struct mlx4_wqe_atomic_seg)) / 16;
-
+				wqe  += sizeof(struct mlx4_wqe_atomic_seg);
+				size += (sizeof(struct mlx4_wqe_raddr_seg) +
+					 sizeof(struct mlx4_wqe_atomic_seg))
+					/ 16;
 				break;
 
 			case IB_WR_MASKED_ATOMIC_CMP_AND_SWP:
 				set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
 					      atomic_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
 				set_masked_atomic_seg(wqe, atomic_wr(wr));
-				wqe  += sizeof (struct mlx4_wqe_masked_atomic_seg);
-
-				size += (sizeof (struct mlx4_wqe_raddr_seg) +
-					 sizeof (struct mlx4_wqe_masked_atomic_seg)) / 16;
-
+				wqe  += sizeof(struct mlx4_wqe_masked_atomic_seg);
+				size += (sizeof(struct mlx4_wqe_raddr_seg) +
+					 sizeof(struct mlx4_wqe_masked_atomic_seg))
+					/ 16;
 				break;
 
 			case IB_WR_RDMA_READ:
@@ -3050,16 +3047,17 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			case IB_WR_RDMA_WRITE_WITH_IMM:
 				set_raddr_seg(wqe, rdma_wr(wr)->remote_addr,
 					      rdma_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-				size += sizeof (struct mlx4_wqe_raddr_seg) / 16;
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
+				size += sizeof(struct mlx4_wqe_raddr_seg) / 16;
 				break;
 
 			case IB_WR_LOCAL_INV:
 				ctrl->srcrb_flags |=
 					cpu_to_be32(MLX4_WQE_CTRL_STRONG_ORDER);
 				set_local_inv_seg(wqe, wr->ex.invalidate_rkey);
-				wqe  += sizeof (struct mlx4_wqe_local_inval_seg);
-				size += sizeof (struct mlx4_wqe_local_inval_seg) / 16;
+				wqe  += sizeof(struct mlx4_wqe_local_inval_seg);
+				size += sizeof(struct mlx4_wqe_local_inval_seg)
+					/ 16;
 				break;
 
 			case IB_WR_REG_MR:
@@ -3092,13 +3090,13 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			set_datagram_seg(wqe, ud_wr(wr));
 			/* set the forced-loopback bit in the data seg av */
 			*(__be32 *) wqe |= cpu_to_be32(0x80000000);
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 			break;
 		case MLX4_IB_QPT_UD:
 			set_datagram_seg(wqe, ud_wr(wr));
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 
 			if (wr->opcode == IB_WR_LSO) {
 				err = build_lso_seg(wqe, ud_wr(wr), qp, &seglen,
@@ -3139,8 +3137,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			set_tunnel_datagram_seg(to_mdev(ibqp->device), wqe,
 						ud_wr(wr),
 						qp->mlx4_ib_qp_type);
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 			build_tunnel_header(ud_wr(wr), wqe, &seglen);
 			wqe  += seglen;
 			size += seglen / 16;
@@ -3171,7 +3169,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 
 		dseg = wqe;
 		dseg += wr->num_sge - 1;
-		size += wr->num_sge * (sizeof (struct mlx4_wqe_data_seg) / 16);
+		size += wr->num_sge * (sizeof(struct mlx4_wqe_data_seg) / 16);
 
 		/* Add one more inline data segment for ICRC for MLX sends */
 		if (unlikely(qp->mlx4_ib_qp_type == MLX4_IB_QPT_SMI ||
@@ -3179,7 +3177,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			     qp->mlx4_ib_qp_type &
 			     (MLX4_IB_QPT_PROXY_SMI_OWNER | MLX4_IB_QPT_TUN_SMI_OWNER))) {
 			set_mlx_icrc_seg(dseg + 1);
-			size += sizeof (struct mlx4_wqe_data_seg) / 16;
+			size += sizeof(struct mlx4_wqe_data_seg) / 16;
 		}
 
 		for (i = wr->num_sge - 1; i >= 0; --i, --dseg)
@@ -3304,10 +3302,10 @@ int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
 		    MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) {
 			ib_dma_sync_single_for_device(ibqp->device,
 						      qp->sqp_proxy_rcv[ind].map,
-						      sizeof (struct mlx4_ib_proxy_sqp_hdr),
+						      sizeof(struct mlx4_ib_proxy_sqp_hdr),
 						      DMA_FROM_DEVICE);
 			scat->byte_count =
-				cpu_to_be32(sizeof (struct mlx4_ib_proxy_sqp_hdr));
+				cpu_to_be32(sizeof(struct mlx4_ib_proxy_sqp_hdr));
 			/* use dma lkey from upper layer entry */
 			scat->lkey = cpu_to_be32(wr->sg_list->lkey);
 			scat->addr = cpu_to_be64(qp->sqp_proxy_rcv[ind].map);
-- 
2.11.1

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

* [PATCH 24/29] IB/mlx4: Delete unwanted spaces behind usages of the sizeof operator
@ 2017-02-18 21:14   ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:14 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 18:33:00 +0100

* Replace the source code "sizeof (" by "sizeof("
  according to the Linux coding style convention.

* Adjust indentation at a few places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/qp.c | 128 ++++++++++++++++++++--------------------
 1 file changed, 63 insertions(+), 65 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index cc7bd257a1fd..47a647c1d94f 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -340,39 +340,39 @@ static int send_wqe_overhead(enum mlx4_ib_qp_type type, u32 flags)
 	 */
 	switch (type) {
 	case MLX4_IB_QPT_UD:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg) +
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg) +
 			((flags & MLX4_IB_QP_LSO) ? MLX4_IB_LSO_HEADER_SPARE : 0);
 	case MLX4_IB_QPT_PROXY_SMI_OWNER:
 	case MLX4_IB_QPT_PROXY_SMI:
 	case MLX4_IB_QPT_PROXY_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg) + 64;
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg) + 64;
 	case MLX4_IB_QPT_TUN_SMI_OWNER:
 	case MLX4_IB_QPT_TUN_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg);
 
 	case MLX4_IB_QPT_UC:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_raddr_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_raddr_seg);
 	case MLX4_IB_QPT_RC:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_masked_atomic_seg) +
-			sizeof (struct mlx4_wqe_raddr_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_masked_atomic_seg) +
+			sizeof(struct mlx4_wqe_raddr_seg);
 	case MLX4_IB_QPT_SMI:
 	case MLX4_IB_QPT_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
 			ALIGN(MLX4_IB_UD_HEADER_SIZE +
 			      DIV_ROUND_UP(MLX4_IB_UD_HEADER_SIZE,
 					   MLX4_INLINE_ALIGN) *
-			      sizeof (struct mlx4_wqe_inline_seg),
-			      sizeof (struct mlx4_wqe_data_seg)) +
+			      sizeof(struct mlx4_wqe_inline_seg),
+			      sizeof(struct mlx4_wqe_data_seg)) +
 			ALIGN(4 +
-			      sizeof (struct mlx4_wqe_inline_seg),
-			      sizeof (struct mlx4_wqe_data_seg));
+			      sizeof(struct mlx4_wqe_inline_seg),
+			      sizeof(struct mlx4_wqe_data_seg));
 	default:
-		return sizeof (struct mlx4_wqe_ctrl_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg);
 	}
 }
 
@@ -396,7 +396,8 @@ static int set_rq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 
 		qp->rq.wqe_cnt	 = roundup_pow_of_two(max(1U, cap->max_recv_wr));
 		qp->rq.max_gs	 = roundup_pow_of_two(max(1U, cap->max_recv_sge));
-		qp->rq.wqe_shift = ilog2(qp->rq.max_gs * sizeof (struct mlx4_wqe_data_seg));
+		qp->rq.wqe_shift = ilog2(qp->rq.max_gs
+					 * sizeof(struct mlx4_wqe_data_seg));
 	}
 
 	/* leave userspace return values as they were, so as not to break ABI */
@@ -424,7 +425,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	if (cap->max_send_wr  > (dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE) ||
 	    cap->max_send_sge > min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg) ||
 	    cap->max_inline_data + send_wqe_overhead(type, qp->flags) +
-	    sizeof (struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
+	    sizeof(struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
 		return -EINVAL;
 
 	/*
@@ -436,8 +437,8 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	    cap->max_send_sge + 2 > dev->dev->caps.max_sq_sg)
 		return -EINVAL;
 
-	s = max(cap->max_send_sge * sizeof (struct mlx4_wqe_data_seg),
-		cap->max_inline_data + sizeof (struct mlx4_wqe_inline_seg)) +
+	s = max(cap->max_send_sge * sizeof(struct mlx4_wqe_data_seg),
+		cap->max_inline_data + sizeof(struct mlx4_wqe_inline_seg)) +
 		send_wqe_overhead(type, qp->flags);
 
 	if (s > dev->dev->caps.max_sq_desc_sz)
@@ -507,7 +508,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	qp->sq.max_gs = (min(dev->dev->caps.max_sq_desc_sz,
 			     (qp->sq_max_wqes_per_wr << qp->sq.wqe_shift)) -
 			 send_wqe_overhead(type, qp->flags)) /
-		sizeof (struct mlx4_wqe_data_seg);
+		sizeof(struct mlx4_wqe_data_seg);
 
 	qp->buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) +
 		(qp->sq.wqe_cnt << qp->sq.wqe_shift);
@@ -561,13 +562,13 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 		return -ENOMEM;
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
 		qp->sqp_proxy_rcv[i].addr -			kmalloc(sizeof (struct mlx4_ib_proxy_sqp_hdr),
+			kmalloc(sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				GFP_KERNEL);
 		if (!qp->sqp_proxy_rcv[i].addr)
 			goto err;
 		qp->sqp_proxy_rcv[i].map  			ib_dma_map_single(dev, qp->sqp_proxy_rcv[i].addr,
-					  sizeof (struct mlx4_ib_proxy_sqp_hdr),
+					  sizeof(struct mlx4_ib_proxy_sqp_hdr),
 					  DMA_FROM_DEVICE);
 		if (ib_dma_mapping_error(dev, qp->sqp_proxy_rcv[i].map)) {
 			kfree(qp->sqp_proxy_rcv[i].addr);
@@ -580,7 +581,7 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 	while (i > 0) {
 		--i;
 		ib_dma_unmap_single(dev, qp->sqp_proxy_rcv[i].map,
-				    sizeof (struct mlx4_ib_proxy_sqp_hdr),
+				    sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				    DMA_FROM_DEVICE);
 		kfree(qp->sqp_proxy_rcv[i].addr);
 	}
@@ -595,7 +596,7 @@ static void free_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
 		ib_dma_unmap_single(dev, qp->sqp_proxy_rcv[i].map,
-				    sizeof (struct mlx4_ib_proxy_sqp_hdr),
+				    sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				    DMA_FROM_DEVICE);
 		kfree(qp->sqp_proxy_rcv[i].addr);
 	}
@@ -2318,7 +2319,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	/* for proxy-qp0 sends, need to add in size of tunnel header */
 	/* for tunnel-qp0 sends, tunnel header is already in s/g list */
 	if (sqp->qp.mlx4_ib_qp_type = MLX4_IB_QPT_PROXY_SMI_OWNER)
-		send_size += sizeof (struct mlx4_ib_tunnel_header);
+		send_size += sizeof(struct mlx4_ib_tunnel_header);
 
 	ib_ud_header_init(send_size, 1, 0, 0, 0, 0, 0, 0, &sqp->ud_header);
 
@@ -2400,7 +2401,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	}
 
 	*mlx_seg_len -	ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + header_size, 16);
+	ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + header_size, 16);
 	return 0;
 }
 
@@ -2678,7 +2679,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 	}
 
 	*mlx_seg_len -		ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + header_size, 16);
+		ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + header_size, 16);
 	return 0;
 }
 
@@ -2769,7 +2770,7 @@ static void set_masked_atomic_seg(struct mlx4_wqe_masked_atomic_seg *aseg,
 static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
 			     struct ib_ud_wr *wr)
 {
-	memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof (struct mlx4_av));
+	memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof(struct mlx4_av));
 	dseg->dqpn = cpu_to_be32(wr->remote_qpn);
 	dseg->qkey = cpu_to_be32(wr->remote_qkey);
 	dseg->vlan = to_mah(wr->ah)->av.eth.vlan;
@@ -2791,7 +2792,7 @@ static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev,
 	sqp_av.sl_tclass_flowlabel = av->ib.sl_tclass_flowlabel &
 			cpu_to_be32(0xf0000000);
 
-	memcpy(dseg->av, &sqp_av, sizeof (struct mlx4_av));
+	memcpy(dseg->av, &sqp_av, sizeof(struct mlx4_av));
 	if (qpt = MLX4_IB_QPT_PROXY_GSI)
 		dseg->dqpn = cpu_to_be32(dev->dev->caps.qp1_tunnel[port - 1]);
 	else
@@ -2817,10 +2818,10 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 
 	spc = MLX4_INLINE_ALIGN -
 		((unsigned long) (inl + 1) & (MLX4_INLINE_ALIGN - 1));
-	if (sizeof (hdr) <= spc) {
-		memcpy(inl + 1, &hdr, sizeof (hdr));
+	if (sizeof(hdr) <= spc) {
+		memcpy(inl + 1, &hdr, sizeof(hdr));
 		wmb();
-		inl->byte_count = cpu_to_be32(1 << 31 | sizeof (hdr));
+		inl->byte_count = cpu_to_be32(1 << 31 | sizeof(hdr));
 		i = 1;
 	} else {
 		memcpy(inl + 1, &hdr, spc);
@@ -2828,14 +2829,14 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 		inl->byte_count = cpu_to_be32(1 << 31 | spc);
 
 		inl = (void *) (inl + 1) + spc;
-		memcpy(inl + 1, (void *) &hdr + spc, sizeof (hdr) - spc);
+		memcpy(inl + 1, (void *) &hdr + spc, sizeof(hdr) - spc);
 		wmb();
-		inl->byte_count = cpu_to_be32(1 << 31 | (sizeof (hdr) - spc));
+		inl->byte_count = cpu_to_be32(1 << 31 | (sizeof(hdr) - spc));
 		i = 2;
 	}
 
 	*mlx_seg_len -		ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + sizeof (hdr), 16);
+		ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + sizeof(hdr), 16);
 }
 
 static void set_mlx_icrc_seg(void *dseg)
@@ -3022,27 +3023,23 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			case IB_WR_MASKED_ATOMIC_FETCH_AND_ADD:
 				set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
 					      atomic_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
 				set_atomic_seg(wqe, atomic_wr(wr));
-				wqe  += sizeof (struct mlx4_wqe_atomic_seg);
-
-				size += (sizeof (struct mlx4_wqe_raddr_seg) +
-					 sizeof (struct mlx4_wqe_atomic_seg)) / 16;
-
+				wqe  += sizeof(struct mlx4_wqe_atomic_seg);
+				size += (sizeof(struct mlx4_wqe_raddr_seg) +
+					 sizeof(struct mlx4_wqe_atomic_seg))
+					/ 16;
 				break;
 
 			case IB_WR_MASKED_ATOMIC_CMP_AND_SWP:
 				set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
 					      atomic_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
 				set_masked_atomic_seg(wqe, atomic_wr(wr));
-				wqe  += sizeof (struct mlx4_wqe_masked_atomic_seg);
-
-				size += (sizeof (struct mlx4_wqe_raddr_seg) +
-					 sizeof (struct mlx4_wqe_masked_atomic_seg)) / 16;
-
+				wqe  += sizeof(struct mlx4_wqe_masked_atomic_seg);
+				size += (sizeof(struct mlx4_wqe_raddr_seg) +
+					 sizeof(struct mlx4_wqe_masked_atomic_seg))
+					/ 16;
 				break;
 
 			case IB_WR_RDMA_READ:
@@ -3050,16 +3047,17 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			case IB_WR_RDMA_WRITE_WITH_IMM:
 				set_raddr_seg(wqe, rdma_wr(wr)->remote_addr,
 					      rdma_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-				size += sizeof (struct mlx4_wqe_raddr_seg) / 16;
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
+				size += sizeof(struct mlx4_wqe_raddr_seg) / 16;
 				break;
 
 			case IB_WR_LOCAL_INV:
 				ctrl->srcrb_flags | 					cpu_to_be32(MLX4_WQE_CTRL_STRONG_ORDER);
 				set_local_inv_seg(wqe, wr->ex.invalidate_rkey);
-				wqe  += sizeof (struct mlx4_wqe_local_inval_seg);
-				size += sizeof (struct mlx4_wqe_local_inval_seg) / 16;
+				wqe  += sizeof(struct mlx4_wqe_local_inval_seg);
+				size += sizeof(struct mlx4_wqe_local_inval_seg)
+					/ 16;
 				break;
 
 			case IB_WR_REG_MR:
@@ -3092,13 +3090,13 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			set_datagram_seg(wqe, ud_wr(wr));
 			/* set the forced-loopback bit in the data seg av */
 			*(__be32 *) wqe |= cpu_to_be32(0x80000000);
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 			break;
 		case MLX4_IB_QPT_UD:
 			set_datagram_seg(wqe, ud_wr(wr));
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 
 			if (wr->opcode = IB_WR_LSO) {
 				err = build_lso_seg(wqe, ud_wr(wr), qp, &seglen,
@@ -3139,8 +3137,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			set_tunnel_datagram_seg(to_mdev(ibqp->device), wqe,
 						ud_wr(wr),
 						qp->mlx4_ib_qp_type);
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 			build_tunnel_header(ud_wr(wr), wqe, &seglen);
 			wqe  += seglen;
 			size += seglen / 16;
@@ -3171,7 +3169,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 
 		dseg = wqe;
 		dseg += wr->num_sge - 1;
-		size += wr->num_sge * (sizeof (struct mlx4_wqe_data_seg) / 16);
+		size += wr->num_sge * (sizeof(struct mlx4_wqe_data_seg) / 16);
 
 		/* Add one more inline data segment for ICRC for MLX sends */
 		if (unlikely(qp->mlx4_ib_qp_type = MLX4_IB_QPT_SMI ||
@@ -3179,7 +3177,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			     qp->mlx4_ib_qp_type &
 			     (MLX4_IB_QPT_PROXY_SMI_OWNER | MLX4_IB_QPT_TUN_SMI_OWNER))) {
 			set_mlx_icrc_seg(dseg + 1);
-			size += sizeof (struct mlx4_wqe_data_seg) / 16;
+			size += sizeof(struct mlx4_wqe_data_seg) / 16;
 		}
 
 		for (i = wr->num_sge - 1; i >= 0; --i, --dseg)
@@ -3304,10 +3302,10 @@ int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
 		    MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) {
 			ib_dma_sync_single_for_device(ibqp->device,
 						      qp->sqp_proxy_rcv[ind].map,
-						      sizeof (struct mlx4_ib_proxy_sqp_hdr),
+						      sizeof(struct mlx4_ib_proxy_sqp_hdr),
 						      DMA_FROM_DEVICE);
 			scat->byte_count -				cpu_to_be32(sizeof (struct mlx4_ib_proxy_sqp_hdr));
+				cpu_to_be32(sizeof(struct mlx4_ib_proxy_sqp_hdr));
 			/* use dma lkey from upper layer entry */
 			scat->lkey = cpu_to_be32(wr->sg_list->lkey);
 			scat->addr = cpu_to_be64(qp->sqp_proxy_rcv[ind].map);
-- 
2.11.1


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

* [PATCH 25/29] IB/mlx4: Add spaces for better code readability
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:15     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:15 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 18:52:11 +0100

Use space characters at some source code places according to
the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 47a647c1d94f..16164ff09a86 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1063,7 +1063,7 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
 	list_del(&qp->cq_recv_list);
 	if (!is_user) {
 		__mlx4_ib_cq_clean(recv_cq, qp->mqp.qpn,
-				 qp->ibqp.srq ? to_msrq(qp->ibqp.srq): NULL);
+				   qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
 		if (send_cq != recv_cq)
 			__mlx4_ib_cq_clean(send_cq, qp->mqp.qpn, NULL);
 	}
@@ -2585,7 +2585,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 		u16 ether_type;
 		u16 pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 29) << 13;
 
-		ether_type = (!is_udp) ? ETH_P_IBOE:
+		ether_type = (!is_udp) ? ETH_P_IBOE :
 			(ip_version == 4 ? ETH_P_IP : ETH_P_IPV6);
 
 		mlx->sched_prio = cpu_to_be16(pcp);
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 25/29] IB/mlx4: Add spaces for better code readability
@ 2017-02-18 21:15     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:15 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 18:52:11 +0100

Use space characters at some source code places according to
the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 47a647c1d94f..16164ff09a86 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1063,7 +1063,7 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
 	list_del(&qp->cq_recv_list);
 	if (!is_user) {
 		__mlx4_ib_cq_clean(recv_cq, qp->mqp.qpn,
-				 qp->ibqp.srq ? to_msrq(qp->ibqp.srq): NULL);
+				   qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
 		if (send_cq != recv_cq)
 			__mlx4_ib_cq_clean(send_cq, qp->mqp.qpn, NULL);
 	}
@@ -2585,7 +2585,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 		u16 ether_type;
 		u16 pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 29) << 13;
 
-		ether_type = (!is_udp) ? ETH_P_IBOE:
+		ether_type = (!is_udp) ? ETH_P_IBOE :
 			(ip_version == 4 ? ETH_P_IP : ETH_P_IPV6);
 
 		mlx->sched_prio = cpu_to_be16(pcp);
-- 
2.11.1

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

* [PATCH 25/29] IB/mlx4: Add spaces for better code readability
@ 2017-02-18 21:15     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:15 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 18:52:11 +0100

Use space characters at some source code places according to
the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 47a647c1d94f..16164ff09a86 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1063,7 +1063,7 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
 	list_del(&qp->cq_recv_list);
 	if (!is_user) {
 		__mlx4_ib_cq_clean(recv_cq, qp->mqp.qpn,
-				 qp->ibqp.srq ? to_msrq(qp->ibqp.srq): NULL);
+				   qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
 		if (send_cq != recv_cq)
 			__mlx4_ib_cq_clean(send_cq, qp->mqp.qpn, NULL);
 	}
@@ -2585,7 +2585,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 		u16 ether_type;
 		u16 pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 29) << 13;
 
-		ether_type = (!is_udp) ? ETH_P_IBOE:
+		ether_type = (!is_udp) ? ETH_P_IBOE :
 			(ip_version = 4 ? ETH_P_IP : ETH_P_IPV6);
 
 		mlx->sched_prio = cpu_to_be16(pcp);
-- 
2.11.1


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

* [PATCH 26/29] IB/mlx4: Enclose 14 expressions for the sizeof operator by parentheses
  2017-02-18 20:45 ` SF Markus Elfring
@ 2017-02-18 21:16   ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:16 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 19:30:41 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

WARNING: sizeof … should be sizeof(…)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/qp.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 16164ff09a86..3ffba8ebba7f 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -247,9 +247,10 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size)
 	s = sizeof(struct mlx4_wqe_ctrl_seg);
 
 	if (qp->ibqp.qp_type == IB_QPT_UD) {
-		struct mlx4_wqe_datagram_seg *dgram = wqe + sizeof *ctrl;
+		struct mlx4_wqe_datagram_seg *dgram = wqe + sizeof(*ctrl);
 		struct mlx4_av *av = (struct mlx4_av *)dgram->av;
-		memset(dgram, 0, sizeof *dgram);
+
+		memset(dgram, 0, sizeof(*dgram));
 		av->port_pd = cpu_to_be32((qp->port << 24) | to_mpd(qp->ibqp.pd)->pdn);
 		s += sizeof(struct mlx4_wqe_datagram_seg);
 	}
@@ -257,7 +258,8 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size)
 	/* Pad the remainder of the WQE with an inline data segment. */
 	if (size > s) {
 		inl = wqe + s;
-		inl->byte_count = cpu_to_be32(1 << 31 | (size - s - sizeof *inl));
+		inl->byte_count = cpu_to_be32(1 << 31
+					      | (size - s - sizeof(*inl)));
 	}
 	ctrl->srcrb_flags = 0;
 	ctrl->qpn_vlan.fence_size = size / 16;
@@ -727,7 +729,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
 	if (pd->uobject) {
 		struct mlx4_ib_create_qp ucmd;
 
-		if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+		if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
 			err = -EFAULT;
 			goto err;
 		}
@@ -1180,7 +1182,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd,
 	case IB_QPT_RC:
 	case IB_QPT_UC:
 	case IB_QPT_RAW_PACKET:
-		qp = kzalloc(sizeof *qp, gfp);
+		qp = kzalloc(sizeof(*qp), gfp);
 		if (!qp)
 			return ERR_PTR(-ENOMEM);
 		qp->pri.vid = 0xFFFF;
@@ -1635,7 +1637,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 	    IB_LINK_LAYER_ETHERNET)
 		return -ENOTSUPP;
 
-	context = kzalloc(sizeof *context, GFP_KERNEL);
+	context = kzalloc(sizeof(*context), GFP_KERNEL);
 	if (!context)
 		return -ENOMEM;
 
@@ -2299,7 +2301,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	struct mlx4_ib_dev *mdev = to_mdev(sqp->qp.ibqp.device);
 	struct ib_device *ib_dev = &mdev->ib_dev;
 	struct mlx4_wqe_mlx_seg *mlx = wqe;
-	struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
+	struct mlx4_wqe_inline_seg *inl = wqe + sizeof(*mlx);
 	struct mlx4_ib_ah *ah = to_mah(wr->ah);
 	u16 pkey;
 	u32 qkey;
@@ -2428,7 +2430,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 	struct ib_device *ib_dev = sqp->qp.ibqp.device;
 	struct mlx4_wqe_mlx_seg *mlx = wqe;
 	struct mlx4_wqe_ctrl_seg *ctrl = wqe;
-	struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
+	struct mlx4_wqe_inline_seg *inl = wqe + sizeof(*mlx);
 	struct mlx4_ib_ah *ah = to_mah(wr->ah);
 	union ib_gid sgid;
 	u16 pkey;
@@ -2809,7 +2811,7 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 	int spc;
 	int i;
 
-	memcpy(&hdr.av, &ah->av, sizeof hdr.av);
+	memcpy(&hdr.av, &ah->av, sizeof(hdr.av));
 	hdr.remote_qpn = cpu_to_be32(wr->remote_qpn);
 	hdr.pkey_index = cpu_to_be16(wr->pkey_index);
 	hdr.qkey = cpu_to_be32(wr->remote_qkey);
@@ -2888,7 +2890,7 @@ static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_ud_wr *wr,
 			 struct mlx4_ib_qp *qp, unsigned *lso_seg_len,
 			 __be32 *lso_hdr_sz, __be32 *blh)
 {
-	unsigned halign = ALIGN(sizeof *wqe + wr->hlen, 16);
+	unsigned int halign = ALIGN(sizeof(*wqe) + wr->hlen, 16);
 
 	if (unlikely(halign > MLX4_IB_CACHE_LINE_SIZE))
 		*blh = cpu_to_be32(1 << 6);
@@ -3010,9 +3012,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			qp->sq_signal_bits;
 
 		ctrl->imm = send_ieth(wr);
-
-		wqe += sizeof *ctrl;
-		size = sizeof *ctrl / 16;
+		wqe += sizeof(*ctrl);
+		size = sizeof(*ctrl) / 16;
 
 		switch (qp->mlx4_ib_qp_type) {
 		case MLX4_IB_QPT_RC:
@@ -3390,7 +3391,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
 	struct mlx4_dev *dev = ibdev->dev;
 	int is_eth;
 
-	memset(ib_ah_attr, 0, sizeof *ib_ah_attr);
+	memset(ib_ah_attr, 0, sizeof(*ib_ah_attr));
 	ib_ah_attr->port_num	  = path->sched_queue & 0x40 ? 2 : 1;
 
 	if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
@@ -3416,7 +3417,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
 		ib_ah_attr->grh.flow_label =
 			be32_to_cpu(path->tclass_flowlabel) & 0xfffff;
 		memcpy(ib_ah_attr->grh.dgid.raw,
-			path->rgid, sizeof ib_ah_attr->grh.dgid.raw);
+			path->rgid, sizeof(ib_ah_attr->grh.dgid.raw));
 	}
 }
 
-- 
2.11.1

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

* [PATCH 26/29] IB/mlx4: Enclose 14 expressions for the sizeof operator by parentheses
@ 2017-02-18 21:16   ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:16 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 19:30:41 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

WARNING: sizeof … should be sizeof(…)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/qp.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 16164ff09a86..3ffba8ebba7f 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -247,9 +247,10 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size)
 	s = sizeof(struct mlx4_wqe_ctrl_seg);
 
 	if (qp->ibqp.qp_type = IB_QPT_UD) {
-		struct mlx4_wqe_datagram_seg *dgram = wqe + sizeof *ctrl;
+		struct mlx4_wqe_datagram_seg *dgram = wqe + sizeof(*ctrl);
 		struct mlx4_av *av = (struct mlx4_av *)dgram->av;
-		memset(dgram, 0, sizeof *dgram);
+
+		memset(dgram, 0, sizeof(*dgram));
 		av->port_pd = cpu_to_be32((qp->port << 24) | to_mpd(qp->ibqp.pd)->pdn);
 		s += sizeof(struct mlx4_wqe_datagram_seg);
 	}
@@ -257,7 +258,8 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size)
 	/* Pad the remainder of the WQE with an inline data segment. */
 	if (size > s) {
 		inl = wqe + s;
-		inl->byte_count = cpu_to_be32(1 << 31 | (size - s - sizeof *inl));
+		inl->byte_count = cpu_to_be32(1 << 31
+					      | (size - s - sizeof(*inl)));
 	}
 	ctrl->srcrb_flags = 0;
 	ctrl->qpn_vlan.fence_size = size / 16;
@@ -727,7 +729,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
 	if (pd->uobject) {
 		struct mlx4_ib_create_qp ucmd;
 
-		if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+		if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
 			err = -EFAULT;
 			goto err;
 		}
@@ -1180,7 +1182,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd,
 	case IB_QPT_RC:
 	case IB_QPT_UC:
 	case IB_QPT_RAW_PACKET:
-		qp = kzalloc(sizeof *qp, gfp);
+		qp = kzalloc(sizeof(*qp), gfp);
 		if (!qp)
 			return ERR_PTR(-ENOMEM);
 		qp->pri.vid = 0xFFFF;
@@ -1635,7 +1637,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 	    IB_LINK_LAYER_ETHERNET)
 		return -ENOTSUPP;
 
-	context = kzalloc(sizeof *context, GFP_KERNEL);
+	context = kzalloc(sizeof(*context), GFP_KERNEL);
 	if (!context)
 		return -ENOMEM;
 
@@ -2299,7 +2301,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	struct mlx4_ib_dev *mdev = to_mdev(sqp->qp.ibqp.device);
 	struct ib_device *ib_dev = &mdev->ib_dev;
 	struct mlx4_wqe_mlx_seg *mlx = wqe;
-	struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
+	struct mlx4_wqe_inline_seg *inl = wqe + sizeof(*mlx);
 	struct mlx4_ib_ah *ah = to_mah(wr->ah);
 	u16 pkey;
 	u32 qkey;
@@ -2428,7 +2430,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 	struct ib_device *ib_dev = sqp->qp.ibqp.device;
 	struct mlx4_wqe_mlx_seg *mlx = wqe;
 	struct mlx4_wqe_ctrl_seg *ctrl = wqe;
-	struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
+	struct mlx4_wqe_inline_seg *inl = wqe + sizeof(*mlx);
 	struct mlx4_ib_ah *ah = to_mah(wr->ah);
 	union ib_gid sgid;
 	u16 pkey;
@@ -2809,7 +2811,7 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 	int spc;
 	int i;
 
-	memcpy(&hdr.av, &ah->av, sizeof hdr.av);
+	memcpy(&hdr.av, &ah->av, sizeof(hdr.av));
 	hdr.remote_qpn = cpu_to_be32(wr->remote_qpn);
 	hdr.pkey_index = cpu_to_be16(wr->pkey_index);
 	hdr.qkey = cpu_to_be32(wr->remote_qkey);
@@ -2888,7 +2890,7 @@ static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_ud_wr *wr,
 			 struct mlx4_ib_qp *qp, unsigned *lso_seg_len,
 			 __be32 *lso_hdr_sz, __be32 *blh)
 {
-	unsigned halign = ALIGN(sizeof *wqe + wr->hlen, 16);
+	unsigned int halign = ALIGN(sizeof(*wqe) + wr->hlen, 16);
 
 	if (unlikely(halign > MLX4_IB_CACHE_LINE_SIZE))
 		*blh = cpu_to_be32(1 << 6);
@@ -3010,9 +3012,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			qp->sq_signal_bits;
 
 		ctrl->imm = send_ieth(wr);
-
-		wqe += sizeof *ctrl;
-		size = sizeof *ctrl / 16;
+		wqe += sizeof(*ctrl);
+		size = sizeof(*ctrl) / 16;
 
 		switch (qp->mlx4_ib_qp_type) {
 		case MLX4_IB_QPT_RC:
@@ -3390,7 +3391,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
 	struct mlx4_dev *dev = ibdev->dev;
 	int is_eth;
 
-	memset(ib_ah_attr, 0, sizeof *ib_ah_attr);
+	memset(ib_ah_attr, 0, sizeof(*ib_ah_attr));
 	ib_ah_attr->port_num	  = path->sched_queue & 0x40 ? 2 : 1;
 
 	if (ib_ah_attr->port_num = 0 || ib_ah_attr->port_num > dev->caps.num_ports)
@@ -3416,7 +3417,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
 		ib_ah_attr->grh.flow_label  			be32_to_cpu(path->tclass_flowlabel) & 0xfffff;
 		memcpy(ib_ah_attr->grh.dgid.raw,
-			path->rgid, sizeof ib_ah_attr->grh.dgid.raw);
+			path->rgid, sizeof(ib_ah_attr->grh.dgid.raw));
 	}
 }
 
-- 
2.11.1


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

* [PATCH 27/29] IB/mlx5: Use kmalloc_array() in create_kernel_qp()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:17     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:17 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 20:12:44 +0100

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

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

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 5ed5208d0ddd..e6e9b468b206 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -955,12 +955,21 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 		goto err_free;
 	}
 
-	qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL);
-	qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL);
-	qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL);
-	qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL);
-	qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL);
-
+	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
+				    sizeof(*qp->sq.wrid),
+				    GFP_KERNEL);
+	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
+				       sizeof(*qp->sq.wr_data),
+				       GFP_KERNEL);
+	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
+				    sizeof(*qp->rq.wrid),
+				    GFP_KERNEL);
+	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
+				      sizeof(*qp->sq.w_list),
+				      GFP_KERNEL);
+	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
+					sizeof(*qp->sq.wqe_head),
+					GFP_KERNEL);
 	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
 	    !qp->sq.w_list || !qp->sq.wqe_head) {
 		err = -ENOMEM;
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 27/29] IB/mlx5: Use kmalloc_array() in create_kernel_qp()
@ 2017-02-18 21:17     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:17 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 20:12:44 +0100

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx5/qp.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 5ed5208d0ddd..e6e9b468b206 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -955,12 +955,21 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 		goto err_free;
 	}
 
-	qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL);
-	qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL);
-	qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL);
-	qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL);
-	qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL);
-
+	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
+				    sizeof(*qp->sq.wrid),
+				    GFP_KERNEL);
+	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
+				       sizeof(*qp->sq.wr_data),
+				       GFP_KERNEL);
+	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
+				    sizeof(*qp->rq.wrid),
+				    GFP_KERNEL);
+	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
+				      sizeof(*qp->sq.w_list),
+				      GFP_KERNEL);
+	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
+					sizeof(*qp->sq.wqe_head),
+					GFP_KERNEL);
 	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
 	    !qp->sq.w_list || !qp->sq.wqe_head) {
 		err = -ENOMEM;
-- 
2.11.1

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

* [PATCH 27/29] IB/mlx5: Use kmalloc_array() in create_kernel_qp()
@ 2017-02-18 21:17     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:17 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 20:12:44 +0100

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx5/qp.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 5ed5208d0ddd..e6e9b468b206 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -955,12 +955,21 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 		goto err_free;
 	}
 
-	qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL);
-	qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL);
-	qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL);
-	qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL);
-	qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL);
-
+	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
+				    sizeof(*qp->sq.wrid),
+				    GFP_KERNEL);
+	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
+				       sizeof(*qp->sq.wr_data),
+				       GFP_KERNEL);
+	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
+				    sizeof(*qp->rq.wrid),
+				    GFP_KERNEL);
+	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
+				      sizeof(*qp->sq.w_list),
+				      GFP_KERNEL);
+	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
+					sizeof(*qp->sq.wqe_head),
+					GFP_KERNEL);
 	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
 	    !qp->sq.w_list || !qp->sq.wqe_head) {
 		err = -ENOMEM;
-- 
2.11.1


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

* [PATCH 28/29] IB/mlx5: Less function calls in create_kernel_qp() after error detection
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:18     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:18 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 21:00:50 +0100

The kfree() function was called in up to five cases
by the create_kernel_qp() function during error handling
even if the passed data structure member contained a null pointer.

* Adjust jump targets according to the Linux coding style convention.

* Split a condition check for memory allocation failures so that
  each pointer from these function calls will be checked immediately.

  See also background information:
  Topic "CWE-754: Improper check for unusual or exceptional conditions"
  Link: https://cwe.mitre.org/data/definitions/754.html

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/hw/mlx5/qp.c | 43 ++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index e6e9b468b206..c47afce5fc6a 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -930,7 +930,7 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 	*in = mlx5_vzalloc(*inlen);
 	if (!*in) {
 		err = -ENOMEM;
-		goto err_buf;
+		goto free_buffer;
 	}
 
 	qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
@@ -952,45 +952,56 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 	err = mlx5_db_alloc(dev->mdev, &qp->db);
 	if (err) {
 		mlx5_ib_dbg(dev, "err %d\n", err);
-		goto err_free;
+		goto vfree_in;
 	}
 
 	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
 				    sizeof(*qp->sq.wrid),
 				    GFP_KERNEL);
+	if (!qp->sq.wrid)
+		goto free_db;
+
 	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
 				       sizeof(*qp->sq.wr_data),
 				       GFP_KERNEL);
+	if (!qp->sq.wr_data)
+		goto free_sq_wrid;
+
 	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
 				    sizeof(*qp->rq.wrid),
 				    GFP_KERNEL);
+	if (!qp->rq.wrid)
+		goto free_sq_wr_data;
+
 	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
 				      sizeof(*qp->sq.w_list),
 				      GFP_KERNEL);
+	if (!qp->sq.w_list)
+		goto free_rq_wrid;
+
 	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
 					sizeof(*qp->sq.wqe_head),
 					GFP_KERNEL);
-	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
-	    !qp->sq.w_list || !qp->sq.wqe_head) {
-		err = -ENOMEM;
-		goto err_wrid;
-	}
+	if (!qp->sq.wqe_head)
+		goto free_sq_w_list;
+
 	qp->create_type = MLX5_QP_KERNEL;
 
 	return 0;
-
-err_wrid:
-	kfree(qp->sq.wqe_head);
+free_sq_w_list:
 	kfree(qp->sq.w_list);
-	kfree(qp->sq.wrid);
-	kfree(qp->sq.wr_data);
+free_rq_wrid:
 	kfree(qp->rq.wrid);
+free_sq_wr_data:
+	kfree(qp->sq.wr_data);
+free_sq_wrid:
+	kfree(qp->sq.wrid);
+free_db:
 	mlx5_db_free(dev->mdev, &qp->db);
-
-err_free:
+	err = -ENOMEM;
+vfree_in:
 	kvfree(*in);
-
-err_buf:
+free_buffer:
 	mlx5_buf_free(dev->mdev, &qp->buf);
 	return err;
 }
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 28/29] IB/mlx5: Less function calls in create_kernel_qp() after error detection
@ 2017-02-18 21:18     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:18 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 21:00:50 +0100

The kfree() function was called in up to five cases
by the create_kernel_qp() function during error handling
even if the passed data structure member contained a null pointer.

* Adjust jump targets according to the Linux coding style convention.

* Split a condition check for memory allocation failures so that
  each pointer from these function calls will be checked immediately.

  See also background information:
  Topic "CWE-754: Improper check for unusual or exceptional conditions"
  Link: https://cwe.mitre.org/data/definitions/754.html

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx5/qp.c | 43 ++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index e6e9b468b206..c47afce5fc6a 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -930,7 +930,7 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 	*in = mlx5_vzalloc(*inlen);
 	if (!*in) {
 		err = -ENOMEM;
-		goto err_buf;
+		goto free_buffer;
 	}
 
 	qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
@@ -952,45 +952,56 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 	err = mlx5_db_alloc(dev->mdev, &qp->db);
 	if (err) {
 		mlx5_ib_dbg(dev, "err %d\n", err);
-		goto err_free;
+		goto vfree_in;
 	}
 
 	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
 				    sizeof(*qp->sq.wrid),
 				    GFP_KERNEL);
+	if (!qp->sq.wrid)
+		goto free_db;
+
 	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
 				       sizeof(*qp->sq.wr_data),
 				       GFP_KERNEL);
+	if (!qp->sq.wr_data)
+		goto free_sq_wrid;
+
 	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
 				    sizeof(*qp->rq.wrid),
 				    GFP_KERNEL);
+	if (!qp->rq.wrid)
+		goto free_sq_wr_data;
+
 	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
 				      sizeof(*qp->sq.w_list),
 				      GFP_KERNEL);
+	if (!qp->sq.w_list)
+		goto free_rq_wrid;
+
 	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
 					sizeof(*qp->sq.wqe_head),
 					GFP_KERNEL);
-	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
-	    !qp->sq.w_list || !qp->sq.wqe_head) {
-		err = -ENOMEM;
-		goto err_wrid;
-	}
+	if (!qp->sq.wqe_head)
+		goto free_sq_w_list;
+
 	qp->create_type = MLX5_QP_KERNEL;
 
 	return 0;
-
-err_wrid:
-	kfree(qp->sq.wqe_head);
+free_sq_w_list:
 	kfree(qp->sq.w_list);
-	kfree(qp->sq.wrid);
-	kfree(qp->sq.wr_data);
+free_rq_wrid:
 	kfree(qp->rq.wrid);
+free_sq_wr_data:
+	kfree(qp->sq.wr_data);
+free_sq_wrid:
+	kfree(qp->sq.wrid);
+free_db:
 	mlx5_db_free(dev->mdev, &qp->db);
-
-err_free:
+	err = -ENOMEM;
+vfree_in:
 	kvfree(*in);
-
-err_buf:
+free_buffer:
 	mlx5_buf_free(dev->mdev, &qp->buf);
 	return err;
 }
-- 
2.11.1

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

* [PATCH 28/29] IB/mlx5: Less function calls in create_kernel_qp() after error detection
@ 2017-02-18 21:18     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:18 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 21:00:50 +0100

The kfree() function was called in up to five cases
by the create_kernel_qp() function during error handling
even if the passed data structure member contained a null pointer.

* Adjust jump targets according to the Linux coding style convention.

* Split a condition check for memory allocation failures so that
  each pointer from these function calls will be checked immediately.

  See also background information:
  Topic "CWE-754: Improper check for unusual or exceptional conditions"
  Link: https://cwe.mitre.org/data/definitions/754.html

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx5/qp.c | 43 ++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index e6e9b468b206..c47afce5fc6a 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -930,7 +930,7 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 	*in = mlx5_vzalloc(*inlen);
 	if (!*in) {
 		err = -ENOMEM;
-		goto err_buf;
+		goto free_buffer;
 	}
 
 	qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
@@ -952,45 +952,56 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 	err = mlx5_db_alloc(dev->mdev, &qp->db);
 	if (err) {
 		mlx5_ib_dbg(dev, "err %d\n", err);
-		goto err_free;
+		goto vfree_in;
 	}
 
 	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
 				    sizeof(*qp->sq.wrid),
 				    GFP_KERNEL);
+	if (!qp->sq.wrid)
+		goto free_db;
+
 	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
 				       sizeof(*qp->sq.wr_data),
 				       GFP_KERNEL);
+	if (!qp->sq.wr_data)
+		goto free_sq_wrid;
+
 	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
 				    sizeof(*qp->rq.wrid),
 				    GFP_KERNEL);
+	if (!qp->rq.wrid)
+		goto free_sq_wr_data;
+
 	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
 				      sizeof(*qp->sq.w_list),
 				      GFP_KERNEL);
+	if (!qp->sq.w_list)
+		goto free_rq_wrid;
+
 	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
 					sizeof(*qp->sq.wqe_head),
 					GFP_KERNEL);
-	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
-	    !qp->sq.w_list || !qp->sq.wqe_head) {
-		err = -ENOMEM;
-		goto err_wrid;
-	}
+	if (!qp->sq.wqe_head)
+		goto free_sq_w_list;
+
 	qp->create_type = MLX5_QP_KERNEL;
 
 	return 0;
-
-err_wrid:
-	kfree(qp->sq.wqe_head);
+free_sq_w_list:
 	kfree(qp->sq.w_list);
-	kfree(qp->sq.wrid);
-	kfree(qp->sq.wr_data);
+free_rq_wrid:
 	kfree(qp->rq.wrid);
+free_sq_wr_data:
+	kfree(qp->sq.wr_data);
+free_sq_wrid:
+	kfree(qp->sq.wrid);
+free_db:
 	mlx5_db_free(dev->mdev, &qp->db);
-
-err_free:
+	err = -ENOMEM;
+vfree_in:
 	kvfree(*in);
-
-err_buf:
+free_buffer:
 	mlx5_buf_free(dev->mdev, &qp->buf);
 	return err;
 }
-- 
2.11.1


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

* [PATCH 29/29] IB/mlx5: Use kmalloc_array() in create_srq_kernel()
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-02-18 21:19     ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:19 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sat, 18 Feb 2017 21:18:15 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
index 7cb145f9a6db..8ba1953177af 100644
--- a/drivers/infiniband/hw/mlx5/srq.c
+++ b/drivers/infiniband/hw/mlx5/srq.c
@@ -195,8 +195,9 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 		goto err_buf;
 	}
 	mlx5_fill_page_array(&srq->buf, in->pas);
-
-	srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL);
+	srq->wrid = kmalloc_array(srq->msrq.max,
+				  sizeof(*srq->wrid),
+				  GFP_KERNEL);
 	if (!srq->wrid) {
 		err = -ENOMEM;
 		goto err_in;
-- 
2.11.1

--
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] 179+ messages in thread

* [PATCH 29/29] IB/mlx5: Use kmalloc_array() in create_srq_kernel()
@ 2017-02-18 21:19     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:19 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 21:18:15 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
index 7cb145f9a6db..8ba1953177af 100644
--- a/drivers/infiniband/hw/mlx5/srq.c
+++ b/drivers/infiniband/hw/mlx5/srq.c
@@ -195,8 +195,9 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 		goto err_buf;
 	}
 	mlx5_fill_page_array(&srq->buf, in->pas);
-
-	srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL);
+	srq->wrid = kmalloc_array(srq->msrq.max,
+				  sizeof(*srq->wrid),
+				  GFP_KERNEL);
 	if (!srq->wrid) {
 		err = -ENOMEM;
 		goto err_in;
-- 
2.11.1

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

* [PATCH 29/29] IB/mlx5: Use kmalloc_array() in create_srq_kernel()
@ 2017-02-18 21:19     ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-02-18 21:19 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Feb 2017 21:18:15 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
index 7cb145f9a6db..8ba1953177af 100644
--- a/drivers/infiniband/hw/mlx5/srq.c
+++ b/drivers/infiniband/hw/mlx5/srq.c
@@ -195,8 +195,9 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 		goto err_buf;
 	}
 	mlx5_fill_page_array(&srq->buf, in->pas);
-
-	srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL);
+	srq->wrid = kmalloc_array(srq->msrq.max,
+				  sizeof(*srq->wrid),
+				  GFP_KERNEL);
 	if (!srq->wrid) {
 		err = -ENOMEM;
 		goto err_in;
-- 
2.11.1


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

* Re: [PATCH 02/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_pv_bufs()
  2017-02-18 20:49     ` SF Markus Elfring
  (?)
@ 2017-02-19 17:06         ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 10:49 PM, SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5ug@public.gmane.orge.net> wrote:
> 
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Fri, 17 Feb 2017 20:05:38 +0100
> 
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 61bd81baeb29..858da8746d49 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1607,7 +1607,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
>        return -ENOMEM;
> 
>    tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
> -                  sizeof (struct mlx4_ib_tun_tx_buf),
> +                  sizeof(*tun_qp->tx_ring),
>                  GFP_KERNEL);
>    if (!tun_qp->tx_ring) {
>        kfree(tun_qp->ring);
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>--
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] 179+ messages in thread

* Re: [PATCH 02/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_pv_bufs()
@ 2017-02-19 17:06         ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 10:49 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 20:05:38 +0100
> 
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 61bd81baeb29..858da8746d49 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1607,7 +1607,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
>        return -ENOMEM;
> 
>    tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
> -                  sizeof (struct mlx4_ib_tun_tx_buf),
> +                  sizeof(*tun_qp->tx_ring),
>                  GFP_KERNEL);
>    if (!tun_qp->tx_ring) {
>        kfree(tun_qp->ring);
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 02/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_pv_bufs()
@ 2017-02-19 17:06         ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 10:49 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 20:05:38 +0100
> 
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 61bd81baeb29..858da8746d49 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1607,7 +1607,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
>        return -ENOMEM;
> 
>    tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
> -                  sizeof (struct mlx4_ib_tun_tx_buf),
> +                  sizeof(*tun_qp->tx_ring),
>                  GFP_KERNEL);
>    if (!tun_qp->tx_ring) {
>        kfree(tun_qp->ring);
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 04/29] IB/mlx4: Improve another size determination in alloc_pv_object()
  2017-02-18 20:51   ` SF Markus Elfring
  (?)
@ 2017-02-19 17:06   ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 10:52 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 20:20:43 +0100
> 
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 284634d36b1c..ea4892b0f39e 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1948,7 +1948,7 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
>    struct mlx4_ib_demux_pv_ctx *ctx;
> 
>    *ret_ctx = NULL;
> -    ctx = kzalloc(sizeof (struct mlx4_ib_demux_pv_ctx), GFP_KERNEL);
> +    ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
>    if (!ctx)
>        return -ENOMEM;
> 
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 03/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_demux_ctx()
  2017-02-18 20:50     ` SF Markus Elfring
  (?)
  (?)
@ 2017-02-19 17:06     ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 10:50 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 20:15:02 +0100
> 
> Replace the specification of a data type by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 858da8746d49..284634d36b1c 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -2150,7 +2150,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
>    int i;
> 
>    ctx->tun = kcalloc(dev->dev->caps.sqp_demux,
> -               sizeof (struct mlx4_ib_demux_pv_ctx *), GFP_KERNEL);
> +               sizeof(*ctx->tun), GFP_KERNEL);
>    if (!ctx->tun)
>        return -ENOMEM;
> 
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 05/29] IB/mlx4: Fix a typo in a comment line
  2017-02-18 20:52   ` SF Markus Elfring
  (?)
@ 2017-02-19 17:06   ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 10:53 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 20:48:59 +0100
> 
> Add a missing character in this description and adjust
> the comment formatting.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index ea4892b0f39e..d8c27e3ed69a 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1559,8 +1559,10 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
>        }
>    }
> 
> -    /* We are using standard ib_core services to send the mad, so generate a
> -     * stadard address handle by decoding the tunnelled mlx4_ah fields */
> +    /*
> +     * We are using standard ib_core services to send the mad, so generate
> +     * a standard address handle by decoding the tunnelled mlx4_ah fields.
> +     */
>    memcpy(&ah.av, &tunnel->hdr.av, sizeof (struct mlx4_av));
>    ah.ibah.device = ctx->ib_dev;
> 
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 06/29] IB/mlx4: Delete three unnecessary return statements
  2017-02-18 20:54     ` SF Markus Elfring
  (?)
  (?)
@ 2017-02-19 17:06     ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 10:54 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 21:34:27 +0100
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> WARNING: void function return statements are not generally useful
> 
> Thus remove such a statement in the affected functions.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 3 ---
> 1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index d8c27e3ed69a..cf33efce69d2 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1173,7 +1173,6 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
> out:
>    kfree(in_mad);
>    kfree(out_mad);
> -    return;
> }
> 
> void handle_port_mgmt_change_event(struct work_struct *work)
> @@ -2140,7 +2139,6 @@ void mlx4_ib_tunnels_update_work(struct work_struct *work)
>    mlx4_ib_tunnels_update(dmxw->dev, dmxw->slave, (int) dmxw->port,
>                   dmxw->do_init);
>    kfree(dmxw);
> -    return;
> }
> 
> static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
> @@ -2268,7 +2266,6 @@ static void mlx4_ib_master_tunnels(struct mlx4_ib_dev *dev, int do_init)
>    /* initialize or tear down tunnel QPs for the master */
>    for (i = 0; i < dev->dev->caps.num_ports; i++)
>        mlx4_ib_tunnels_update(dev, mlx4_master_func_num(dev->dev), i + 1, do_init);
> -    return;
> }
> 
> int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev)
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 01/29] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs()
  2017-02-18 20:47     ` SF Markus Elfring
  (?)
  (?)
@ 2017-02-19 17:06     ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 10:55 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 20:00:34 +0100
> 
> * A multiplication for the size determination of a memory allocation
>  indicated that an array data structure should be processed.
>  Thus use the corresponding function "kcalloc".
> 
>  This issue was detected by using the Coccinelle software.
> 
> * Replace the specification of a data structure by a pointer dereference
>  to make the corresponding size determination a bit safer according to
>  the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index db564ccc0f92..61bd81baeb29 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1600,8 +1600,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
>        return -EINVAL;
> 
>    tun_qp = &ctx->qp[qp_type];
> -
> -    tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS,
> +    tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
> +                   sizeof(*tun_qp->ring),
>                   GFP_KERNEL);
>    if (!tun_qp->ring)
>        return -ENOMEM;
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com> 

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

* Re: [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change()
  2017-02-18 20:55     ` SF Markus Elfring
  (?)
@ 2017-02-19 17:09         ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 10:55 PM, SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5ug@public.gmane.orge.net> wrote:
> 
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Fri, 17 Feb 2017 21:41:25 +0100
> 
> The kfree() function was called in up to two cases by the
> handle_slaves_guid_change() function during error handling even if
> the passed variable contained a null pointer.
> 
> * Split a condition check for memory allocation failures.
> 
> * Adjust jump targets according to the Linux coding style convention.
> 
> * Delete an initialisation for these variables at the beginning
>  which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index cf33efce69d2..75b6522b3a8f 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1128,17 +1128,20 @@ static void propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
> static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
>                      u32 guid_tbl_blk_num, u32 change_bitmap)
> {
> -    struct ib_smp *in_mad  = NULL;
> -    struct ib_smp *out_mad  = NULL;
> +    struct ib_smp *in_mad;
> +    struct ib_smp *out_mad;
>    u16 i;
> 
>    if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
>        return;
> 
>    in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
> +    if (!in_mad)
> +        return;
> +
>    out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> -    if (!in_mad || !out_mad)
> -        goto out;
> +    if (!out_mad)
> +        goto free_in_mad;
> 
>    guid_tbl_blk_num  *= 4;
> 
> @@ -1171,8 +1174,9 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
>    }
> 
> out:
> -    kfree(in_mad);
>    kfree(out_mad);
> +free_in_mad:
> +    kfree(in_mad);
> }
> 
> void handle_port_mgmt_change_event(struct work_struct *work)
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>--
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] 179+ messages in thread

* Re: [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change()
@ 2017-02-19 17:09         ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 10:55 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 21:41:25 +0100
> 
> The kfree() function was called in up to two cases by the
> handle_slaves_guid_change() function during error handling even if
> the passed variable contained a null pointer.
> 
> * Split a condition check for memory allocation failures.
> 
> * Adjust jump targets according to the Linux coding style convention.
> 
> * Delete an initialisation for these variables at the beginning
>  which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index cf33efce69d2..75b6522b3a8f 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1128,17 +1128,20 @@ static void propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
> static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
>                      u32 guid_tbl_blk_num, u32 change_bitmap)
> {
> -    struct ib_smp *in_mad  = NULL;
> -    struct ib_smp *out_mad  = NULL;
> +    struct ib_smp *in_mad;
> +    struct ib_smp *out_mad;
>    u16 i;
> 
>    if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
>        return;
> 
>    in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
> +    if (!in_mad)
> +        return;
> +
>    out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> -    if (!in_mad || !out_mad)
> -        goto out;
> +    if (!out_mad)
> +        goto free_in_mad;
> 
>    guid_tbl_blk_num  *= 4;
> 
> @@ -1171,8 +1174,9 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
>    }
> 
> out:
> -    kfree(in_mad);
>    kfree(out_mad);
> +free_in_mad:
> +    kfree(in_mad);
> }
> 
> void handle_port_mgmt_change_event(struct work_struct *work)
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change()
@ 2017-02-19 17:09         ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 10:55 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 21:41:25 +0100
> 
> The kfree() function was called in up to two cases by the
> handle_slaves_guid_change() function during error handling even if
> the passed variable contained a null pointer.
> 
> * Split a condition check for memory allocation failures.
> 
> * Adjust jump targets according to the Linux coding style convention.
> 
> * Delete an initialisation for these variables at the beginning
>  which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index cf33efce69d2..75b6522b3a8f 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1128,17 +1128,20 @@ static void propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
> static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
>                      u32 guid_tbl_blk_num, u32 change_bitmap)
> {
> -    struct ib_smp *in_mad  = NULL;
> -    struct ib_smp *out_mad  = NULL;
> +    struct ib_smp *in_mad;
> +    struct ib_smp *out_mad;
>    u16 i;
> 
>    if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
>        return;
> 
>    in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
> +    if (!in_mad)
> +        return;
> +
>    out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> -    if (!in_mad || !out_mad)
> -        goto out;
> +    if (!out_mad)
> +        goto free_in_mad;
> 
>    guid_tbl_blk_num  *= 4;
> 
> @@ -1171,8 +1174,9 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
>    }
> 
> out:
> -    kfree(in_mad);
>    kfree(out_mad);
> +free_in_mad:
> +    kfree(in_mad);
> }
> 
> void handle_port_mgmt_change_event(struct work_struct *work)
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object()
  2017-02-18 20:56     ` [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object() SF Markus Elfring
@ 2017-02-19 17:11       ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:11 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:28 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 22:06:24 +0100
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> WARNING: kfree(NULL) is safe and this check is probably not required
> 
> Thus fix the affected source code place.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 75b6522b3a8f..9518b7244269 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1966,10 +1966,8 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
> 
> static void free_pv_object(struct mlx4_ib_dev *dev, int slave, int port)
> {
> -    if (dev->sriov.demux[port - 1].tun[slave]) {
> -        kfree(dev->sriov.demux[port - 1].tun[slave]);
> -        dev->sriov.demux[port - 1].tun[slave] = NULL;
> -    }
> +    kfree(dev->sriov.demux[port - 1].tun[slave]);
> +    dev->sriov.demux[port - 1].tun[slave] = NULL;
> }
In case it was NULL, we will have a redundant assignment here.
I don't think this change is needed..
> 
> static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
> -- 
> 2.11.1
> 
> --
> 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] 179+ messages in thread

* Re: [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_o
@ 2017-02-19 17:11       ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:11 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:28 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 22:06:24 +0100
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> WARNING: kfree(NULL) is safe and this check is probably not required
> 
> Thus fix the affected source code place.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 75b6522b3a8f..9518b7244269 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1966,10 +1966,8 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
> 
> static void free_pv_object(struct mlx4_ib_dev *dev, int slave, int port)
> {
> -    if (dev->sriov.demux[port - 1].tun[slave]) {
> -        kfree(dev->sriov.demux[port - 1].tun[slave]);
> -        dev->sriov.demux[port - 1].tun[slave] = NULL;
> -    }
> +    kfree(dev->sriov.demux[port - 1].tun[slave]);
> +    dev->sriov.demux[port - 1].tun[slave] = NULL;
> }
In case it was NULL, we will have a redundant assignment here.
I don't think this change is needed..
> 
> static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
> -- 
> 2.11.1
> 
> --
> 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] 179+ messages in thread

* Re: [PATCH 09/29] IB/mlx4: Move an assignment out of a check in forward_trap()
  2017-02-18 20:57     ` SF Markus Elfring
  (?)
  (?)
@ 2017-02-19 17:12     ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:12 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 10:58 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 17 Feb 2017 22:22:53 +0100
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> ERROR: do not use assignment in if condition
> 
> Thus fix the affected source code place.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 9518b7244269..860fec8b9601 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -401,7 +401,8 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
>         */
>        spin_lock_irqsave(&dev->sm_lock, flags);
>        memcpy(send_buf->mad, mad, sizeof *mad);
> -        if ((send_buf->ah = dev->sm_ah[port_num - 1]))
> +        send_buf->ah = dev->sm_ah[port_num - 1];
> +        if (send_buf->ah)
>            ret = ib_post_send_mad(send_buf, NULL);
>        else
>            ret = -EINVAL;
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses
  2017-02-18 21:00   ` SF Markus Elfring
@ 2017-02-19 17:21     ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:21 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:02 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 11:28:41 +0100
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> WARNING: sizeof … should be sizeof(…)
> 
> Thus fix the affected source code places.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 35 +++++++++++++++++------------------
> 1 file changed, 17 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 350c9148340e..b3b5ded85166 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -457,8 +457,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
> 
>    resp.response_length = offsetof(typeof(resp), response_length) +
>        sizeof(resp.response_length);
> -    in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
> -    out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> +    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> +    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
>    err = -ENOMEM;
>    if (!in_mad || !out_mad)
>        goto out;
> @@ -471,8 +471,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
>    if (err)
>        goto out;
> 
> -    memset(props, 0, sizeof *props);
> -
> +    memset(props, 0, sizeof(*props));
>    have_ib_ports = num_ib_ports(dev->dev);
> 
>    props->fw_ver = dev->dev->caps.fw_ver;
> @@ -595,8 +594,8 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
>    int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
>    int err = -ENOMEM;
> 
> -    in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
> -    out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> +    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> +    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
>    if (!in_mad || !out_mad)
>        goto out;
> 
> @@ -771,8 +770,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
>    int clear = 0;
>    int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> 
> -    in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
> -    out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> +    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> +    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
>    if (!in_mad || !out_mad)
>        goto out;
> 
> @@ -908,8 +907,8 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
>    int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
>    int err = -ENOMEM;
> 
> -    in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
> -    out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> +    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> +    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
>    if (!in_mad || !out_mad)
>        goto out;
> 
> @@ -1280,7 +1279,7 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
>    struct mlx4_ib_pd *pd;
>    int err;
> 
> -    pd = kmalloc(sizeof *pd, GFP_KERNEL);
> +    pd = kmalloc(sizeof(*pd), GFP_KERNEL);
>    if (!pd)
>        return ERR_PTR(-ENOMEM);
> 
> @@ -1319,7 +1318,7 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev,
>    if (!(to_mdev(ibdev)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
>        return ERR_PTR(-ENOSYS);
> 
> -    xrcd = kmalloc(sizeof *xrcd, GFP_KERNEL);
> +    xrcd = kmalloc(sizeof(*xrcd), GFP_KERNEL);
>    if (!xrcd)
>        return ERR_PTR(-ENOMEM);
> 
> @@ -1367,7 +1366,7 @@ static int add_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
>    struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
>    struct mlx4_ib_gid_entry *ge;
> 
> -    ge = kzalloc(sizeof *ge, GFP_KERNEL);
> +    ge = kzalloc(sizeof(*ge), GFP_KERNEL);
>    if (!ge)
>        return -ENOMEM;
> 
> @@ -2089,8 +2088,8 @@ static int init_node_data(struct mlx4_ib_dev *dev)
>    int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
>    int err = -ENOMEM;
> 
> -    in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
> -    out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> +    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> +    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
>    if (!in_mad || !out_mad)
>        goto out;
> 
> @@ -2600,7 +2599,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>    if (num_ports == 0)
>        return NULL;
> 
> -    ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
> +    ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
>    if (!ibdev) {
>        dev_err(&dev->persist->pdev->dev,
>            "Device struct alloc failed\n");
> @@ -3301,12 +3300,12 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
>        break;
> 
>    case MLX4_DEV_EVENT_PORT_MGMT_CHANGE:
> -        ew = kmalloc(sizeof *ew, GFP_ATOMIC);
> +        ew = kmalloc(sizeof(*ew), GFP_ATOMIC);
>        if (!ew)
>            break;
> 
>        INIT_WORK(&ew->work, handle_port_mgmt_change_event);
> -        memcpy(&ew->ib_eqe, eqe, sizeof *eqe);
> +        memcpy(&ew->ib_eqe, eqe, sizeof(*eqe));
>        ew->ib_dev = ibdev;
>        /* need to queue only for port owner, which uses GEN_EQE */
>        if (mlx4_is_master(dev))
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 13/29] IB/mlx4: Split a condition check in five functions
  2017-02-18 21:01     ` SF Markus Elfring
  (?)
  (?)
@ 2017-02-19 17:21     ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:21 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:08 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 14:43:34 +0100
> 
> The kfree() function was called in up to two cases during error handling
> even if the passed variable contained a null pointer.
> 
> * Split a condition check for memory allocation failures.
> 
> * Adjust jump targets according to the Linux coding style convention.
> 
> * Delete initialisations for variables at the beginning
>  which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 90 +++++++++++++++++++++++++--------------
> 1 file changed, 59 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index b3b5ded85166..c0c299ffa0f6 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -432,8 +432,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
>                struct ib_udata *uhw)
> {
>    struct mlx4_ib_dev *dev = to_mdev(ibdev);
> -    struct ib_smp *in_mad  = NULL;
> -    struct ib_smp *out_mad = NULL;
> +    struct ib_smp *in_mad;
> +    struct ib_smp *out_mad;
>    int err;
>    int have_ib_ports;
>    struct mlx4_uverbs_ex_query_device cmd;
> @@ -458,10 +458,14 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
>    resp.response_length = offsetof(typeof(resp), response_length) +
>        sizeof(resp.response_length);
>    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> +    if (!in_mad)
> +        return -ENOMEM;
> +
>    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> -    err = -ENOMEM;
> -    if (!in_mad || !out_mad)
> -        goto out;
> +    if (!out_mad) {
> +        err = -ENOMEM;
> +        goto free_in_mad;
> +    }
> 
>    init_query_mad(in_mad);
>    in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
> @@ -570,9 +574,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
>            goto out;
>    }
> out:
> -    kfree(in_mad);
>    kfree(out_mad);
> -
> +free_in_mad:
> +    kfree(in_mad);
>    return err;
> }
> 
> @@ -588,16 +592,21 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num)
> static int ib_link_query_port(struct ib_device *ibdev, u8 port,
>                  struct ib_port_attr *props, int netw_view)
> {
> -    struct ib_smp *in_mad  = NULL;
> -    struct ib_smp *out_mad = NULL;
> +    struct ib_smp *in_mad;
> +    struct ib_smp *out_mad;
>    int ext_active_speed;
>    int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> -    int err = -ENOMEM;
> +    int err;
> 
>    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> +    if (!in_mad)
> +        return -ENOMEM;
> +
>    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> -    if (!in_mad || !out_mad)
> -        goto out;
> +    if (!out_mad) {
> +        err = -ENOMEM;
> +        goto free_in_mad;
> +    }
> 
>    init_query_mad(in_mad);
>    in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
> @@ -670,8 +679,9 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
>         props->active_speed = IB_SPEED_SDR;
> 
> out:
> -    kfree(in_mad);
>    kfree(out_mad);
> +free_in_mad:
> +    kfree(in_mad);
>    return err;
> }
> 
> @@ -763,17 +773,22 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
> int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
>            union ib_gid *gid, int netw_view)
> {
> -    struct ib_smp *in_mad  = NULL;
> -    struct ib_smp *out_mad = NULL;
> -    int err = -ENOMEM;
> +    struct ib_smp *in_mad;
> +    struct ib_smp *out_mad;
> +    int err;
>    struct mlx4_ib_dev *dev = to_mdev(ibdev);
>    int clear = 0;
>    int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> 
>    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> +    if (!in_mad)
> +        return -ENOMEM;
> +
>    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> -    if (!in_mad || !out_mad)
> -        goto out;
> +    if (!out_mad) {
> +        err = -ENOMEM;
> +        goto free_in_mad;
> +    }
> 
>    init_query_mad(in_mad);
>    in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
> @@ -811,8 +826,9 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
> out:
>    if (clear)
>        memset(gid->raw + 8, 0, 8);
> -    kfree(in_mad);
>    kfree(out_mad);
> +free_in_mad:
> +    kfree(in_mad);
>    return err;
> }
> 
> @@ -902,15 +918,20 @@ static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
> int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
>             u16 *pkey, int netw_view)
> {
> -    struct ib_smp *in_mad  = NULL;
> -    struct ib_smp *out_mad = NULL;
> +    struct ib_smp *in_mad;
> +    struct ib_smp *out_mad;
>    int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> -    int err = -ENOMEM;
> +    int err;
> 
>    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> +    if (!in_mad)
> +        return -ENOMEM;
> +
>    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> -    if (!in_mad || !out_mad)
> -        goto out;
> +    if (!out_mad) {
> +        err = -ENOMEM;
> +        goto free_in_mad;
> +    }
> 
>    init_query_mad(in_mad);
>    in_mad->attr_id  = IB_SMP_ATTR_PKEY_TABLE;
> @@ -927,8 +948,9 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
>    *pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
> 
> out:
> -    kfree(in_mad);
>    kfree(out_mad);
> +free_in_mad:
> +    kfree(in_mad);
>    return err;
> }
> 
> @@ -2083,15 +2105,20 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
> 
> static int init_node_data(struct mlx4_ib_dev *dev)
> {
> -    struct ib_smp *in_mad  = NULL;
> -    struct ib_smp *out_mad = NULL;
> +    struct ib_smp *in_mad;
> +    struct ib_smp *out_mad;
>    int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
> -    int err = -ENOMEM;
> +    int err;
> 
>    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
> +    if (!in_mad)
> +        return -ENOMEM;
> +
>    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
> -    if (!in_mad || !out_mad)
> -        goto out;
> +    if (!out_mad) {
> +        err = -ENOMEM;
> +        goto free_in_mad;
> +    }
> 
>    init_query_mad(in_mad);
>    in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
> @@ -2114,8 +2141,9 @@ static int init_node_data(struct mlx4_ib_dev *dev)
>    memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
> 
> out:
> -    kfree(in_mad);
>    kfree(out_mad);
> +free_in_mad:
> +    kfree(in_mad);
>    return err;
> }
> 
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses
@ 2017-02-19 17:21     ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:21 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors

DQo+IE9uIEZlYiAxOCwgMjAxNywgYXQgMTE6MDIgUE0sIFNGIE1hcmt1cyBFbGZyaW5nIDxlbGZy
aW5nQHVzZXJzLnNvdXJjZWZvcmdlLm5ldD4gd3JvdGU6DQo+IA0KPiBGcm9tOiBNYXJrdXMgRWxm
cmluZyA8ZWxmcmluZ0B1c2Vycy5zb3VyY2Vmb3JnZS5uZXQ+DQo+IERhdGU6IFNhdCwgMTggRmVi
IDIwMTcgMTE6Mjg6NDEgKzAxMDANCj4gTUlNRS1WZXJzaW9uOiAxLjANCj4gQ29udGVudC1UeXBl
OiB0ZXh0L3BsYWluOyBjaGFyc2V0PVVURi04DQo+IENvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6
IDhiaXQNCj4gDQo+IFRoZSBzY3JpcHQgImNoZWNrcGF0Y2gucGwiIHBvaW50ZWQgaW5mb3JtYXRp
b24gb3V0IGxpa2UgdGhlIGZvbGxvd2luZy4NCj4gDQo+IFdBUk5JTkc6IHNpemVvZiDigKYgc2hv
dWxkIGJlIHNpemVvZijigKYpDQo+IA0KPiBUaHVzIGZpeCB0aGUgYWZmZWN0ZWQgc291cmNlIGNv
ZGUgcGxhY2VzLg0KPiANCj4gU2lnbmVkLW9mZi1ieTogTWFya3VzIEVsZnJpbmcgPGVsZnJpbmdA
dXNlcnMuc291cmNlZm9yZ2UubmV0Pg0KPiAtLS0NCj4gZHJpdmVycy9pbmZpbmliYW5kL2h3L21s
eDQvbWFpbi5jIHwgMzUgKysrKysrKysrKysrKysrKystLS0tLS0tLS0tLS0tLS0tLS0NCj4gMSBm
aWxlIGNoYW5nZWQsIDE3IGluc2VydGlvbnMoKyksIDE4IGRlbGV0aW9ucygtKQ0KPiANCj4gZGlm
ZiAtLWdpdCBhL2RyaXZlcnMvaW5maW5pYmFuZC9ody9tbHg0L21haW4uYyBiL2RyaXZlcnMvaW5m
aW5pYmFuZC9ody9tbHg0L21haW4uYw0KPiBpbmRleCAzNTBjOTE0ODM0MGUuLmIzYjVkZWQ4NTE2
NiAxMDA2NDQNCj4gLS0tIGEvZHJpdmVycy9pbmZpbmliYW5kL2h3L21seDQvbWFpbi5jDQo+ICsr
KyBiL2RyaXZlcnMvaW5maW5pYmFuZC9ody9tbHg0L21haW4uYw0KPiBAQCAtNDU3LDggKzQ1Nyw4
IEBAIHN0YXRpYyBpbnQgbWx4NF9pYl9xdWVyeV9kZXZpY2Uoc3RydWN0IGliX2RldmljZSAqaWJk
ZXYsDQo+IA0KPiAgICByZXNwLnJlc3BvbnNlX2xlbmd0aCA9IG9mZnNldG9mKHR5cGVvZihyZXNw
KSwgcmVzcG9uc2VfbGVuZ3RoKSArDQo+ICAgICAgICBzaXplb2YocmVzcC5yZXNwb25zZV9sZW5n
dGgpOw0KPiAtICAgIGluX21hZCAgPSBremFsbG9jKHNpemVvZiAqaW5fbWFkLCBHRlBfS0VSTkVM
KTsNCj4gLSAgICBvdXRfbWFkID0ga21hbGxvYyhzaXplb2YgKm91dF9tYWQsIEdGUF9LRVJORUwp
Ow0KPiArICAgIGluX21hZCAgPSBremFsbG9jKHNpemVvZigqaW5fbWFkKSwgR0ZQX0tFUk5FTCk7
DQo+ICsgICAgb3V0X21hZCA9IGttYWxsb2Moc2l6ZW9mKCpvdXRfbWFkKSwgR0ZQX0tFUk5FTCk7
DQo+ICAgIGVyciA9IC1FTk9NRU07DQo+ICAgIGlmICghaW5fbWFkIHx8ICFvdXRfbWFkKQ0KPiAg
ICAgICAgZ290byBvdXQ7DQo+IEBAIC00NzEsOCArNDcxLDcgQEAgc3RhdGljIGludCBtbHg0X2li
X3F1ZXJ5X2RldmljZShzdHJ1Y3QgaWJfZGV2aWNlICppYmRldiwNCj4gICAgaWYgKGVycikNCj4g
ICAgICAgIGdvdG8gb3V0Ow0KPiANCj4gLSAgICBtZW1zZXQocHJvcHMsIDAsIHNpemVvZiAqcHJv
cHMpOw0KPiAtDQo+ICsgICAgbWVtc2V0KHByb3BzLCAwLCBzaXplb2YoKnByb3BzKSk7DQo+ICAg
IGhhdmVfaWJfcG9ydHMgPSBudW1faWJfcG9ydHMoZGV2LT5kZXYpOw0KPiANCj4gICAgcHJvcHMt
PmZ3X3ZlciA9IGRldi0+ZGV2LT5jYXBzLmZ3X3ZlcjsNCj4gQEAgLTU5NSw4ICs1OTQsOCBAQCBz
dGF0aWMgaW50IGliX2xpbmtfcXVlcnlfcG9ydChzdHJ1Y3QgaWJfZGV2aWNlICppYmRldiwgdTgg
cG9ydCwNCj4gICAgaW50IG1hZF9pZmNfZmxhZ3MgPSBNTFg0X01BRF9JRkNfSUdOT1JFX0tFWVM7
DQo+ICAgIGludCBlcnIgPSAtRU5PTUVNOw0KPiANCj4gLSAgICBpbl9tYWQgID0ga3phbGxvYyhz
aXplb2YgKmluX21hZCwgR0ZQX0tFUk5FTCk7DQo+IC0gICAgb3V0X21hZCA9IGttYWxsb2Moc2l6
ZW9mICpvdXRfbWFkLCBHRlBfS0VSTkVMKTsNCj4gKyAgICBpbl9tYWQgID0ga3phbGxvYyhzaXpl
b2YoKmluX21hZCksIEdGUF9LRVJORUwpOw0KPiArICAgIG91dF9tYWQgPSBrbWFsbG9jKHNpemVv
Zigqb3V0X21hZCksIEdGUF9LRVJORUwpOw0KPiAgICBpZiAoIWluX21hZCB8fCAhb3V0X21hZCkN
Cj4gICAgICAgIGdvdG8gb3V0Ow0KPiANCj4gQEAgLTc3MSw4ICs3NzAsOCBAQCBpbnQgX19tbHg0
X2liX3F1ZXJ5X2dpZChzdHJ1Y3QgaWJfZGV2aWNlICppYmRldiwgdTggcG9ydCwgaW50IGluZGV4
LA0KPiAgICBpbnQgY2xlYXIgPSAwOw0KPiAgICBpbnQgbWFkX2lmY19mbGFncyA9IE1MWDRfTUFE
X0lGQ19JR05PUkVfS0VZUzsNCj4gDQo+IC0gICAgaW5fbWFkICA9IGt6YWxsb2Moc2l6ZW9mICpp
bl9tYWQsIEdGUF9LRVJORUwpOw0KPiAtICAgIG91dF9tYWQgPSBrbWFsbG9jKHNpemVvZiAqb3V0
X21hZCwgR0ZQX0tFUk5FTCk7DQo+ICsgICAgaW5fbWFkICA9IGt6YWxsb2Moc2l6ZW9mKCppbl9t
YWQpLCBHRlBfS0VSTkVMKTsNCj4gKyAgICBvdXRfbWFkID0ga21hbGxvYyhzaXplb2YoKm91dF9t
YWQpLCBHRlBfS0VSTkVMKTsNCj4gICAgaWYgKCFpbl9tYWQgfHwgIW91dF9tYWQpDQo+ICAgICAg
ICBnb3RvIG91dDsNCj4gDQo+IEBAIC05MDgsOCArOTA3LDggQEAgaW50IF9fbWx4NF9pYl9xdWVy
eV9wa2V5KHN0cnVjdCBpYl9kZXZpY2UgKmliZGV2LCB1OCBwb3J0LCB1MTYgaW5kZXgsDQo+ICAg
IGludCBtYWRfaWZjX2ZsYWdzID0gTUxYNF9NQURfSUZDX0lHTk9SRV9LRVlTOw0KPiAgICBpbnQg
ZXJyID0gLUVOT01FTTsNCj4gDQo+IC0gICAgaW5fbWFkICA9IGt6YWxsb2Moc2l6ZW9mICppbl9t
YWQsIEdGUF9LRVJORUwpOw0KPiAtICAgIG91dF9tYWQgPSBrbWFsbG9jKHNpemVvZiAqb3V0X21h
ZCwgR0ZQX0tFUk5FTCk7DQo+ICsgICAgaW5fbWFkICA9IGt6YWxsb2Moc2l6ZW9mKCppbl9tYWQp
LCBHRlBfS0VSTkVMKTsNCj4gKyAgICBvdXRfbWFkID0ga21hbGxvYyhzaXplb2YoKm91dF9tYWQp
LCBHRlBfS0VSTkVMKTsNCj4gICAgaWYgKCFpbl9tYWQgfHwgIW91dF9tYWQpDQo+ICAgICAgICBn
b3RvIG91dDsNCj4gDQo+IEBAIC0xMjgwLDcgKzEyNzksNyBAQCBzdGF0aWMgc3RydWN0IGliX3Bk
ICptbHg0X2liX2FsbG9jX3BkKHN0cnVjdCBpYl9kZXZpY2UgKmliZGV2LA0KPiAgICBzdHJ1Y3Qg
bWx4NF9pYl9wZCAqcGQ7DQo+ICAgIGludCBlcnI7DQo+IA0KPiAtICAgIHBkID0ga21hbGxvYyhz
aXplb2YgKnBkLCBHRlBfS0VSTkVMKTsNCj4gKyAgICBwZCA9IGttYWxsb2Moc2l6ZW9mKCpwZCks
IEdGUF9LRVJORUwpOw0KPiAgICBpZiAoIXBkKQ0KPiAgICAgICAgcmV0dXJuIEVSUl9QVFIoLUVO
T01FTSk7DQo+IA0KPiBAQCAtMTMxOSw3ICsxMzE4LDcgQEAgc3RhdGljIHN0cnVjdCBpYl94cmNk
ICptbHg0X2liX2FsbG9jX3hyY2Qoc3RydWN0IGliX2RldmljZSAqaWJkZXYsDQo+ICAgIGlmICgh
KHRvX21kZXYoaWJkZXYpLT5kZXYtPmNhcHMuZmxhZ3MgJiBNTFg0X0RFVl9DQVBfRkxBR19YUkMp
KQ0KPiAgICAgICAgcmV0dXJuIEVSUl9QVFIoLUVOT1NZUyk7DQo+IA0KPiAtICAgIHhyY2QgPSBr
bWFsbG9jKHNpemVvZiAqeHJjZCwgR0ZQX0tFUk5FTCk7DQo+ICsgICAgeHJjZCA9IGttYWxsb2Mo
c2l6ZW9mKCp4cmNkKSwgR0ZQX0tFUk5FTCk7DQo+ICAgIGlmICgheHJjZCkNCj4gICAgICAgIHJl
dHVybiBFUlJfUFRSKC1FTk9NRU0pOw0KPiANCj4gQEAgLTEzNjcsNyArMTM2Niw3IEBAIHN0YXRp
YyBpbnQgYWRkX2dpZF9lbnRyeShzdHJ1Y3QgaWJfcXAgKmlicXAsIHVuaW9uIGliX2dpZCAqZ2lk
KQ0KPiAgICBzdHJ1Y3QgbWx4NF9pYl9kZXYgKm1kZXYgPSB0b19tZGV2KGlicXAtPmRldmljZSk7
DQo+ICAgIHN0cnVjdCBtbHg0X2liX2dpZF9lbnRyeSAqZ2U7DQo+IA0KPiAtICAgIGdlID0ga3ph
bGxvYyhzaXplb2YgKmdlLCBHRlBfS0VSTkVMKTsNCj4gKyAgICBnZSA9IGt6YWxsb2Moc2l6ZW9m
KCpnZSksIEdGUF9LRVJORUwpOw0KPiAgICBpZiAoIWdlKQ0KPiAgICAgICAgcmV0dXJuIC1FTk9N
RU07DQo+IA0KPiBAQCAtMjA4OSw4ICsyMDg4LDggQEAgc3RhdGljIGludCBpbml0X25vZGVfZGF0
YShzdHJ1Y3QgbWx4NF9pYl9kZXYgKmRldikNCj4gICAgaW50IG1hZF9pZmNfZmxhZ3MgPSBNTFg0
X01BRF9JRkNfSUdOT1JFX0tFWVM7DQo+ICAgIGludCBlcnIgPSAtRU5PTUVNOw0KPiANCj4gLSAg
ICBpbl9tYWQgID0ga3phbGxvYyhzaXplb2YgKmluX21hZCwgR0ZQX0tFUk5FTCk7DQo+IC0gICAg
b3V0X21hZCA9IGttYWxsb2Moc2l6ZW9mICpvdXRfbWFkLCBHRlBfS0VSTkVMKTsNCj4gKyAgICBp
bl9tYWQgID0ga3phbGxvYyhzaXplb2YoKmluX21hZCksIEdGUF9LRVJORUwpOw0KPiArICAgIG91
dF9tYWQgPSBrbWFsbG9jKHNpemVvZigqb3V0X21hZCksIEdGUF9LRVJORUwpOw0KPiAgICBpZiAo
IWluX21hZCB8fCAhb3V0X21hZCkNCj4gICAgICAgIGdvdG8gb3V0Ow0KPiANCj4gQEAgLTI2MDAs
NyArMjU5OSw3IEBAIHN0YXRpYyB2b2lkICptbHg0X2liX2FkZChzdHJ1Y3QgbWx4NF9kZXYgKmRl
dikNCj4gICAgaWYgKG51bV9wb3J0cyA9PSAwKQ0KPiAgICAgICAgcmV0dXJuIE5VTEw7DQo+IA0K
PiAtICAgIGliZGV2ID0gKHN0cnVjdCBtbHg0X2liX2RldiAqKSBpYl9hbGxvY19kZXZpY2Uoc2l6
ZW9mICppYmRldik7DQo+ICsgICAgaWJkZXYgPSAoc3RydWN0IG1seDRfaWJfZGV2ICopIGliX2Fs
bG9jX2RldmljZShzaXplb2YoKmliZGV2KSk7DQo+ICAgIGlmICghaWJkZXYpIHsNCj4gICAgICAg
IGRldl9lcnIoJmRldi0+cGVyc2lzdC0+cGRldi0+ZGV2LA0KPiAgICAgICAgICAgICJEZXZpY2Ug
c3RydWN0IGFsbG9jIGZhaWxlZFxuIik7DQo+IEBAIC0zMzAxLDEyICszMzAwLDEyIEBAIHN0YXRp
YyB2b2lkIG1seDRfaWJfZXZlbnQoc3RydWN0IG1seDRfZGV2ICpkZXYsIHZvaWQgKmliZGV2X3B0
ciwNCj4gICAgICAgIGJyZWFrOw0KPiANCj4gICAgY2FzZSBNTFg0X0RFVl9FVkVOVF9QT1JUX01H
TVRfQ0hBTkdFOg0KPiAtICAgICAgICBldyA9IGttYWxsb2Moc2l6ZW9mICpldywgR0ZQX0FUT01J
Qyk7DQo+ICsgICAgICAgIGV3ID0ga21hbGxvYyhzaXplb2YoKmV3KSwgR0ZQX0FUT01JQyk7DQo+
ICAgICAgICBpZiAoIWV3KQ0KPiAgICAgICAgICAgIGJyZWFrOw0KPiANCj4gICAgICAgIElOSVRf
V09SSygmZXctPndvcmssIGhhbmRsZV9wb3J0X21nbXRfY2hhbmdlX2V2ZW50KTsNCj4gLSAgICAg
ICAgbWVtY3B5KCZldy0+aWJfZXFlLCBlcWUsIHNpemVvZiAqZXFlKTsNCj4gKyAgICAgICAgbWVt
Y3B5KCZldy0+aWJfZXFlLCBlcWUsIHNpemVvZigqZXFlKSk7DQo+ICAgICAgICBldy0+aWJfZGV2
ID0gaWJkZXY7DQo+ICAgICAgICAvKiBuZWVkIHRvIHF1ZXVlIG9ubHkgZm9yIHBvcnQgb3duZXIs
IHdoaWNoIHVzZXMgR0VOX0VRRSAqLw0KPiAgICAgICAgaWYgKG1seDRfaXNfbWFzdGVyKGRldikp
DQo+IC0tIA0KPiAyLjExLjENCj4gDQo+IC0tDQo+IFRvIHVuc3Vic2NyaWJlIGZyb20gdGhpcyBs
aXN0OiBzZW5kIHRoZSBsaW5lICJ1bnN1YnNjcmliZSBsaW51eC1yZG1hIiBpbg0KPiB0aGUgYm9k
eSBvZiBhIG1lc3NhZ2UgdG8gbWFqb3Jkb21vQHZnZXIua2VybmVsLm9yZw0KPiBNb3JlIG1ham9y
ZG9tbyBpbmZvIGF0ICBodHRwOi8vdmdlci5rZXJuZWwub3JnL21ham9yZG9tby1pbmZvLmh0bWwN
ClRoYW5rcywNClJldmlld2VkLWJ5OiBNYWpkIERpYmJpbnkNCjxtYWpkQG1lbGxhbm94LmNvbT4

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

* Re: [PATCH 11/29] IB/mlx4: Use kmalloc_array() in three functions
  2017-02-18 20:59     ` SF Markus Elfring
  (?)
  (?)
@ 2017-02-19 17:21     ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:21 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:07 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 10:32:32 +0100
> 
> Multiplications for the size determination of memory allocations
> indicated that array data structures should be processed.
> Thus use the corresponding function "kmalloc_array".
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index ba6af84cc236..350c9148340e 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -304,7 +304,9 @@ static int mlx4_ib_add_gid(struct ib_device *device,
>        ctx->refcount++;
>    }
>    if (!ret && hw_update) {
> -        gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
> +        gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
> +                     sizeof(*gids),
> +                     GFP_ATOMIC);
>        if (!gids) {
>            ret = -ENOMEM;
>        } else {
> @@ -359,7 +361,9 @@ static int mlx4_ib_del_gid(struct ib_device *device,
>    if (!ret && hw_update) {
>        int i;
> 
> -        gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
> +        gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
> +                     sizeof(*gids),
> +                     GFP_ATOMIC);
>        if (!gids) {
>            ret = -ENOMEM;
>        } else {
> @@ -2828,9 +2832,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>            goto err_counter;
> 
>        ibdev->ib_uc_qpns_bitmap =
> -            kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
> -                sizeof(long),
> -                GFP_KERNEL);
> +            kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
> +                      sizeof(long),
> +                      GFP_KERNEL);
>        if (!ibdev->ib_uc_qpns_bitmap)
>            goto err_steer_qp_release;
> 
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 10/29] IB/mlx4: Enclose 15 expressions for the sizeof operator by parentheses
  2017-02-18 20:58     ` SF Markus Elfring
@ 2017-02-19 17:21       ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:21 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 10:59 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 09:54:15 +0100
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> WARNING: sizeof … should be sizeof(…)
> 
> Thus fix the affected source code places.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 30 +++++++++++++++---------------
> 1 file changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 860fec8b9601..b26817f0669f 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -195,7 +195,7 @@ static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)
>    if (!dev->send_agent[port_num - 1][0])
>        return;
> 
> -    memset(&ah_attr, 0, sizeof ah_attr);
> +    memset(&ah_attr, 0, sizeof(ah_attr));
>    ah_attr.dlid     = lid;
>    ah_attr.sl       = sl;
>    ah_attr.port_num = port_num;
> @@ -400,7 +400,7 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
>         * it's OK for our devices).
>         */
>        spin_lock_irqsave(&dev->sm_lock, flags);
> -        memcpy(send_buf->mad, mad, sizeof *mad);
> +        memcpy(send_buf->mad, mad, sizeof(*mad));
>        send_buf->ah = dev->sm_ah[port_num - 1];
>        if (send_buf->ah)
>            ret = ib_post_send_mad(send_buf, NULL);
> @@ -555,7 +555,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
> 
>    /* create ah. Just need an empty one with the port num for the post send.
>     * The driver will set the force loopback bit in post_send */
> -    memset(&attr, 0, sizeof attr);
> +    memset(&attr, 0, sizeof(attr));
>    attr.port_num = port;
>    if (is_eth) {
>        union ib_gid sgid;
> @@ -590,8 +590,8 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
> 
>    /* copy over to tunnel buffer */
>    if (grh)
> -        memcpy(&tun_mad->grh, grh, sizeof *grh);
> -    memcpy(&tun_mad->mad, mad, sizeof *mad);
> +        memcpy(&tun_mad->grh, grh, sizeof(*grh));
> +    memcpy(&tun_mad->mad, mad, sizeof(*mad));
> 
>    /* adjust tunnel data */
>    tun_mad->hdr.pkey_index = cpu_to_be16(tun_pkey_ix);
> @@ -961,7 +961,7 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
>    }
>    mutex_unlock(&dev->counters_table[port_num - 1].mutex);
>    if (stats_avail) {
> -        memset(out_mad->data, 0, sizeof out_mad->data);
> +        memset(out_mad->data, 0, sizeof(out_mad->data));
>        switch (counter_stats.counter_mode & 0xf) {
>        case 0:
>            edit_counter(&counter_stats,
> @@ -1136,11 +1136,11 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
>    if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
>        return;
> 
> -    in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
> +    in_mad  = kmalloc(sizeof(*in_mad), GFP_KERNEL);
>    if (!in_mad)
>        return;
> 
> -    out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> +    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
>    if (!out_mad)
>        goto free_in_mad;
> 
> @@ -1149,8 +1149,8 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
>    for (i = 0; i < 4; i++) {
>        if (change_bitmap && (!((change_bitmap >> (8 * i)) & 0xff)))
>            continue;
> -        memset(in_mad, 0, sizeof *in_mad);
> -        memset(out_mad, 0, sizeof *out_mad);
> +        memset(in_mad, 0, sizeof(*in_mad));
> +        memset(out_mad, 0, sizeof(*out_mad));
> 
>        in_mad->base_version  = 1;
>        in_mad->mgmt_class    = IB_MGMT_CLASS_SUBN_LID_ROUTED;
> @@ -1421,7 +1421,7 @@ int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
>                   sizeof (struct mlx4_mad_snd_buf),
>                   DMA_TO_DEVICE);
> 
> -    memcpy(&sqp_mad->payload, mad, sizeof *mad);
> +    memcpy(&sqp_mad->payload, mad, sizeof(*mad));
> 
>    ib_dma_sync_single_for_device(&dev->ib_dev,
>                      sqp->tx_ring[wire_tx_ix].buf.map,
> @@ -1804,7 +1804,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
> 
>    tun_qp = &ctx->qp[qp_type];
> 
> -    memset(&qp_init_attr, 0, sizeof qp_init_attr);
> +    memset(&qp_init_attr, 0, sizeof(qp_init_attr));
>    qp_init_attr.init_attr.send_cq = ctx->cq;
>    qp_init_attr.init_attr.recv_cq = ctx->cq;
>    qp_init_attr.init_attr.sq_sig_type = IB_SIGNAL_ALL_WR;
> @@ -1837,7 +1837,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
>        return ret;
>    }
> 
> -    memset(&attr, 0, sizeof attr);
> +    memset(&attr, 0, sizeof(attr));
>    attr.qp_state = IB_QPS_INIT;
>    ret = 0;
>    if (create_tun)
> @@ -2184,7 +2184,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
>        goto err_mcg;
>    }
> 
> -    snprintf(name, sizeof name, "mlx4_ibt%d", port);
> +    snprintf(name, sizeof(name), "mlx4_ibt%d", port);
>    ctx->wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
>    if (!ctx->wq) {
>        pr_err("Failed to create tunnelling WQ for port %d\n", port);
> @@ -2192,7 +2192,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
>        goto err_wq;
>    }
> 
> -    snprintf(name, sizeof name, "mlx4_ibud%d", port);
> +    snprintf(name, sizeof(name), "mlx4_ibud%d", port);
>    ctx->ud_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
>    if (!ctx->ud_wq) {
>        pr_err("Failed to create up/down WQ for port %d\n", port);
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 10/29] IB/mlx4: Enclose 15 expressions for the sizeof operator by parentheses
@ 2017-02-19 17:21       ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:21 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors

DQo+IE9uIEZlYiAxOCwgMjAxNywgYXQgMTA6NTkgUE0sIFNGIE1hcmt1cyBFbGZyaW5nIDxlbGZy
aW5nQHVzZXJzLnNvdXJjZWZvcmdlLm5ldD4gd3JvdGU6DQo+IA0KPiBGcm9tOiBNYXJrdXMgRWxm
cmluZyA8ZWxmcmluZ0B1c2Vycy5zb3VyY2Vmb3JnZS5uZXQ+DQo+IERhdGU6IFNhdCwgMTggRmVi
IDIwMTcgMDk6NTQ6MTUgKzAxMDANCj4gTUlNRS1WZXJzaW9uOiAxLjANCj4gQ29udGVudC1UeXBl
OiB0ZXh0L3BsYWluOyBjaGFyc2V0PVVURi04DQo+IENvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6
IDhiaXQNCj4gDQo+IFRoZSBzY3JpcHQgImNoZWNrcGF0Y2gucGwiIHBvaW50ZWQgaW5mb3JtYXRp
b24gb3V0IGxpa2UgdGhlIGZvbGxvd2luZy4NCj4gDQo+IFdBUk5JTkc6IHNpemVvZiDigKYgc2hv
dWxkIGJlIHNpemVvZijigKYpDQo+IA0KPiBUaHVzIGZpeCB0aGUgYWZmZWN0ZWQgc291cmNlIGNv
ZGUgcGxhY2VzLg0KPiANCj4gU2lnbmVkLW9mZi1ieTogTWFya3VzIEVsZnJpbmcgPGVsZnJpbmdA
dXNlcnMuc291cmNlZm9yZ2UubmV0Pg0KPiAtLS0NCj4gZHJpdmVycy9pbmZpbmliYW5kL2h3L21s
eDQvbWFkLmMgfCAzMCArKysrKysrKysrKysrKystLS0tLS0tLS0tLS0tLS0NCj4gMSBmaWxlIGNo
YW5nZWQsIDE1IGluc2VydGlvbnMoKyksIDE1IGRlbGV0aW9ucygtKQ0KPiANCj4gZGlmZiAtLWdp
dCBhL2RyaXZlcnMvaW5maW5pYmFuZC9ody9tbHg0L21hZC5jIGIvZHJpdmVycy9pbmZpbmliYW5k
L2h3L21seDQvbWFkLmMNCj4gaW5kZXggODYwZmVjOGI5NjAxLi5iMjY4MTdmMDY2OWYgMTAwNjQ0
DQo+IC0tLSBhL2RyaXZlcnMvaW5maW5pYmFuZC9ody9tbHg0L21hZC5jDQo+ICsrKyBiL2RyaXZl
cnMvaW5maW5pYmFuZC9ody9tbHg0L21hZC5jDQo+IEBAIC0xOTUsNyArMTk1LDcgQEAgc3RhdGlj
IHZvaWQgdXBkYXRlX3NtX2FoKHN0cnVjdCBtbHg0X2liX2RldiAqZGV2LCB1OCBwb3J0X251bSwg
dTE2IGxpZCwgdTggc2wpDQo+ICAgIGlmICghZGV2LT5zZW5kX2FnZW50W3BvcnRfbnVtIC0gMV1b
MF0pDQo+ICAgICAgICByZXR1cm47DQo+IA0KPiAtICAgIG1lbXNldCgmYWhfYXR0ciwgMCwgc2l6
ZW9mIGFoX2F0dHIpOw0KPiArICAgIG1lbXNldCgmYWhfYXR0ciwgMCwgc2l6ZW9mKGFoX2F0dHIp
KTsNCj4gICAgYWhfYXR0ci5kbGlkICAgICA9IGxpZDsNCj4gICAgYWhfYXR0ci5zbCAgICAgICA9
IHNsOw0KPiAgICBhaF9hdHRyLnBvcnRfbnVtID0gcG9ydF9udW07DQo+IEBAIC00MDAsNyArNDAw
LDcgQEAgc3RhdGljIHZvaWQgZm9yd2FyZF90cmFwKHN0cnVjdCBtbHg0X2liX2RldiAqZGV2LCB1
OCBwb3J0X251bSwgY29uc3Qgc3RydWN0IGliX20NCj4gICAgICAgICAqIGl0J3MgT0sgZm9yIG91
ciBkZXZpY2VzKS4NCj4gICAgICAgICAqLw0KPiAgICAgICAgc3Bpbl9sb2NrX2lycXNhdmUoJmRl
di0+c21fbG9jaywgZmxhZ3MpOw0KPiAtICAgICAgICBtZW1jcHkoc2VuZF9idWYtPm1hZCwgbWFk
LCBzaXplb2YgKm1hZCk7DQo+ICsgICAgICAgIG1lbWNweShzZW5kX2J1Zi0+bWFkLCBtYWQsIHNp
emVvZigqbWFkKSk7DQo+ICAgICAgICBzZW5kX2J1Zi0+YWggPSBkZXYtPnNtX2FoW3BvcnRfbnVt
IC0gMV07DQo+ICAgICAgICBpZiAoc2VuZF9idWYtPmFoKQ0KPiAgICAgICAgICAgIHJldCA9IGli
X3Bvc3Rfc2VuZF9tYWQoc2VuZF9idWYsIE5VTEwpOw0KPiBAQCAtNTU1LDcgKzU1NSw3IEBAIGlu
dCBtbHg0X2liX3NlbmRfdG9fc2xhdmUoc3RydWN0IG1seDRfaWJfZGV2ICpkZXYsIGludCBzbGF2
ZSwgdTggcG9ydCwNCj4gDQo+ICAgIC8qIGNyZWF0ZSBhaC4gSnVzdCBuZWVkIGFuIGVtcHR5IG9u
ZSB3aXRoIHRoZSBwb3J0IG51bSBmb3IgdGhlIHBvc3Qgc2VuZC4NCj4gICAgICogVGhlIGRyaXZl
ciB3aWxsIHNldCB0aGUgZm9yY2UgbG9vcGJhY2sgYml0IGluIHBvc3Rfc2VuZCAqLw0KPiAtICAg
IG1lbXNldCgmYXR0ciwgMCwgc2l6ZW9mIGF0dHIpOw0KPiArICAgIG1lbXNldCgmYXR0ciwgMCwg
c2l6ZW9mKGF0dHIpKTsNCj4gICAgYXR0ci5wb3J0X251bSA9IHBvcnQ7DQo+ICAgIGlmIChpc19l
dGgpIHsNCj4gICAgICAgIHVuaW9uIGliX2dpZCBzZ2lkOw0KPiBAQCAtNTkwLDggKzU5MCw4IEBA
IGludCBtbHg0X2liX3NlbmRfdG9fc2xhdmUoc3RydWN0IG1seDRfaWJfZGV2ICpkZXYsIGludCBz
bGF2ZSwgdTggcG9ydCwNCj4gDQo+ICAgIC8qIGNvcHkgb3ZlciB0byB0dW5uZWwgYnVmZmVyICov
DQo+ICAgIGlmIChncmgpDQo+IC0gICAgICAgIG1lbWNweSgmdHVuX21hZC0+Z3JoLCBncmgsIHNp
emVvZiAqZ3JoKTsNCj4gLSAgICBtZW1jcHkoJnR1bl9tYWQtPm1hZCwgbWFkLCBzaXplb2YgKm1h
ZCk7DQo+ICsgICAgICAgIG1lbWNweSgmdHVuX21hZC0+Z3JoLCBncmgsIHNpemVvZigqZ3JoKSk7
DQo+ICsgICAgbWVtY3B5KCZ0dW5fbWFkLT5tYWQsIG1hZCwgc2l6ZW9mKCptYWQpKTsNCj4gDQo+
ICAgIC8qIGFkanVzdCB0dW5uZWwgZGF0YSAqLw0KPiAgICB0dW5fbWFkLT5oZHIucGtleV9pbmRl
eCA9IGNwdV90b19iZTE2KHR1bl9wa2V5X2l4KTsNCj4gQEAgLTk2MSw3ICs5NjEsNyBAQCBzdGF0
aWMgaW50IGlib2VfcHJvY2Vzc19tYWQoc3RydWN0IGliX2RldmljZSAqaWJkZXYsIGludCBtYWRf
ZmxhZ3MsIHU4IHBvcnRfbnVtLA0KPiAgICB9DQo+ICAgIG11dGV4X3VubG9jaygmZGV2LT5jb3Vu
dGVyc190YWJsZVtwb3J0X251bSAtIDFdLm11dGV4KTsNCj4gICAgaWYgKHN0YXRzX2F2YWlsKSB7
DQo+IC0gICAgICAgIG1lbXNldChvdXRfbWFkLT5kYXRhLCAwLCBzaXplb2Ygb3V0X21hZC0+ZGF0
YSk7DQo+ICsgICAgICAgIG1lbXNldChvdXRfbWFkLT5kYXRhLCAwLCBzaXplb2Yob3V0X21hZC0+
ZGF0YSkpOw0KPiAgICAgICAgc3dpdGNoIChjb3VudGVyX3N0YXRzLmNvdW50ZXJfbW9kZSAmIDB4
Zikgew0KPiAgICAgICAgY2FzZSAwOg0KPiAgICAgICAgICAgIGVkaXRfY291bnRlcigmY291bnRl
cl9zdGF0cywNCj4gQEAgLTExMzYsMTEgKzExMzYsMTEgQEAgc3RhdGljIHZvaWQgaGFuZGxlX3Ns
YXZlc19ndWlkX2NoYW5nZShzdHJ1Y3QgbWx4NF9pYl9kZXYgKmRldiwgdTggcG9ydF9udW0sDQo+
ICAgIGlmICghbWx4NF9pc19tZnVuYyhkZXYtPmRldikgfHwgIW1seDRfaXNfbWFzdGVyKGRldi0+
ZGV2KSkNCj4gICAgICAgIHJldHVybjsNCj4gDQo+IC0gICAgaW5fbWFkICA9IGttYWxsb2Moc2l6
ZW9mICppbl9tYWQsIEdGUF9LRVJORUwpOw0KPiArICAgIGluX21hZCAgPSBrbWFsbG9jKHNpemVv
ZigqaW5fbWFkKSwgR0ZQX0tFUk5FTCk7DQo+ICAgIGlmICghaW5fbWFkKQ0KPiAgICAgICAgcmV0
dXJuOw0KPiANCj4gLSAgICBvdXRfbWFkID0ga21hbGxvYyhzaXplb2YgKm91dF9tYWQsIEdGUF9L
RVJORUwpOw0KPiArICAgIG91dF9tYWQgPSBrbWFsbG9jKHNpemVvZigqb3V0X21hZCksIEdGUF9L
RVJORUwpOw0KPiAgICBpZiAoIW91dF9tYWQpDQo+ICAgICAgICBnb3RvIGZyZWVfaW5fbWFkOw0K
PiANCj4gQEAgLTExNDksOCArMTE0OSw4IEBAIHN0YXRpYyB2b2lkIGhhbmRsZV9zbGF2ZXNfZ3Vp
ZF9jaGFuZ2Uoc3RydWN0IG1seDRfaWJfZGV2ICpkZXYsIHU4IHBvcnRfbnVtLA0KPiAgICBmb3Ig
KGkgPSAwOyBpIDwgNDsgaSsrKSB7DQo+ICAgICAgICBpZiAoY2hhbmdlX2JpdG1hcCAmJiAoISgo
Y2hhbmdlX2JpdG1hcCA+PiAoOCAqIGkpKSAmIDB4ZmYpKSkNCj4gICAgICAgICAgICBjb250aW51
ZTsNCj4gLSAgICAgICAgbWVtc2V0KGluX21hZCwgMCwgc2l6ZW9mICppbl9tYWQpOw0KPiAtICAg
ICAgICBtZW1zZXQob3V0X21hZCwgMCwgc2l6ZW9mICpvdXRfbWFkKTsNCj4gKyAgICAgICAgbWVt
c2V0KGluX21hZCwgMCwgc2l6ZW9mKCppbl9tYWQpKTsNCj4gKyAgICAgICAgbWVtc2V0KG91dF9t
YWQsIDAsIHNpemVvZigqb3V0X21hZCkpOw0KPiANCj4gICAgICAgIGluX21hZC0+YmFzZV92ZXJz
aW9uICA9IDE7DQo+ICAgICAgICBpbl9tYWQtPm1nbXRfY2xhc3MgICAgPSBJQl9NR01UX0NMQVNT
X1NVQk5fTElEX1JPVVRFRDsNCj4gQEAgLTE0MjEsNyArMTQyMSw3IEBAIGludCBtbHg0X2liX3Nl
bmRfdG9fd2lyZShzdHJ1Y3QgbWx4NF9pYl9kZXYgKmRldiwgaW50IHNsYXZlLCB1OCBwb3J0LA0K
PiAgICAgICAgICAgICAgICAgICBzaXplb2YgKHN0cnVjdCBtbHg0X21hZF9zbmRfYnVmKSwNCj4g
ICAgICAgICAgICAgICAgICAgRE1BX1RPX0RFVklDRSk7DQo+IA0KPiAtICAgIG1lbWNweSgmc3Fw
X21hZC0+cGF5bG9hZCwgbWFkLCBzaXplb2YgKm1hZCk7DQo+ICsgICAgbWVtY3B5KCZzcXBfbWFk
LT5wYXlsb2FkLCBtYWQsIHNpemVvZigqbWFkKSk7DQo+IA0KPiAgICBpYl9kbWFfc3luY19zaW5n
bGVfZm9yX2RldmljZSgmZGV2LT5pYl9kZXYsDQo+ICAgICAgICAgICAgICAgICAgICAgIHNxcC0+
dHhfcmluZ1t3aXJlX3R4X2l4XS5idWYubWFwLA0KPiBAQCAtMTgwNCw3ICsxODA0LDcgQEAgc3Rh
dGljIGludCBjcmVhdGVfcHZfc3FwKHN0cnVjdCBtbHg0X2liX2RlbXV4X3B2X2N0eCAqY3R4LA0K
PiANCj4gICAgdHVuX3FwID0gJmN0eC0+cXBbcXBfdHlwZV07DQo+IA0KPiAtICAgIG1lbXNldCgm
cXBfaW5pdF9hdHRyLCAwLCBzaXplb2YgcXBfaW5pdF9hdHRyKTsNCj4gKyAgICBtZW1zZXQoJnFw
X2luaXRfYXR0ciwgMCwgc2l6ZW9mKHFwX2luaXRfYXR0cikpOw0KPiAgICBxcF9pbml0X2F0dHIu
aW5pdF9hdHRyLnNlbmRfY3EgPSBjdHgtPmNxOw0KPiAgICBxcF9pbml0X2F0dHIuaW5pdF9hdHRy
LnJlY3ZfY3EgPSBjdHgtPmNxOw0KPiAgICBxcF9pbml0X2F0dHIuaW5pdF9hdHRyLnNxX3NpZ190
eXBlID0gSUJfU0lHTkFMX0FMTF9XUjsNCj4gQEAgLTE4MzcsNyArMTgzNyw3IEBAIHN0YXRpYyBp
bnQgY3JlYXRlX3B2X3NxcChzdHJ1Y3QgbWx4NF9pYl9kZW11eF9wdl9jdHggKmN0eCwNCj4gICAg
ICAgIHJldHVybiByZXQ7DQo+ICAgIH0NCj4gDQo+IC0gICAgbWVtc2V0KCZhdHRyLCAwLCBzaXpl
b2YgYXR0cik7DQo+ICsgICAgbWVtc2V0KCZhdHRyLCAwLCBzaXplb2YoYXR0cikpOw0KPiAgICBh
dHRyLnFwX3N0YXRlID0gSUJfUVBTX0lOSVQ7DQo+ICAgIHJldCA9IDA7DQo+ICAgIGlmIChjcmVh
dGVfdHVuKQ0KPiBAQCAtMjE4NCw3ICsyMTg0LDcgQEAgc3RhdGljIGludCBtbHg0X2liX2FsbG9j
X2RlbXV4X2N0eChzdHJ1Y3QgbWx4NF9pYl9kZXYgKmRldiwNCj4gICAgICAgIGdvdG8gZXJyX21j
ZzsNCj4gICAgfQ0KPiANCj4gLSAgICBzbnByaW50ZihuYW1lLCBzaXplb2YgbmFtZSwgIm1seDRf
aWJ0JWQiLCBwb3J0KTsNCj4gKyAgICBzbnByaW50ZihuYW1lLCBzaXplb2YobmFtZSksICJtbHg0
X2lidCVkIiwgcG9ydCk7DQo+ICAgIGN0eC0+d3EgPSBhbGxvY19vcmRlcmVkX3dvcmtxdWV1ZShu
YW1lLCBXUV9NRU1fUkVDTEFJTSk7DQo+ICAgIGlmICghY3R4LT53cSkgew0KPiAgICAgICAgcHJf
ZXJyKCJGYWlsZWQgdG8gY3JlYXRlIHR1bm5lbGxpbmcgV1EgZm9yIHBvcnQgJWRcbiIsIHBvcnQp
Ow0KPiBAQCAtMjE5Miw3ICsyMTkyLDcgQEAgc3RhdGljIGludCBtbHg0X2liX2FsbG9jX2RlbXV4
X2N0eChzdHJ1Y3QgbWx4NF9pYl9kZXYgKmRldiwNCj4gICAgICAgIGdvdG8gZXJyX3dxOw0KPiAg
ICB9DQo+IA0KPiAtICAgIHNucHJpbnRmKG5hbWUsIHNpemVvZiBuYW1lLCAibWx4NF9pYnVkJWQi
LCBwb3J0KTsNCj4gKyAgICBzbnByaW50ZihuYW1lLCBzaXplb2YobmFtZSksICJtbHg0X2lidWQl
ZCIsIHBvcnQpOw0KPiAgICBjdHgtPnVkX3dxID0gYWxsb2Nfb3JkZXJlZF93b3JrcXVldWUobmFt
ZSwgV1FfTUVNX1JFQ0xBSU0pOw0KPiAgICBpZiAoIWN0eC0+dWRfd3EpIHsNCj4gICAgICAgIHBy
X2VycigiRmFpbGVkIHRvIGNyZWF0ZSB1cC9kb3duIFdRIGZvciBwb3J0ICVkXG4iLCBwb3J0KTsN
Cj4gLS0gDQo+IDIuMTEuMQ0KPiANCj4gLS0NCj4gVG8gdW5zdWJzY3JpYmUgZnJvbSB0aGlzIGxp
c3Q6IHNlbmQgdGhlIGxpbmUgInVuc3Vic2NyaWJlIGxpbnV4LXJkbWEiIGluDQo+IHRoZSBib2R5
IG9mIGEgbWVzc2FnZSB0byBtYWpvcmRvbW9Admdlci5rZXJuZWwub3JnDQo+IE1vcmUgbWFqb3Jk
b21vIGluZm8gYXQgIGh0dHA6Ly92Z2VyLmtlcm5lbC5vcmcvbWFqb3Jkb21vLWluZm8uaHRtbA0K
VGhhbmtzLA0KUmV2aWV3ZWQtYnk6IE1hamQgRGliYmlueQ0KPG1hamRAbWVsbGFub3guY29tPg=

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

* Re: [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add()
  2017-02-18 21:05     ` SF Markus Elfring
  (?)
  (?)
@ 2017-02-19 17:36     ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:06 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 15:43:54 +0100
> 
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index b78f17623121..f3194f2a6e62 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2825,9 +2825,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>    }
>    if (mlx4_is_bonded(dev))
>        for (i = 1; i < ibdev->num_ports ; ++i) {
> -            new_counter_index =
> -                    kmalloc(sizeof(struct counter_index),
> -                        GFP_KERNEL);
> +            new_counter_index = kmalloc(sizeof(*new_counter_index),
> +                            GFP_KERNEL);
>            if (!new_counter_index)
>                goto err_counter;
>            new_counter_index->index = counter_index;
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add()
  2017-02-18 21:05     ` SF Markus Elfring
  (?)
@ 2017-02-19 17:36         ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 11:06 PM, SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5ug@public.gmane.orge.net> wrote:
> 
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sat, 18 Feb 2017 15:43:54 +0100
> 
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> ---
> drivers/infiniband/hw/mlx4/main.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index b78f17623121..f3194f2a6e62 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2825,9 +2825,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>    }
>    if (mlx4_is_bonded(dev))
>        for (i = 1; i < ibdev->num_ports ; ++i) {
> -            new_counter_index =
> -                    kmalloc(sizeof(struct counter_index),
> -                        GFP_KERNEL);
> +            new_counter_index = kmalloc(sizeof(*new_counter_index),
> +                            GFP_KERNEL);
>            if (!new_counter_index)
>                goto err_counter;
>            new_counter_index->index = counter_index;
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>--
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] 179+ messages in thread

* Re: [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add()
@ 2017-02-19 17:36         ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:06 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 15:43:54 +0100
> 
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index b78f17623121..f3194f2a6e62 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2825,9 +2825,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>    }
>    if (mlx4_is_bonded(dev))
>        for (i = 1; i < ibdev->num_ports ; ++i) {
> -            new_counter_index =
> -                    kmalloc(sizeof(struct counter_index),
> -                        GFP_KERNEL);
> +            new_counter_index = kmalloc(sizeof(*new_counter_index),
> +                            GFP_KERNEL);
>            if (!new_counter_index)
>                goto err_counter;
>            new_counter_index->index = counter_index;
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add()
@ 2017-02-19 17:36         ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 11:06 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 15:43:54 +0100
> 
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index b78f17623121..f3194f2a6e62 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2825,9 +2825,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>    }
>    if (mlx4_is_bonded(dev))
>        for (i = 1; i < ibdev->num_ports ; ++i) {
> -            new_counter_index =
> -                    kmalloc(sizeof(struct counter_index),
> -                        GFP_KERNEL);
> +            new_counter_index = kmalloc(sizeof(*new_counter_index),
> +                            GFP_KERNEL);
>            if (!new_counter_index)
>                goto err_counter;
>            new_counter_index->index = counter_index;
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 15/29] IB/mlx4: Delete an unnecessary return statement in do_slave_init()
  2017-02-18 21:03   ` SF Markus Elfring
  (?)
@ 2017-02-19 17:36   ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 17:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:04 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 15:16:54 +0100
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> WARNING: void function return statements are not generally useful
> 
> Thus remove such a statement here.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 1 -
> 1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 89bbb61d62f5..b2b472977a39 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -3131,7 +3131,6 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
>    }
> out:
>    kfree(dm);
> -    return;
> }
> 
> static void mlx4_ib_handle_catas_error(struct mlx4_ib_dev *ibdev)
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add()
  2017-02-18 21:08     ` SF Markus Elfring
  (?)
@ 2017-02-19 19:42         ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:42 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 11:09 PM, SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5ug@public.gmane.orge.net> wrote:
> 
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sat, 18 Feb 2017 16:00:28 +0100
> 
> Delete an assignment for the local variable "num_ports" at the beginning
> because it was initialised with the same value.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> ---
> drivers/infiniband/hw/mlx4/main.c | 2 --
> 1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 4e08e4d57181..21b88d5ceda4 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2615,8 +2615,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>    struct counter_index *new_counter_index;
> 
>    pr_info_once("%s", mlx4_ib_version);
> -
> -    num_ports = 0;
>    mlx4_foreach_ib_transport_port(i, dev)
>        num_ports++;
> 
> -- 
> 2.11.1
> 
> --
> 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

Thanks,
Reviewed-by: Majd Dibbiny
<majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

--
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] 179+ messages in thread

* Re: [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add()
@ 2017-02-19 19:42         ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:42 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:09 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:00:28 +0100
> 
> Delete an assignment for the local variable "num_ports" at the beginning
> because it was initialised with the same value.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 2 --
> 1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 4e08e4d57181..21b88d5ceda4 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2615,8 +2615,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>    struct counter_index *new_counter_index;
> 
>    pr_info_once("%s", mlx4_ib_version);
> -
> -    num_ports = 0;
>    mlx4_foreach_ib_transport_port(i, dev)
>        num_ports++;
> 
> -- 
> 2.11.1
> 
> --
> 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

Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add()
@ 2017-02-19 19:42         ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:42 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 11:09 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:00:28 +0100
> 
> Delete an assignment for the local variable "num_ports" at the beginning
> because it was initialised with the same value.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 2 --
> 1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 4e08e4d57181..21b88d5ceda4 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2615,8 +2615,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>    struct counter_index *new_counter_index;
> 
>    pr_info_once("%s", mlx4_ib_version);
> -
> -    num_ports = 0;
>    mlx4_foreach_ib_transport_port(i, dev)
>        num_ports++;
> 
> -- 
> 2.11.1
> 
> --
> 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

Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>


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

* Re: [PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add()
  2017-02-18 21:10     ` SF Markus Elfring
  (?)
  (?)
@ 2017-02-19 19:48     ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors,
	Wolfram Sang


> On Feb 18, 2017, at 11:10 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:15:20 +0100
> 
> Omit an extra message for a memory allocation failure in this function.
> 
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 21b88d5ceda4..33b46c463ffa 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2623,11 +2623,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>        return NULL;
> 
>    ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
> -    if (!ibdev) {
> -        dev_err(&dev->persist->pdev->dev,
> -            "Device struct alloc failed\n");
> +    if (!ibdev)
>        return NULL;
> -    }
Not a big fan of this change.
9 out of the 15 drivers have this print in case of a failure..
> 
>    iboe = &ibdev->iboe;
> 
> -- 
> 2.11.1
> 
> --
> 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] 179+ messages in thread

* Re: [PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add()
  2017-02-18 21:11   ` SF Markus Elfring
  (?)
@ 2017-02-19 19:51       ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

> On Feb 18, 2017, at 11:12 PM, SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5ug@public.gmane.orge.net> wrote:
> 
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sat, 18 Feb 2017 16:32:41 +0100
> 
> Do not use curly brackets at one source code place
> where a single statement should be sufficient.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> ---
> drivers/infiniband/hw/mlx4/main.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 33b46c463ffa..b950538e036e 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2898,9 +2898,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>        }
>        if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
>            err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
> -            if (err) {
> +            if (err)
>                goto err_notif;
> -            }
>        }
>    }
> 
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

--
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] 179+ messages in thread

* Re: [PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add()
@ 2017-02-19 19:51       ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors

> On Feb 18, 2017, at 11:12 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:32:41 +0100
> 
> Do not use curly brackets at one source code place
> where a single statement should be sufficient.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 33b46c463ffa..b950538e036e 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2898,9 +2898,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>        }
>        if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
>            err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
> -            if (err) {
> +            if (err)
>                goto err_notif;
> -            }
>        }
>    }
> 
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add()
@ 2017-02-19 19:51       ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

> On Feb 18, 2017, at 11:12 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:32:41 +0100
> 
> Do not use curly brackets at one source code place
> where a single statement should be sufficient.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/main.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 33b46c463ffa..b950538e036e 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2898,9 +2898,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
>        }
>        if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
>            err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
> -            if (err) {
> +            if (err)
>                goto err_notif;
> -            }
>        }
>    }
> 
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>


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

* Re: [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs()
  2017-02-18 21:12     ` SF Markus Elfring
  (?)
@ 2017-02-19 19:53         ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:53 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 11:12 PM, SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5ug@public.gmane.orge.net> wrote:
> 
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sat, 18 Feb 2017 16:56:52 +0100
> 
> * A multiplication for the size determination of a memory allocation
>  indicated that an array data structure should be processed.
>  Thus use the corresponding function "kmalloc_array".
> 
>  This issue was detected by using the Coccinelle software.
> 
> * Replace the specification of a data structure by a pointer dereference
>  to make the corresponding size determination a bit safer according to
>  the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> ---
> drivers/infiniband/hw/mlx4/qp.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index 7d76f769233c..11fec4a8fae5 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
> {
>    int i;
> 
> -    qp->sqp_proxy_rcv =
> -        kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
> -            GFP_KERNEL);
> +    qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
> +                      sizeof(*qp->sqp_proxy_rcv),
> +                      GFP_KERNEL);
>    if (!qp->sqp_proxy_rcv)
>        return -ENOMEM;
>    for (i = 0; i < qp->rq.wqe_cnt; i++) {
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

--
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] 179+ messages in thread

* Re: [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs()
@ 2017-02-19 19:53         ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:53 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:12 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:56:52 +0100
> 
> * A multiplication for the size determination of a memory allocation
>  indicated that an array data structure should be processed.
>  Thus use the corresponding function "kmalloc_array".
> 
>  This issue was detected by using the Coccinelle software.
> 
> * Replace the specification of a data structure by a pointer dereference
>  to make the corresponding size determination a bit safer according to
>  the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/qp.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index 7d76f769233c..11fec4a8fae5 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
> {
>    int i;
> 
> -    qp->sqp_proxy_rcv =
> -        kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
> -            GFP_KERNEL);
> +    qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
> +                      sizeof(*qp->sqp_proxy_rcv),
> +                      GFP_KERNEL);
>    if (!qp->sqp_proxy_rcv)
>        return -ENOMEM;
>    for (i = 0; i < qp->rq.wqe_cnt; i++) {
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs()
@ 2017-02-19 19:53         ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:53 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 11:12 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 16:56:52 +0100
> 
> * A multiplication for the size determination of a memory allocation
>  indicated that an array data structure should be processed.
>  Thus use the corresponding function "kmalloc_array".
> 
>  This issue was detected by using the Coccinelle software.
> 
> * Replace the specification of a data structure by a pointer dereference
>  to make the corresponding size determination a bit safer according to
>  the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/qp.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index 7d76f769233c..11fec4a8fae5 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
> {
>    int i;
> 
> -    qp->sqp_proxy_rcv =
> -        kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
> -            GFP_KERNEL);
> +    qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
> +                      sizeof(*qp->sqp_proxy_rcv),
> +                      GFP_KERNEL);
>    if (!qp->sqp_proxy_rcv)
>        return -ENOMEM;
>    for (i = 0; i < qp->rq.wqe_cnt; i++) {
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>


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

* Re: [PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common()
  2017-02-18 21:13   ` SF Markus Elfring
  (?)
@ 2017-02-19 19:54       ` Majd Dibbiny
  -1 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:54 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 11:15 PM, SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5ug@public.gmane.orge.net> wrote:
> 
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sat, 18 Feb 2017 18:29:30 +0100
> 
> Replace the specification of two data structures by pointer dereferences
> as the parameter for the operator "sizeof" to make the corresponding size
> determinations a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> ---
> drivers/infiniband/hw/mlx4/qp.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index 11fec4a8fae5..cc7bd257a1fd 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
>        if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI ||
>            (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
>                MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
> -            sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
> +            sqp = kzalloc(sizeof(*sqp), gfp);
>            if (!sqp)
>                return -ENOMEM;
>            qp = &sqp->qp;
>            qp->pri.vid = 0xFFFF;
>            qp->alt.vid = 0xFFFF;
>        } else {
> -            qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
> +            qp = kzalloc(sizeof(*qp), gfp);
>            if (!qp)
>                return -ENOMEM;
>            qp->pri.vid = 0xFFFF;
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

--
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] 179+ messages in thread

* Re: [PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common()
@ 2017-02-19 19:54       ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:54 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas, LKML, kernel-janitors


> On Feb 18, 2017, at 11:15 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 18:29:30 +0100
> 
> Replace the specification of two data structures by pointer dereferences
> as the parameter for the operator "sizeof" to make the corresponding size
> determinations a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/qp.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index 11fec4a8fae5..cc7bd257a1fd 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
>        if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI ||
>            (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
>                MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
> -            sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
> +            sqp = kzalloc(sizeof(*sqp), gfp);
>            if (!sqp)
>                return -ENOMEM;
>            qp = &sqp->qp;
>            qp->pri.vid = 0xFFFF;
>            qp->alt.vid = 0xFFFF;
>        } else {
> -            qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
> +            qp = kzalloc(sizeof(*qp), gfp);
>            if (!qp)
>                return -ENOMEM;
>            qp->pri.vid = 0xFFFF;
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>

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

* Re: [PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common()
@ 2017-02-19 19:54       ` Majd Dibbiny
  0 siblings, 0 replies; 179+ messages in thread
From: Majd Dibbiny @ 2017-02-19 19:54 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Matan Barak, Sean Hefty, Yishai Hadas, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> On Feb 18, 2017, at 11:15 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 18:29:30 +0100
> 
> Replace the specification of two data structures by pointer dereferences
> as the parameter for the operator "sizeof" to make the corresponding size
> determinations a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/qp.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index 11fec4a8fae5..cc7bd257a1fd 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
>        if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI ||
>            (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
>                MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
> -            sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
> +            sqp = kzalloc(sizeof(*sqp), gfp);
>            if (!sqp)
>                return -ENOMEM;
>            qp = &sqp->qp;
>            qp->pri.vid = 0xFFFF;
>            qp->alt.vid = 0xFFFF;
>        } else {
> -            qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
> +            qp = kzalloc(sizeof(*qp), gfp);
>            if (!qp)
>                return -ENOMEM;
>            qp->pri.vid = 0xFFFF;
> -- 
> 2.11.1
> 
> --
> 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
Thanks,
Reviewed-by: Majd Dibbiny
<majd@mellanox.com>


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

* Re: [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations
  2017-02-18 20:45 ` SF Markus Elfring
  (?)
@ 2017-04-20 20:37     ` Doug Ledford
  -1 siblings, 0 replies; 179+ messages in thread
From: Doug Ledford @ 2017-04-20 20:37 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Hal Rosenstock, Leon Romanovsky, Matan Barak, Sean Hefty,
	Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Sat, 2017-02-18 at 21:45 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Sat, 18 Feb 2017 21:34:32 +0100
> 
> Several update suggestions were taken into account
> from static source code analysis.

I've dropped this entire series.  If you want me to consider it, you
need to respin it with the following changes:

1) Put all similar corrections in a single patch.  If you are replacing
a sizeof() usage with a safer sizeof() usage, then I don't want one
patch per replacement, I want one patch for all replacements.

2) Use reasonable git commit messages.  "Improve another" is never a
reasonable commit message because it implicitly refereces another git
commit message.  Unless this is a fix for a previous commit, all commit
messages should be standalone.

3) Keep your git commit message subject lines within the recommended
size.  You have many that are too long.  As trivial as all of these
changes are, I'm not going to go fixup 29 commit messages to take them.

4) Make sure to preserve the reviewed-by tags on the resubmission.

> Markus Elfring (29):
>   Use kcalloc() in mlx4_ib_alloc_pv_bufs()
>   Improve another size determination in mlx4_ib_alloc_pv_bufs()
>   Improve another size determination in mlx4_ib_alloc_demux_ctx()
>   Improve another size determination in alloc_pv_object()
>   Fix a typo in a comment line
>   Delete three unnecessary return statements
>   Split a condition check in handle_slaves_guid_change()
>   Delete an unnecessary check before the function call "kfree" in
> free_pv_object()
>   Move an assignment out of a check in forward_trap()
>   Enclose 15 expressions for the sizeof operator by parentheses
>   Use kmalloc_array() in three functions
>   Enclose 17 expressions for the sizeof operator by parentheses
>   Split a condition check in five functions
>   Delete an unnecessary variable in __mlx4_ib_query_gid()
>   Delete an unnecessary return statement in do_slave_init()
>   Improve another size determination in do_slave_init()
>   Improve another size determination in mlx4_ib_add()
>   Delete an unnecessary variable initialisation in mlx4_ib_add()
>   Delete an unnecessary variable assignment in mlx4_ib_add()
>   Delete an error message for a failed memory allocation in
> mlx4_ib_add()
>   Delete unnecessary braces in mlx4_ib_add()
>   Use kmalloc_array() in alloc_proxy_bufs()
>   Improve size determinations in create_qp_common()
>   Delete unwanted spaces behind usages of the sizeof operator
>   Add spaces for better code readability
>   Enclose 14 expressions for the sizeof operator by parentheses
>   Use kmalloc_array() in create_kernel_qp()
>   Less function calls in create_kernel_qp() after error detection
>   Use kmalloc_array() in create_srq_kernel()
> 
>  drivers/infiniband/hw/mlx4/mad.c  |  72 ++++++++--------
>  drivers/infiniband/hw/mlx4/main.c | 164 ++++++++++++++++++++------
> ----------
>  drivers/infiniband/hw/mlx4/qp.c   | 173 +++++++++++++++++++---------
> ----------
>  drivers/infiniband/hw/mlx5/qp.c   |  66 ++++++++++-----
>  drivers/infiniband/hw/mlx5/srq.c  |   5 +-
>  5 files changed, 261 insertions(+), 219 deletions(-)
> 
-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

--
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] 179+ messages in thread

* Re: [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations
@ 2017-04-20 20:37     ` Doug Ledford
  0 siblings, 0 replies; 179+ messages in thread
From: Doug Ledford @ 2017-04-20 20:37 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

On Sat, 2017-02-18 at 21:45 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 21:34:32 +0100
> 
> Several update suggestions were taken into account
> from static source code analysis.

I've dropped this entire series.  If you want me to consider it, you
need to respin it with the following changes:

1) Put all similar corrections in a single patch.  If you are replacing
a sizeof() usage with a safer sizeof() usage, then I don't want one
patch per replacement, I want one patch for all replacements.

2) Use reasonable git commit messages.  "Improve another" is never a
reasonable commit message because it implicitly refereces another git
commit message.  Unless this is a fix for a previous commit, all commit
messages should be standalone.

3) Keep your git commit message subject lines within the recommended
size.  You have many that are too long.  As trivial as all of these
changes are, I'm not going to go fixup 29 commit messages to take them.

4) Make sure to preserve the reviewed-by tags on the resubmission.

> Markus Elfring (29):
>   Use kcalloc() in mlx4_ib_alloc_pv_bufs()
>   Improve another size determination in mlx4_ib_alloc_pv_bufs()
>   Improve another size determination in mlx4_ib_alloc_demux_ctx()
>   Improve another size determination in alloc_pv_object()
>   Fix a typo in a comment line
>   Delete three unnecessary return statements
>   Split a condition check in handle_slaves_guid_change()
>   Delete an unnecessary check before the function call "kfree" in
> free_pv_object()
>   Move an assignment out of a check in forward_trap()
>   Enclose 15 expressions for the sizeof operator by parentheses
>   Use kmalloc_array() in three functions
>   Enclose 17 expressions for the sizeof operator by parentheses
>   Split a condition check in five functions
>   Delete an unnecessary variable in __mlx4_ib_query_gid()
>   Delete an unnecessary return statement in do_slave_init()
>   Improve another size determination in do_slave_init()
>   Improve another size determination in mlx4_ib_add()
>   Delete an unnecessary variable initialisation in mlx4_ib_add()
>   Delete an unnecessary variable assignment in mlx4_ib_add()
>   Delete an error message for a failed memory allocation in
> mlx4_ib_add()
>   Delete unnecessary braces in mlx4_ib_add()
>   Use kmalloc_array() in alloc_proxy_bufs()
>   Improve size determinations in create_qp_common()
>   Delete unwanted spaces behind usages of the sizeof operator
>   Add spaces for better code readability
>   Enclose 14 expressions for the sizeof operator by parentheses
>   Use kmalloc_array() in create_kernel_qp()
>   Less function calls in create_kernel_qp() after error detection
>   Use kmalloc_array() in create_srq_kernel()
> 
>  drivers/infiniband/hw/mlx4/mad.c  |  72 ++++++++--------
>  drivers/infiniband/hw/mlx4/main.c | 164 ++++++++++++++++++++------
> ----------
>  drivers/infiniband/hw/mlx4/qp.c   | 173 +++++++++++++++++++---------
> ----------
>  drivers/infiniband/hw/mlx5/qp.c   |  66 ++++++++++-----
>  drivers/infiniband/hw/mlx5/srq.c  |   5 +-
>  5 files changed, 261 insertions(+), 219 deletions(-)
> 
-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

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

* Re: [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations
@ 2017-04-20 20:37     ` Doug Ledford
  0 siblings, 0 replies; 179+ messages in thread
From: Doug Ledford @ 2017-04-20 20:37 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Hal Rosenstock, Leon Romanovsky, Matan Barak, Sean Hefty,
	Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Sat, 2017-02-18 at 21:45 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 18 Feb 2017 21:34:32 +0100
> 
> Several update suggestions were taken into account
> from static source code analysis.

I've dropped this entire series.  If you want me to consider it, you
need to respin it with the following changes:

1) Put all similar corrections in a single patch.  If you are replacing
a sizeof() usage with a safer sizeof() usage, then I don't want one
patch per replacement, I want one patch for all replacements.

2) Use reasonable git commit messages.  "Improve another" is never a
reasonable commit message because it implicitly refereces another git
commit message.  Unless this is a fix for a previous commit, all commit
messages should be standalone.

3) Keep your git commit message subject lines within the recommended
size.  You have many that are too long.  As trivial as all of these
changes are, I'm not going to go fixup 29 commit messages to take them.

4) Make sure to preserve the reviewed-by tags on the resubmission.

> Markus Elfring (29):
>   Use kcalloc() in mlx4_ib_alloc_pv_bufs()
>   Improve another size determination in mlx4_ib_alloc_pv_bufs()
>   Improve another size determination in mlx4_ib_alloc_demux_ctx()
>   Improve another size determination in alloc_pv_object()
>   Fix a typo in a comment line
>   Delete three unnecessary return statements
>   Split a condition check in handle_slaves_guid_change()
>   Delete an unnecessary check before the function call "kfree" in
> free_pv_object()
>   Move an assignment out of a check in forward_trap()
>   Enclose 15 expressions for the sizeof operator by parentheses
>   Use kmalloc_array() in three functions
>   Enclose 17 expressions for the sizeof operator by parentheses
>   Split a condition check in five functions
>   Delete an unnecessary variable in __mlx4_ib_query_gid()
>   Delete an unnecessary return statement in do_slave_init()
>   Improve another size determination in do_slave_init()
>   Improve another size determination in mlx4_ib_add()
>   Delete an unnecessary variable initialisation in mlx4_ib_add()
>   Delete an unnecessary variable assignment in mlx4_ib_add()
>   Delete an error message for a failed memory allocation in
> mlx4_ib_add()
>   Delete unnecessary braces in mlx4_ib_add()
>   Use kmalloc_array() in alloc_proxy_bufs()
>   Improve size determinations in create_qp_common()
>   Delete unwanted spaces behind usages of the sizeof operator
>   Add spaces for better code readability
>   Enclose 14 expressions for the sizeof operator by parentheses
>   Use kmalloc_array() in create_kernel_qp()
>   Less function calls in create_kernel_qp() after error detection
>   Use kmalloc_array() in create_srq_kernel()
> 
>  drivers/infiniband/hw/mlx4/mad.c  |  72 ++++++++--------
>  drivers/infiniband/hw/mlx4/main.c | 164 ++++++++++++++++++++------
> ----------
>  drivers/infiniband/hw/mlx4/qp.c   | 173 +++++++++++++++++++---------
> ----------
>  drivers/infiniband/hw/mlx5/qp.c   |  66 ++++++++++-----
>  drivers/infiniband/hw/mlx5/srq.c  |   5 +-
>  5 files changed, 261 insertions(+), 219 deletions(-)
> 
-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


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

* Re: [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations
  2017-04-20 20:37     ` Doug Ledford
@ 2017-04-20 21:02       ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-20 21:02 UTC (permalink / raw)
  To: Doug Ledford, linux-rdma, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

> I've dropped this entire series.  If you want me to consider it, you
> need to respin it with the following changes:

How do you think about to integrate any of my update suggestions
which you do not find controversial (or questionable) at the moment?


> 1) Put all similar corrections in a single patch.

I preferred an other patch granularity so far.

Regards,
Markus

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

* Re: [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations
@ 2017-04-20 21:02       ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-20 21:02 UTC (permalink / raw)
  To: Doug Ledford, linux-rdma, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

> I've dropped this entire series.  If you want me to consider it, you
> need to respin it with the following changes:

How do you think about to integrate any of my update suggestions
which you do not find controversial (or questionable) at the moment?


> 1) Put all similar corrections in a single patch.

I preferred an other patch granularity so far.

Regards,
Markus

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

* Re: [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations
  2017-04-20 21:02       ` SF Markus Elfring
  (?)
@ 2017-04-21  2:23           ` Doug Ledford
  -1 siblings, 0 replies; 179+ messages in thread
From: Doug Ledford @ 2017-04-21  2:23 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Hal Rosenstock, Leon Romanovsky, Matan Barak, Sean Hefty,
	Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Thu, 2017-04-20 at 23:02 +0200, SF Markus Elfring wrote:
> > 
> > I've dropped this entire series.  If you want me to consider it,
> > you
> > need to respin it with the following changes:
> 
> How do you think about to integrate any of my update suggestions
> which you do not find controversial (or questionable) at the moment?

No.  Far too many of your patches need commit messages fixes and the
like.  If you want me to include them, then follow all of the
requirements I gave you.

> 
> > 
> > 1) Put all similar corrections in a single patch.
> 
> I preferred an other patch granularity so far.

Not to be too blunt about it, but your preference is not the one that
matters in this situation.  If you want me to consider the patches,
then you need to respin them following the directions I gave.

-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

--
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] 179+ messages in thread

* Re: [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations
@ 2017-04-21  2:23           ` Doug Ledford
  0 siblings, 0 replies; 179+ messages in thread
From: Doug Ledford @ 2017-04-21  2:23 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, Hal Rosenstock, Leon Romanovsky,
	Matan Barak, Sean Hefty, Yishai Hadas
  Cc: LKML, kernel-janitors

On Thu, 2017-04-20 at 23:02 +0200, SF Markus Elfring wrote:
> > 
> > I've dropped this entire series.  If you want me to consider it,
> > you
> > need to respin it with the following changes:
> 
> How do you think about to integrate any of my update suggestions
> which you do not find controversial (or questionable) at the moment?

No.  Far too many of your patches need commit messages fixes and the
like.  If you want me to include them, then follow all of the
requirements I gave you.

> 
> > 
> > 1) Put all similar corrections in a single patch.
> 
> I preferred an other patch granularity so far.

Not to be too blunt about it, but your preference is not the one that
matters in this situation.  If you want me to consider the patches,
then you need to respin them following the directions I gave.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

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

* Re: [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations
@ 2017-04-21  2:23           ` Doug Ledford
  0 siblings, 0 replies; 179+ messages in thread
From: Doug Ledford @ 2017-04-21  2:23 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Hal Rosenstock, Leon Romanovsky, Matan Barak, Sean Hefty,
	Yishai Hadas
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Thu, 2017-04-20 at 23:02 +0200, SF Markus Elfring wrote:
> > 
> > I've dropped this entire series.  If you want me to consider it,
> > you
> > need to respin it with the following changes:
> 
> How do you think about to integrate any of my update suggestions
> which you do not find controversial (or questionable) at the moment?

No.  Far too many of your patches need commit messages fixes and the
like.  If you want me to include them, then follow all of the
requirements I gave you.

> 
> > 
> > 1) Put all similar corrections in a single patch.
> 
> I preferred an other patch granularity so far.

Not to be too blunt about it, but your preference is not the one that
matters in this situation.  If you want me to consider the patches,
then you need to respin them following the directions I gave.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


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

* [PATCH v2 00/17] IB/mlx: Fine-tuning for several function implementations
  2017-04-20 20:37     ` Doug Ledford
@ 2017-04-21 18:17       ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:17 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 19:56:54 +0200

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

Markus Elfring (17):
  Use kcalloc() in mlx4_ib_alloc_pv_bufs()
  Use kmalloc_array() in six functions
  Improve size determinations in six functions
  Fix a typo in a comment line
  Delete four unnecessary return statements
  Delete an unnecessary check before kfree() in free_pv_object()
  Move an assignment out of a check in forward_trap()
  Enclose 46 expressions for sizeof by parentheses
  Split a condition check in six functions
  Delete an unnecessary variable in __mlx4_ib_query_gid()
  Delete an unnecessary variable initialisation in mlx4_ib_add()
  Delete an unnecessary variable assignment in mlx4_ib_add()
  Delete an error message for a failed memory allocation in mlx4_ib_add()
  Delete unnecessary braces in mlx4_ib_add()
  Delete unwanted spaces behind usages of the sizeof operator
  Add spaces for better code readability
  Less function calls in create_kernel_qp() after error detection
---

v2:
Changes were rebased on source files from Linux next-20170421.
Some of them were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  |  72 ++++++++--------
 drivers/infiniband/hw/mlx4/main.c | 164 ++++++++++++++++++++----------------
 drivers/infiniband/hw/mlx4/qp.c   | 173 +++++++++++++++++++-------------------
 drivers/infiniband/hw/mlx5/qp.c   |  66 ++++++++++-----
 drivers/infiniband/hw/mlx5/srq.c  |   5 +-
 5 files changed, 261 insertions(+), 219 deletions(-)

-- 
2.12.2


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

* [PATCH v2 00/17] IB/mlx: Fine-tuning for several function implementations
@ 2017-04-21 18:17       ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:17 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 19:56:54 +0200

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

Markus Elfring (17):
  Use kcalloc() in mlx4_ib_alloc_pv_bufs()
  Use kmalloc_array() in six functions
  Improve size determinations in six functions
  Fix a typo in a comment line
  Delete four unnecessary return statements
  Delete an unnecessary check before kfree() in free_pv_object()
  Move an assignment out of a check in forward_trap()
  Enclose 46 expressions for sizeof by parentheses
  Split a condition check in six functions
  Delete an unnecessary variable in __mlx4_ib_query_gid()
  Delete an unnecessary variable initialisation in mlx4_ib_add()
  Delete an unnecessary variable assignment in mlx4_ib_add()
  Delete an error message for a failed memory allocation in mlx4_ib_add()
  Delete unnecessary braces in mlx4_ib_add()
  Delete unwanted spaces behind usages of the sizeof operator
  Add spaces for better code readability
  Less function calls in create_kernel_qp() after error detection
---

v2:
Changes were rebased on source files from Linux next-20170421.
Some of them were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  |  72 ++++++++--------
 drivers/infiniband/hw/mlx4/main.c | 164 ++++++++++++++++++++----------------
 drivers/infiniband/hw/mlx4/qp.c   | 173 +++++++++++++++++++-------------------
 drivers/infiniband/hw/mlx5/qp.c   |  66 ++++++++++-----
 drivers/infiniband/hw/mlx5/srq.c  |   5 +-
 5 files changed, 261 insertions(+), 219 deletions(-)

-- 
2.12.2


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

* [PATCH v2 01/17] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs()
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:21         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:21 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 10:21:01 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
---
 drivers/infiniband/hw/mlx4/mad.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index db564ccc0f92..61bd81baeb29 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1600,8 +1600,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -EINVAL;
 
 	tun_qp = &ctx->qp[qp_type];
-
-	tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS,
+	tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
+			       sizeof(*tun_qp->ring),
 			       GFP_KERNEL);
 	if (!tun_qp->ring)
 		return -ENOMEM;
-- 
2.12.2

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

* [PATCH v2 01/17] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs()
@ 2017-04-21 18:21         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:21 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 10:21:01 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
---
 drivers/infiniband/hw/mlx4/mad.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index db564ccc0f92..61bd81baeb29 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1600,8 +1600,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -EINVAL;
 
 	tun_qp = &ctx->qp[qp_type];
-
-	tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS,
+	tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
+			       sizeof(*tun_qp->ring),
 			       GFP_KERNEL);
 	if (!tun_qp->ring)
 		return -ENOMEM;
-- 
2.12.2


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

* [PATCH v2 02/17] IB/mlx: Use kmalloc_array() in six functions
  2017-04-21 18:17       ` SF Markus Elfring
  (?)
@ 2017-04-21 18:24           ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:24 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 21 Apr 2017 10:45:49 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/main.c | 14 +++++++++-----
 drivers/infiniband/hw/mlx4/qp.c   |  6 +++---
 drivers/infiniband/hw/mlx5/qp.c   | 21 +++++++++++++++------
 drivers/infiniband/hw/mlx5/srq.c  |  5 +++--
 4 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index fba94df28cf1..30a70fa95fec 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -307,7 +307,9 @@ static int mlx4_ib_add_gid(struct ib_device *device,
 		ctx->refcount++;
 	}
 	if (!ret && hw_update) {
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -362,7 +364,9 @@ static int mlx4_ib_del_gid(struct ib_device *device,
 	if (!ret && hw_update) {
 		int i;
 
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -2831,9 +2835,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 			goto err_counter;
 
 		ibdev->ib_uc_qpns_bitmap =
-			kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
-				sizeof(long),
-				GFP_KERNEL);
+			kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
+				      sizeof(long),
+				      GFP_KERNEL);
 		if (!ibdev->ib_uc_qpns_bitmap)
 			goto err_steer_qp_release;
 
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index c34eebc7db65..1d9d949c66d0 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 {
 	int i;
 
-	qp->sqp_proxy_rcv =
-		kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
-			GFP_KERNEL);
+	qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
+					  sizeof(*qp->sqp_proxy_rcv),
+					  GFP_KERNEL);
 	if (!qp->sqp_proxy_rcv)
 		return -ENOMEM;
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index ed6320186f89..1e98a8c9fab8 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -959,12 +959,21 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 		goto err_free;
 	}
 
-	qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL);
-	qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL);
-	qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL);
-	qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL);
-	qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL);
-
+	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
+				    sizeof(*qp->sq.wrid),
+				    GFP_KERNEL);
+	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
+				       sizeof(*qp->sq.wr_data),
+				       GFP_KERNEL);
+	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
+				    sizeof(*qp->rq.wrid),
+				    GFP_KERNEL);
+	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
+				      sizeof(*qp->sq.w_list),
+				      GFP_KERNEL);
+	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
+					sizeof(*qp->sq.wqe_head),
+					GFP_KERNEL);
 	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
 	    !qp->sq.w_list || !qp->sq.wqe_head) {
 		err = -ENOMEM;
diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
index 7cb145f9a6db..8ba1953177af 100644
--- a/drivers/infiniband/hw/mlx5/srq.c
+++ b/drivers/infiniband/hw/mlx5/srq.c
@@ -195,8 +195,9 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 		goto err_buf;
 	}
 	mlx5_fill_page_array(&srq->buf, in->pas);
-
-	srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL);
+	srq->wrid = kmalloc_array(srq->msrq.max,
+				  sizeof(*srq->wrid),
+				  GFP_KERNEL);
 	if (!srq->wrid) {
 		err = -ENOMEM;
 		goto err_in;
-- 
2.12.2

--
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] 179+ messages in thread

* [PATCH v2 02/17] IB/mlx: Use kmalloc_array() in six functions
@ 2017-04-21 18:24           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:24 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 10:45:49 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/main.c | 14 +++++++++-----
 drivers/infiniband/hw/mlx4/qp.c   |  6 +++---
 drivers/infiniband/hw/mlx5/qp.c   | 21 +++++++++++++++------
 drivers/infiniband/hw/mlx5/srq.c  |  5 +++--
 4 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index fba94df28cf1..30a70fa95fec 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -307,7 +307,9 @@ static int mlx4_ib_add_gid(struct ib_device *device,
 		ctx->refcount++;
 	}
 	if (!ret && hw_update) {
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -362,7 +364,9 @@ static int mlx4_ib_del_gid(struct ib_device *device,
 	if (!ret && hw_update) {
 		int i;
 
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -2831,9 +2835,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 			goto err_counter;
 
 		ibdev->ib_uc_qpns_bitmap =
-			kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
-				sizeof(long),
-				GFP_KERNEL);
+			kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
+				      sizeof(long),
+				      GFP_KERNEL);
 		if (!ibdev->ib_uc_qpns_bitmap)
 			goto err_steer_qp_release;
 
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index c34eebc7db65..1d9d949c66d0 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 {
 	int i;
 
-	qp->sqp_proxy_rcv =
-		kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
-			GFP_KERNEL);
+	qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
+					  sizeof(*qp->sqp_proxy_rcv),
+					  GFP_KERNEL);
 	if (!qp->sqp_proxy_rcv)
 		return -ENOMEM;
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index ed6320186f89..1e98a8c9fab8 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -959,12 +959,21 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 		goto err_free;
 	}
 
-	qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL);
-	qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL);
-	qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL);
-	qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL);
-	qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL);
-
+	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
+				    sizeof(*qp->sq.wrid),
+				    GFP_KERNEL);
+	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
+				       sizeof(*qp->sq.wr_data),
+				       GFP_KERNEL);
+	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
+				    sizeof(*qp->rq.wrid),
+				    GFP_KERNEL);
+	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
+				      sizeof(*qp->sq.w_list),
+				      GFP_KERNEL);
+	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
+					sizeof(*qp->sq.wqe_head),
+					GFP_KERNEL);
 	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
 	    !qp->sq.w_list || !qp->sq.wqe_head) {
 		err = -ENOMEM;
diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
index 7cb145f9a6db..8ba1953177af 100644
--- a/drivers/infiniband/hw/mlx5/srq.c
+++ b/drivers/infiniband/hw/mlx5/srq.c
@@ -195,8 +195,9 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 		goto err_buf;
 	}
 	mlx5_fill_page_array(&srq->buf, in->pas);
-
-	srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL);
+	srq->wrid = kmalloc_array(srq->msrq.max,
+				  sizeof(*srq->wrid),
+				  GFP_KERNEL);
 	if (!srq->wrid) {
 		err = -ENOMEM;
 		goto err_in;
-- 
2.12.2

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

* [PATCH v2 02/17] IB/mlx: Use kmalloc_array() in six functions
@ 2017-04-21 18:24           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:24 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 10:45:49 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/main.c | 14 +++++++++-----
 drivers/infiniband/hw/mlx4/qp.c   |  6 +++---
 drivers/infiniband/hw/mlx5/qp.c   | 21 +++++++++++++++------
 drivers/infiniband/hw/mlx5/srq.c  |  5 +++--
 4 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index fba94df28cf1..30a70fa95fec 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -307,7 +307,9 @@ static int mlx4_ib_add_gid(struct ib_device *device,
 		ctx->refcount++;
 	}
 	if (!ret && hw_update) {
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -362,7 +364,9 @@ static int mlx4_ib_del_gid(struct ib_device *device,
 	if (!ret && hw_update) {
 		int i;
 
-		gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+		gids = kmalloc_array(MLX4_MAX_PORT_GIDS,
+				     sizeof(*gids),
+				     GFP_ATOMIC);
 		if (!gids) {
 			ret = -ENOMEM;
 		} else {
@@ -2831,9 +2835,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 			goto err_counter;
 
 		ibdev->ib_uc_qpns_bitmap -			kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
-				sizeof(long),
-				GFP_KERNEL);
+			kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
+				      sizeof(long),
+				      GFP_KERNEL);
 		if (!ibdev->ib_uc_qpns_bitmap)
 			goto err_steer_qp_release;
 
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index c34eebc7db65..1d9d949c66d0 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 {
 	int i;
 
-	qp->sqp_proxy_rcv -		kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
-			GFP_KERNEL);
+	qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt,
+					  sizeof(*qp->sqp_proxy_rcv),
+					  GFP_KERNEL);
 	if (!qp->sqp_proxy_rcv)
 		return -ENOMEM;
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index ed6320186f89..1e98a8c9fab8 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -959,12 +959,21 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 		goto err_free;
 	}
 
-	qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL);
-	qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL);
-	qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL);
-	qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL);
-	qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL);
-
+	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
+				    sizeof(*qp->sq.wrid),
+				    GFP_KERNEL);
+	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
+				       sizeof(*qp->sq.wr_data),
+				       GFP_KERNEL);
+	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
+				    sizeof(*qp->rq.wrid),
+				    GFP_KERNEL);
+	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
+				      sizeof(*qp->sq.w_list),
+				      GFP_KERNEL);
+	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
+					sizeof(*qp->sq.wqe_head),
+					GFP_KERNEL);
 	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
 	    !qp->sq.w_list || !qp->sq.wqe_head) {
 		err = -ENOMEM;
diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
index 7cb145f9a6db..8ba1953177af 100644
--- a/drivers/infiniband/hw/mlx5/srq.c
+++ b/drivers/infiniband/hw/mlx5/srq.c
@@ -195,8 +195,9 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 		goto err_buf;
 	}
 	mlx5_fill_page_array(&srq->buf, in->pas);
-
-	srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL);
+	srq->wrid = kmalloc_array(srq->msrq.max,
+				  sizeof(*srq->wrid),
+				  GFP_KERNEL);
 	if (!srq->wrid) {
 		err = -ENOMEM;
 		goto err_in;
-- 
2.12.2


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

* [PATCH v2 03/17] IB/mlx4: Improve size determinations in six functions
  2017-04-21 18:17       ` SF Markus Elfring
  (?)
@ 2017-04-21 18:28           ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:28 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 21 Apr 2017 11:33:43 +0200

Replace the specification of data types by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determinations a bit safer according to the Linux coding style convention.

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

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  | 6 +++---
 drivers/infiniband/hw/mlx4/main.c | 7 +++----
 drivers/infiniband/hw/mlx4/qp.c   | 4 ++--
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 61bd81baeb29..ea4892b0f39e 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1607,7 +1607,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -ENOMEM;
 
 	tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
-				  sizeof (struct mlx4_ib_tun_tx_buf),
+				  sizeof(*tun_qp->tx_ring),
 				  GFP_KERNEL);
 	if (!tun_qp->tx_ring) {
 		kfree(tun_qp->ring);
@@ -1948,7 +1948,7 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
 	struct mlx4_ib_demux_pv_ctx *ctx;
 
 	*ret_ctx = NULL;
-	ctx = kzalloc(sizeof (struct mlx4_ib_demux_pv_ctx), GFP_KERNEL);
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;
 
@@ -2150,7 +2150,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 	int i;
 
 	ctx->tun = kcalloc(dev->dev->caps.sqp_demux,
-			   sizeof (struct mlx4_ib_demux_pv_ctx *), GFP_KERNEL);
+			   sizeof(*ctx->tun), GFP_KERNEL);
 	if (!ctx->tun)
 		return -ENOMEM;
 
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 30a70fa95fec..0ac670765466 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2804,9 +2804,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	}
 	if (mlx4_is_bonded(dev))
 		for (i = 1; i < ibdev->num_ports ; ++i) {
-			new_counter_index =
-					kmalloc(sizeof(struct counter_index),
-						GFP_KERNEL);
+			new_counter_index = kmalloc(sizeof(*new_counter_index),
+						    GFP_KERNEL);
 			if (!new_counter_index)
 				goto err_counter;
 			new_counter_index->index = counter_index;
@@ -3085,7 +3084,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		return;
 
 	for (i = 0; i < ports; i++) {
-		dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC);
+		dm[i] = kmalloc(sizeof(*dm[i]), GFP_ATOMIC);
 		if (!dm[i]) {
 			while (--i >= 0)
 				kfree(dm[i]);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 1d9d949c66d0..9269cd503443 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
 		if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI ||
 		    (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
 				MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
-			sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
+			sqp = kzalloc(sizeof(*sqp), gfp);
 			if (!sqp)
 				return -ENOMEM;
 			qp = &sqp->qp;
 			qp->pri.vid = 0xFFFF;
 			qp->alt.vid = 0xFFFF;
 		} else {
-			qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
+			qp = kzalloc(sizeof(*qp), gfp);
 			if (!qp)
 				return -ENOMEM;
 			qp->pri.vid = 0xFFFF;
-- 
2.12.2

--
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] 179+ messages in thread

* [PATCH v2 03/17] IB/mlx4: Improve size determinations in six functions
@ 2017-04-21 18:28           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:28 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 11:33:43 +0200

Replace the specification of data types by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determinations a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  | 6 +++---
 drivers/infiniband/hw/mlx4/main.c | 7 +++----
 drivers/infiniband/hw/mlx4/qp.c   | 4 ++--
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 61bd81baeb29..ea4892b0f39e 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1607,7 +1607,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -ENOMEM;
 
 	tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
-				  sizeof (struct mlx4_ib_tun_tx_buf),
+				  sizeof(*tun_qp->tx_ring),
 				  GFP_KERNEL);
 	if (!tun_qp->tx_ring) {
 		kfree(tun_qp->ring);
@@ -1948,7 +1948,7 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
 	struct mlx4_ib_demux_pv_ctx *ctx;
 
 	*ret_ctx = NULL;
-	ctx = kzalloc(sizeof (struct mlx4_ib_demux_pv_ctx), GFP_KERNEL);
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;
 
@@ -2150,7 +2150,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 	int i;
 
 	ctx->tun = kcalloc(dev->dev->caps.sqp_demux,
-			   sizeof (struct mlx4_ib_demux_pv_ctx *), GFP_KERNEL);
+			   sizeof(*ctx->tun), GFP_KERNEL);
 	if (!ctx->tun)
 		return -ENOMEM;
 
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 30a70fa95fec..0ac670765466 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2804,9 +2804,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	}
 	if (mlx4_is_bonded(dev))
 		for (i = 1; i < ibdev->num_ports ; ++i) {
-			new_counter_index =
-					kmalloc(sizeof(struct counter_index),
-						GFP_KERNEL);
+			new_counter_index = kmalloc(sizeof(*new_counter_index),
+						    GFP_KERNEL);
 			if (!new_counter_index)
 				goto err_counter;
 			new_counter_index->index = counter_index;
@@ -3085,7 +3084,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		return;
 
 	for (i = 0; i < ports; i++) {
-		dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC);
+		dm[i] = kmalloc(sizeof(*dm[i]), GFP_ATOMIC);
 		if (!dm[i]) {
 			while (--i >= 0)
 				kfree(dm[i]);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 1d9d949c66d0..9269cd503443 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
 		if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI ||
 		    (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
 				MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
-			sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
+			sqp = kzalloc(sizeof(*sqp), gfp);
 			if (!sqp)
 				return -ENOMEM;
 			qp = &sqp->qp;
 			qp->pri.vid = 0xFFFF;
 			qp->alt.vid = 0xFFFF;
 		} else {
-			qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
+			qp = kzalloc(sizeof(*qp), gfp);
 			if (!qp)
 				return -ENOMEM;
 			qp->pri.vid = 0xFFFF;
-- 
2.12.2

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

* [PATCH v2 03/17] IB/mlx4: Improve size determinations in six functions
@ 2017-04-21 18:28           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:28 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 11:33:43 +0200

Replace the specification of data types by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determinations a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  | 6 +++---
 drivers/infiniband/hw/mlx4/main.c | 7 +++----
 drivers/infiniband/hw/mlx4/qp.c   | 4 ++--
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 61bd81baeb29..ea4892b0f39e 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1607,7 +1607,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 		return -ENOMEM;
 
 	tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
-				  sizeof (struct mlx4_ib_tun_tx_buf),
+				  sizeof(*tun_qp->tx_ring),
 				  GFP_KERNEL);
 	if (!tun_qp->tx_ring) {
 		kfree(tun_qp->ring);
@@ -1948,7 +1948,7 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
 	struct mlx4_ib_demux_pv_ctx *ctx;
 
 	*ret_ctx = NULL;
-	ctx = kzalloc(sizeof (struct mlx4_ib_demux_pv_ctx), GFP_KERNEL);
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;
 
@@ -2150,7 +2150,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 	int i;
 
 	ctx->tun = kcalloc(dev->dev->caps.sqp_demux,
-			   sizeof (struct mlx4_ib_demux_pv_ctx *), GFP_KERNEL);
+			   sizeof(*ctx->tun), GFP_KERNEL);
 	if (!ctx->tun)
 		return -ENOMEM;
 
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 30a70fa95fec..0ac670765466 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2804,9 +2804,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	}
 	if (mlx4_is_bonded(dev))
 		for (i = 1; i < ibdev->num_ports ; ++i) {
-			new_counter_index -					kmalloc(sizeof(struct counter_index),
-						GFP_KERNEL);
+			new_counter_index = kmalloc(sizeof(*new_counter_index),
+						    GFP_KERNEL);
 			if (!new_counter_index)
 				goto err_counter;
 			new_counter_index->index = counter_index;
@@ -3085,7 +3084,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		return;
 
 	for (i = 0; i < ports; i++) {
-		dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC);
+		dm[i] = kmalloc(sizeof(*dm[i]), GFP_ATOMIC);
 		if (!dm[i]) {
 			while (--i >= 0)
 				kfree(dm[i]);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 1d9d949c66d0..9269cd503443 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
 		if (qp_type = MLX4_IB_QPT_SMI || qp_type = MLX4_IB_QPT_GSI ||
 		    (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
 				MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
-			sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
+			sqp = kzalloc(sizeof(*sqp), gfp);
 			if (!sqp)
 				return -ENOMEM;
 			qp = &sqp->qp;
 			qp->pri.vid = 0xFFFF;
 			qp->alt.vid = 0xFFFF;
 		} else {
-			qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
+			qp = kzalloc(sizeof(*qp), gfp);
 			if (!qp)
 				return -ENOMEM;
 			qp->pri.vid = 0xFFFF;
-- 
2.12.2


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

* Re: [PATCH v2 00/17] IB/mlx: Fine-tuning for several function implementations
  2017-04-21 18:17       ` SF Markus Elfring
  (?)
  (?)
@ 2017-04-21 18:29       ` Bart Van Assche
  2017-04-21 19:21           ` SF Markus Elfring
  -1 siblings, 1 reply; 179+ messages in thread
From: Bart Van Assche @ 2017-04-21 18:29 UTC (permalink / raw)
  To: leonro, linux-rdma, yishaih, sean.hefty, elfring, majd,
	hal.rosenstock, dledford, matanb
  Cc: linux-kernel, kernel-janitors

On Fri, 2017-04-21 at 20:17 +0200, SF Markus Elfring wrote:
> Several update suggestions were taken into account
> from static source code analysis.

Hello Markus,

Patches should either be useful to users of the Linux kernel, e.g. by adding
new functionality or by fixing a bug, or to kernel developers, e.g. by making
their workflow easier. I don't think this patch series falls in either
category so please drop these patches.

Thanks,

Bart.

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

* [PATCH v2 04/17] IB/mlx4: Fix a typo in a comment line
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:30         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:30 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, trivial

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 12:28:35 +0200

Add a missing character in this description and adjust
the comment formatting.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
---
 drivers/infiniband/hw/mlx4/mad.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index ea4892b0f39e..d8c27e3ed69a 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1559,8 +1559,10 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
 		}
 	}
 
-	/* We are using standard ib_core services to send the mad, so generate a
-	 * stadard address handle by decoding the tunnelled mlx4_ah fields */
+	/*
+	 * We are using standard ib_core services to send the mad, so generate
+	 * a standard address handle by decoding the tunnelled mlx4_ah fields.
+	 */
 	memcpy(&ah.av, &tunnel->hdr.av, sizeof (struct mlx4_av));
 	ah.ibah.device = ctx->ib_dev;
 
-- 
2.12.2

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

* [PATCH v2 04/17] IB/mlx4: Fix a typo in a comment line
@ 2017-04-21 18:30         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:30 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, trivial

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 12:28:35 +0200

Add a missing character in this description and adjust
the comment formatting.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
---
 drivers/infiniband/hw/mlx4/mad.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index ea4892b0f39e..d8c27e3ed69a 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1559,8 +1559,10 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
 		}
 	}
 
-	/* We are using standard ib_core services to send the mad, so generate a
-	 * stadard address handle by decoding the tunnelled mlx4_ah fields */
+	/*
+	 * We are using standard ib_core services to send the mad, so generate
+	 * a standard address handle by decoding the tunnelled mlx4_ah fields.
+	 */
 	memcpy(&ah.av, &tunnel->hdr.av, sizeof (struct mlx4_av));
 	ah.ibah.device = ctx->ib_dev;
 
-- 
2.12.2


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

* [PATCH v2 05/17] IB/mlx4: Delete four unnecessary return statements
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:33         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:33 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 13:10:14 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in the affected functions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  | 3 ---
 drivers/infiniband/hw/mlx4/main.c | 1 -
 2 files changed, 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index d8c27e3ed69a..cf33efce69d2 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1173,7 +1173,6 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 out:
 	kfree(in_mad);
 	kfree(out_mad);
-	return;
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
@@ -2140,7 +2139,6 @@ void mlx4_ib_tunnels_update_work(struct work_struct *work)
 	mlx4_ib_tunnels_update(dmxw->dev, dmxw->slave, (int) dmxw->port,
 			       dmxw->do_init);
 	kfree(dmxw);
-	return;
 }
 
 static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
@@ -2268,7 +2266,6 @@ static void mlx4_ib_master_tunnels(struct mlx4_ib_dev *dev, int do_init)
 	/* initialize or tear down tunnel QPs for the master */
 	for (i = 0; i < dev->dev->caps.num_ports; i++)
 		mlx4_ib_tunnels_update(dev, mlx4_master_func_num(dev->dev), i + 1, do_init);
-	return;
 }
 
 int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 0ac670765466..232f556b1121 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -3109,7 +3109,6 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 	}
 out:
 	kfree(dm);
-	return;
 }
 
 static void mlx4_ib_handle_catas_error(struct mlx4_ib_dev *ibdev)
-- 
2.12.2

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

* [PATCH v2 05/17] IB/mlx4: Delete four unnecessary return statements
@ 2017-04-21 18:33         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:33 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 13:10:14 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in the affected functions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  | 3 ---
 drivers/infiniband/hw/mlx4/main.c | 1 -
 2 files changed, 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index d8c27e3ed69a..cf33efce69d2 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1173,7 +1173,6 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 out:
 	kfree(in_mad);
 	kfree(out_mad);
-	return;
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
@@ -2140,7 +2139,6 @@ void mlx4_ib_tunnels_update_work(struct work_struct *work)
 	mlx4_ib_tunnels_update(dmxw->dev, dmxw->slave, (int) dmxw->port,
 			       dmxw->do_init);
 	kfree(dmxw);
-	return;
 }
 
 static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
@@ -2268,7 +2266,6 @@ static void mlx4_ib_master_tunnels(struct mlx4_ib_dev *dev, int do_init)
 	/* initialize or tear down tunnel QPs for the master */
 	for (i = 0; i < dev->dev->caps.num_ports; i++)
 		mlx4_ib_tunnels_update(dev, mlx4_master_func_num(dev->dev), i + 1, do_init);
-	return;
 }
 
 int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 0ac670765466..232f556b1121 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -3109,7 +3109,6 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 	}
 out:
 	kfree(dm);
-	return;
 }
 
 static void mlx4_ib_handle_catas_error(struct mlx4_ib_dev *ibdev)
-- 
2.12.2


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

* [PATCH v2 06/17] IB/mlx4: Delete an unnecessary check before kfree() in free_pv_object()
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:36         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:36 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 13:50:38 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: kfree(NULL) is safe and this check is probably not required

Thus fix the affected source code place.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index cf33efce69d2..3caf468ca133 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1962,10 +1962,8 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
 
 static void free_pv_object(struct mlx4_ib_dev *dev, int slave, int port)
 {
-	if (dev->sriov.demux[port - 1].tun[slave]) {
-		kfree(dev->sriov.demux[port - 1].tun[slave]);
-		dev->sriov.demux[port - 1].tun[slave] = NULL;
-	}
+	kfree(dev->sriov.demux[port - 1].tun[slave]);
+	dev->sriov.demux[port - 1].tun[slave] = NULL;
 }
 
 static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
-- 
2.12.2

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

* [PATCH v2 06/17] IB/mlx4: Delete an unnecessary check before kfree() in free_pv_object()
@ 2017-04-21 18:36         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:36 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 13:50:38 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: kfree(NULL) is safe and this check is probably not required

Thus fix the affected source code place.

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

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index cf33efce69d2..3caf468ca133 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1962,10 +1962,8 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port,
 
 static void free_pv_object(struct mlx4_ib_dev *dev, int slave, int port)
 {
-	if (dev->sriov.demux[port - 1].tun[slave]) {
-		kfree(dev->sriov.demux[port - 1].tun[slave]);
-		dev->sriov.demux[port - 1].tun[slave] = NULL;
-	}
+	kfree(dev->sriov.demux[port - 1].tun[slave]);
+	dev->sriov.demux[port - 1].tun[slave] = NULL;
 }
 
 static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
-- 
2.12.2


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

* [PATCH v2 07/17] IB/mlx4: Move an assignment out of a check in forward_trap()
  2017-04-21 18:17       ` SF Markus Elfring
  (?)
@ 2017-04-21 18:37           ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:37 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 21 Apr 2017 14:00:08 +0200

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Reviewed-by: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 drivers/infiniband/hw/mlx4/mad.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 3caf468ca133..0a5b46791335 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -401,7 +401,8 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
 		memcpy(send_buf->mad, mad, sizeof *mad);
-		if ((send_buf->ah = dev->sm_ah[port_num - 1]))
+		send_buf->ah = dev->sm_ah[port_num - 1];
+		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
 		else
 			ret = -EINVAL;
-- 
2.12.2

--
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] 179+ messages in thread

* [PATCH v2 07/17] IB/mlx4: Move an assignment out of a check in forward_trap()
@ 2017-04-21 18:37           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:37 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 14:00:08 +0200

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
---
 drivers/infiniband/hw/mlx4/mad.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 3caf468ca133..0a5b46791335 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -401,7 +401,8 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
 		memcpy(send_buf->mad, mad, sizeof *mad);
-		if ((send_buf->ah = dev->sm_ah[port_num - 1]))
+		send_buf->ah = dev->sm_ah[port_num - 1];
+		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
 		else
 			ret = -EINVAL;
-- 
2.12.2

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

* [PATCH v2 07/17] IB/mlx4: Move an assignment out of a check in forward_trap()
@ 2017-04-21 18:37           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:37 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 14:00:08 +0200

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
---
 drivers/infiniband/hw/mlx4/mad.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 3caf468ca133..0a5b46791335 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -401,7 +401,8 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
 		memcpy(send_buf->mad, mad, sizeof *mad);
-		if ((send_buf->ah = dev->sm_ah[port_num - 1]))
+		send_buf->ah = dev->sm_ah[port_num - 1];
+		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
 		else
 			ret = -EINVAL;
-- 
2.12.2


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

* [PATCH v2 08/17] IB/mlx4: Enclose 46 expressions for sizeof by parentheses
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:38         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:38 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 15:27:55 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

WARNING: sizeof … should be sizeof(…)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  | 30 +++++++++++++++---------------
 drivers/infiniband/hw/mlx4/main.c | 35 +++++++++++++++++------------------
 drivers/infiniband/hw/mlx4/qp.c   | 31 ++++++++++++++++---------------
 3 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 0a5b46791335..41461aeb7c5e 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -195,7 +195,7 @@ static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)
 	if (!dev->send_agent[port_num - 1][0])
 		return;
 
-	memset(&ah_attr, 0, sizeof ah_attr);
+	memset(&ah_attr, 0, sizeof(ah_attr));
 	ah_attr.dlid     = lid;
 	ah_attr.sl       = sl;
 	ah_attr.port_num = port_num;
@@ -400,7 +400,7 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 * it's OK for our devices).
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
-		memcpy(send_buf->mad, mad, sizeof *mad);
+		memcpy(send_buf->mad, mad, sizeof(*mad));
 		send_buf->ah = dev->sm_ah[port_num - 1];
 		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
@@ -555,7 +555,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 
 	/* create ah. Just need an empty one with the port num for the post send.
 	 * The driver will set the force loopback bit in post_send */
-	memset(&attr, 0, sizeof attr);
+	memset(&attr, 0, sizeof(attr));
 	attr.port_num = port;
 	if (is_eth) {
 		union ib_gid sgid;
@@ -590,8 +590,8 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 
 	/* copy over to tunnel buffer */
 	if (grh)
-		memcpy(&tun_mad->grh, grh, sizeof *grh);
-	memcpy(&tun_mad->mad, mad, sizeof *mad);
+		memcpy(&tun_mad->grh, grh, sizeof(*grh));
+	memcpy(&tun_mad->mad, mad, sizeof(*mad));
 
 	/* adjust tunnel data */
 	tun_mad->hdr.pkey_index = cpu_to_be16(tun_pkey_ix);
@@ -961,7 +961,7 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	}
 	mutex_unlock(&dev->counters_table[port_num - 1].mutex);
 	if (stats_avail) {
-		memset(out_mad->data, 0, sizeof out_mad->data);
+		memset(out_mad->data, 0, sizeof(out_mad->data));
 		switch (counter_stats.counter_mode & 0xf) {
 		case 0:
 			edit_counter(&counter_stats,
@@ -1136,8 +1136,8 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
-	in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kmalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -1146,8 +1146,8 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	for (i = 0; i < 4; i++) {
 		if (change_bitmap && (!((change_bitmap >> (8 * i)) & 0xff)))
 			continue;
-		memset(in_mad, 0, sizeof *in_mad);
-		memset(out_mad, 0, sizeof *out_mad);
+		memset(in_mad, 0, sizeof(*in_mad));
+		memset(out_mad, 0, sizeof(*out_mad));
 
 		in_mad->base_version  = 1;
 		in_mad->mgmt_class    = IB_MGMT_CLASS_SUBN_LID_ROUTED;
@@ -1417,7 +1417,7 @@ int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
 				   sizeof (struct mlx4_mad_snd_buf),
 				   DMA_TO_DEVICE);
 
-	memcpy(&sqp_mad->payload, mad, sizeof *mad);
+	memcpy(&sqp_mad->payload, mad, sizeof(*mad));
 
 	ib_dma_sync_single_for_device(&dev->ib_dev,
 				      sqp->tx_ring[wire_tx_ix].buf.map,
@@ -1800,7 +1800,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 
 	tun_qp = &ctx->qp[qp_type];
 
-	memset(&qp_init_attr, 0, sizeof qp_init_attr);
+	memset(&qp_init_attr, 0, sizeof(qp_init_attr));
 	qp_init_attr.init_attr.send_cq = ctx->cq;
 	qp_init_attr.init_attr.recv_cq = ctx->cq;
 	qp_init_attr.init_attr.sq_sig_type = IB_SIGNAL_ALL_WR;
@@ -1833,7 +1833,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 		return ret;
 	}
 
-	memset(&attr, 0, sizeof attr);
+	memset(&attr, 0, sizeof(attr));
 	attr.qp_state = IB_QPS_INIT;
 	ret = 0;
 	if (create_tun)
@@ -2180,7 +2180,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 		goto err_mcg;
 	}
 
-	snprintf(name, sizeof name, "mlx4_ibt%d", port);
+	snprintf(name, sizeof(name), "mlx4_ibt%d", port);
 	ctx->wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
 	if (!ctx->wq) {
 		pr_err("Failed to create tunnelling WQ for port %d\n", port);
@@ -2188,7 +2188,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 		goto err_wq;
 	}
 
-	snprintf(name, sizeof name, "mlx4_ibud%d", port);
+	snprintf(name, sizeof(name), "mlx4_ibud%d", port);
 	ctx->ud_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
 	if (!ctx->ud_wq) {
 		pr_err("Failed to create up/down WQ for port %d\n", port);
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 232f556b1121..8f0e37c4f381 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -460,8 +460,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 
 	resp.response_length = offsetof(typeof(resp), response_length) +
 		sizeof(resp.response_length);
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	err = -ENOMEM;
 	if (!in_mad || !out_mad)
 		goto out;
@@ -474,8 +474,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	if (err)
 		goto out;
 
-	memset(props, 0, sizeof *props);
-
+	memset(props, 0, sizeof(*props));
 	have_ib_ports = num_ib_ports(dev->dev);
 
 	props->fw_ver = dev->dev->caps.fw_ver;
@@ -598,8 +597,8 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -774,8 +773,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -911,8 +910,8 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -1283,7 +1282,7 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
 	struct mlx4_ib_pd *pd;
 	int err;
 
-	pd = kmalloc(sizeof *pd, GFP_KERNEL);
+	pd = kmalloc(sizeof(*pd), GFP_KERNEL);
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 
@@ -1322,7 +1321,7 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev,
 	if (!(to_mdev(ibdev)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
 		return ERR_PTR(-ENOSYS);
 
-	xrcd = kmalloc(sizeof *xrcd, GFP_KERNEL);
+	xrcd = kmalloc(sizeof(*xrcd), GFP_KERNEL);
 	if (!xrcd)
 		return ERR_PTR(-ENOMEM);
 
@@ -1370,7 +1369,7 @@ static int add_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
 	struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
 	struct mlx4_ib_gid_entry *ge;
 
-	ge = kzalloc(sizeof *ge, GFP_KERNEL);
+	ge = kzalloc(sizeof(*ge), GFP_KERNEL);
 	if (!ge)
 		return -ENOMEM;
 
@@ -2092,8 +2091,8 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -2603,7 +2602,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	if (num_ports == 0)
 		return NULL;
 
-	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
+	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
 	if (!ibdev) {
 		dev_err(&dev->persist->pdev->dev,
 			"Device struct alloc failed\n");
@@ -3302,12 +3301,12 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
 		break;
 
 	case MLX4_DEV_EVENT_PORT_MGMT_CHANGE:
-		ew = kmalloc(sizeof *ew, GFP_ATOMIC);
+		ew = kmalloc(sizeof(*ew), GFP_ATOMIC);
 		if (!ew)
 			break;
 
 		INIT_WORK(&ew->work, handle_port_mgmt_change_event);
-		memcpy(&ew->ib_eqe, eqe, sizeof *eqe);
+		memcpy(&ew->ib_eqe, eqe, sizeof(*eqe));
 		ew->ib_dev = ibdev;
 		/* need to queue only for port owner, which uses GEN_EQE */
 		if (mlx4_is_master(dev))
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 9269cd503443..c2a0f75d7d07 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -247,9 +247,10 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size)
 	s = sizeof(struct mlx4_wqe_ctrl_seg);
 
 	if (qp->ibqp.qp_type == IB_QPT_UD) {
-		struct mlx4_wqe_datagram_seg *dgram = wqe + sizeof *ctrl;
+		struct mlx4_wqe_datagram_seg *dgram = wqe + sizeof(*ctrl);
 		struct mlx4_av *av = (struct mlx4_av *)dgram->av;
-		memset(dgram, 0, sizeof *dgram);
+
+		memset(dgram, 0, sizeof(*dgram));
 		av->port_pd = cpu_to_be32((qp->port << 24) | to_mpd(qp->ibqp.pd)->pdn);
 		s += sizeof(struct mlx4_wqe_datagram_seg);
 	}
@@ -257,7 +258,8 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size)
 	/* Pad the remainder of the WQE with an inline data segment. */
 	if (size > s) {
 		inl = wqe + s;
-		inl->byte_count = cpu_to_be32(1 << 31 | (size - s - sizeof *inl));
+		inl->byte_count = cpu_to_be32(1 << 31
+					      | (size - s - sizeof(*inl)));
 	}
 	ctrl->srcrb_flags = 0;
 	ctrl->qpn_vlan.fence_size = size / 16;
@@ -726,7 +728,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
 	if (pd->uobject) {
 		struct mlx4_ib_create_qp ucmd;
 
-		if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+		if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
 			err = -EFAULT;
 			goto err;
 		}
@@ -1179,7 +1181,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd,
 	case IB_QPT_RC:
 	case IB_QPT_UC:
 	case IB_QPT_RAW_PACKET:
-		qp = kzalloc(sizeof *qp, gfp);
+		qp = kzalloc(sizeof(*qp), gfp);
 		if (!qp)
 			return ERR_PTR(-ENOMEM);
 		qp->pri.vid = 0xFFFF;
@@ -1634,7 +1636,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 	    IB_LINK_LAYER_ETHERNET)
 		return -ENOTSUPP;
 
-	context = kzalloc(sizeof *context, GFP_KERNEL);
+	context = kzalloc(sizeof(*context), GFP_KERNEL);
 	if (!context)
 		return -ENOMEM;
 
@@ -2298,7 +2300,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	struct mlx4_ib_dev *mdev = to_mdev(sqp->qp.ibqp.device);
 	struct ib_device *ib_dev = &mdev->ib_dev;
 	struct mlx4_wqe_mlx_seg *mlx = wqe;
-	struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
+	struct mlx4_wqe_inline_seg *inl = wqe + sizeof(*mlx);
 	struct mlx4_ib_ah *ah = to_mah(wr->ah);
 	u16 pkey;
 	u32 qkey;
@@ -2447,7 +2449,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 	struct mlx4_ib_dev *ibdev = to_mdev(ib_dev);
 	struct mlx4_wqe_mlx_seg *mlx = wqe;
 	struct mlx4_wqe_ctrl_seg *ctrl = wqe;
-	struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
+	struct mlx4_wqe_inline_seg *inl = wqe + sizeof(*mlx);
 	struct mlx4_ib_ah *ah = to_mah(wr->ah);
 	union ib_gid sgid;
 	u16 pkey;
@@ -2820,7 +2822,7 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 	int spc;
 	int i;
 
-	memcpy(&hdr.av, &ah->av, sizeof hdr.av);
+	memcpy(&hdr.av, &ah->av, sizeof(hdr.av));
 	hdr.remote_qpn = cpu_to_be32(wr->remote_qpn);
 	hdr.pkey_index = cpu_to_be16(wr->pkey_index);
 	hdr.qkey = cpu_to_be32(wr->remote_qkey);
@@ -2899,7 +2901,7 @@ static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_ud_wr *wr,
 			 struct mlx4_ib_qp *qp, unsigned *lso_seg_len,
 			 __be32 *lso_hdr_sz, __be32 *blh)
 {
-	unsigned halign = ALIGN(sizeof *wqe + wr->hlen, 16);
+	unsigned int halign = ALIGN(sizeof(*wqe) + wr->hlen, 16);
 
 	if (unlikely(halign > MLX4_IB_CACHE_LINE_SIZE))
 		*blh = cpu_to_be32(1 << 6);
@@ -3017,9 +3019,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			qp->sq_signal_bits;
 
 		ctrl->imm = send_ieth(wr);
-
-		wqe += sizeof *ctrl;
-		size = sizeof *ctrl / 16;
+		wqe += sizeof(*ctrl);
+		size = sizeof(*ctrl) / 16;
 
 		switch (qp->mlx4_ib_qp_type) {
 		case MLX4_IB_QPT_RC:
@@ -3400,7 +3401,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
 	struct mlx4_dev *dev = ibdev->dev;
 	int is_eth;
 
-	memset(ib_ah_attr, 0, sizeof *ib_ah_attr);
+	memset(ib_ah_attr, 0, sizeof(*ib_ah_attr));
 	ib_ah_attr->port_num	  = path->sched_queue & 0x40 ? 2 : 1;
 
 	if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
@@ -3426,7 +3427,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
 		ib_ah_attr->grh.flow_label =
 			be32_to_cpu(path->tclass_flowlabel) & 0xfffff;
 		memcpy(ib_ah_attr->grh.dgid.raw,
-			path->rgid, sizeof ib_ah_attr->grh.dgid.raw);
+			path->rgid, sizeof(ib_ah_attr->grh.dgid.raw));
 	}
 }
 
-- 
2.12.2

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

* [PATCH v2 08/17] IB/mlx4: Enclose 46 expressions for sizeof by parentheses
@ 2017-04-21 18:38         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:38 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 15:27:55 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

WARNING: sizeof … should be sizeof(…)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  | 30 +++++++++++++++---------------
 drivers/infiniband/hw/mlx4/main.c | 35 +++++++++++++++++------------------
 drivers/infiniband/hw/mlx4/qp.c   | 31 ++++++++++++++++---------------
 3 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 0a5b46791335..41461aeb7c5e 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -195,7 +195,7 @@ static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)
 	if (!dev->send_agent[port_num - 1][0])
 		return;
 
-	memset(&ah_attr, 0, sizeof ah_attr);
+	memset(&ah_attr, 0, sizeof(ah_attr));
 	ah_attr.dlid     = lid;
 	ah_attr.sl       = sl;
 	ah_attr.port_num = port_num;
@@ -400,7 +400,7 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_m
 		 * it's OK for our devices).
 		 */
 		spin_lock_irqsave(&dev->sm_lock, flags);
-		memcpy(send_buf->mad, mad, sizeof *mad);
+		memcpy(send_buf->mad, mad, sizeof(*mad));
 		send_buf->ah = dev->sm_ah[port_num - 1];
 		if (send_buf->ah)
 			ret = ib_post_send_mad(send_buf, NULL);
@@ -555,7 +555,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 
 	/* create ah. Just need an empty one with the port num for the post send.
 	 * The driver will set the force loopback bit in post_send */
-	memset(&attr, 0, sizeof attr);
+	memset(&attr, 0, sizeof(attr));
 	attr.port_num = port;
 	if (is_eth) {
 		union ib_gid sgid;
@@ -590,8 +590,8 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 
 	/* copy over to tunnel buffer */
 	if (grh)
-		memcpy(&tun_mad->grh, grh, sizeof *grh);
-	memcpy(&tun_mad->mad, mad, sizeof *mad);
+		memcpy(&tun_mad->grh, grh, sizeof(*grh));
+	memcpy(&tun_mad->mad, mad, sizeof(*mad));
 
 	/* adjust tunnel data */
 	tun_mad->hdr.pkey_index = cpu_to_be16(tun_pkey_ix);
@@ -961,7 +961,7 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	}
 	mutex_unlock(&dev->counters_table[port_num - 1].mutex);
 	if (stats_avail) {
-		memset(out_mad->data, 0, sizeof out_mad->data);
+		memset(out_mad->data, 0, sizeof(out_mad->data));
 		switch (counter_stats.counter_mode & 0xf) {
 		case 0:
 			edit_counter(&counter_stats,
@@ -1136,8 +1136,8 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
-	in_mad  = kmalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kmalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -1146,8 +1146,8 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	for (i = 0; i < 4; i++) {
 		if (change_bitmap && (!((change_bitmap >> (8 * i)) & 0xff)))
 			continue;
-		memset(in_mad, 0, sizeof *in_mad);
-		memset(out_mad, 0, sizeof *out_mad);
+		memset(in_mad, 0, sizeof(*in_mad));
+		memset(out_mad, 0, sizeof(*out_mad));
 
 		in_mad->base_version  = 1;
 		in_mad->mgmt_class    = IB_MGMT_CLASS_SUBN_LID_ROUTED;
@@ -1417,7 +1417,7 @@ int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
 				   sizeof (struct mlx4_mad_snd_buf),
 				   DMA_TO_DEVICE);
 
-	memcpy(&sqp_mad->payload, mad, sizeof *mad);
+	memcpy(&sqp_mad->payload, mad, sizeof(*mad));
 
 	ib_dma_sync_single_for_device(&dev->ib_dev,
 				      sqp->tx_ring[wire_tx_ix].buf.map,
@@ -1800,7 +1800,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 
 	tun_qp = &ctx->qp[qp_type];
 
-	memset(&qp_init_attr, 0, sizeof qp_init_attr);
+	memset(&qp_init_attr, 0, sizeof(qp_init_attr));
 	qp_init_attr.init_attr.send_cq = ctx->cq;
 	qp_init_attr.init_attr.recv_cq = ctx->cq;
 	qp_init_attr.init_attr.sq_sig_type = IB_SIGNAL_ALL_WR;
@@ -1833,7 +1833,7 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 		return ret;
 	}
 
-	memset(&attr, 0, sizeof attr);
+	memset(&attr, 0, sizeof(attr));
 	attr.qp_state = IB_QPS_INIT;
 	ret = 0;
 	if (create_tun)
@@ -2180,7 +2180,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 		goto err_mcg;
 	}
 
-	snprintf(name, sizeof name, "mlx4_ibt%d", port);
+	snprintf(name, sizeof(name), "mlx4_ibt%d", port);
 	ctx->wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
 	if (!ctx->wq) {
 		pr_err("Failed to create tunnelling WQ for port %d\n", port);
@@ -2188,7 +2188,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
 		goto err_wq;
 	}
 
-	snprintf(name, sizeof name, "mlx4_ibud%d", port);
+	snprintf(name, sizeof(name), "mlx4_ibud%d", port);
 	ctx->ud_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
 	if (!ctx->ud_wq) {
 		pr_err("Failed to create up/down WQ for port %d\n", port);
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 232f556b1121..8f0e37c4f381 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -460,8 +460,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 
 	resp.response_length = offsetof(typeof(resp), response_length) +
 		sizeof(resp.response_length);
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	err = -ENOMEM;
 	if (!in_mad || !out_mad)
 		goto out;
@@ -474,8 +474,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	if (err)
 		goto out;
 
-	memset(props, 0, sizeof *props);
-
+	memset(props, 0, sizeof(*props));
 	have_ib_ports = num_ib_ports(dev->dev);
 
 	props->fw_ver = dev->dev->caps.fw_ver;
@@ -598,8 +597,8 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -774,8 +773,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -911,8 +910,8 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -1283,7 +1282,7 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
 	struct mlx4_ib_pd *pd;
 	int err;
 
-	pd = kmalloc(sizeof *pd, GFP_KERNEL);
+	pd = kmalloc(sizeof(*pd), GFP_KERNEL);
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 
@@ -1322,7 +1321,7 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev,
 	if (!(to_mdev(ibdev)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
 		return ERR_PTR(-ENOSYS);
 
-	xrcd = kmalloc(sizeof *xrcd, GFP_KERNEL);
+	xrcd = kmalloc(sizeof(*xrcd), GFP_KERNEL);
 	if (!xrcd)
 		return ERR_PTR(-ENOMEM);
 
@@ -1370,7 +1369,7 @@ static int add_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
 	struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
 	struct mlx4_ib_gid_entry *ge;
 
-	ge = kzalloc(sizeof *ge, GFP_KERNEL);
+	ge = kzalloc(sizeof(*ge), GFP_KERNEL);
 	if (!ge)
 		return -ENOMEM;
 
@@ -2092,8 +2091,8 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 	int err = -ENOMEM;
 
-	in_mad  = kzalloc(sizeof *in_mad, GFP_KERNEL);
-	out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
 	if (!in_mad || !out_mad)
 		goto out;
 
@@ -2603,7 +2602,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	if (num_ports = 0)
 		return NULL;
 
-	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
+	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
 	if (!ibdev) {
 		dev_err(&dev->persist->pdev->dev,
 			"Device struct alloc failed\n");
@@ -3302,12 +3301,12 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
 		break;
 
 	case MLX4_DEV_EVENT_PORT_MGMT_CHANGE:
-		ew = kmalloc(sizeof *ew, GFP_ATOMIC);
+		ew = kmalloc(sizeof(*ew), GFP_ATOMIC);
 		if (!ew)
 			break;
 
 		INIT_WORK(&ew->work, handle_port_mgmt_change_event);
-		memcpy(&ew->ib_eqe, eqe, sizeof *eqe);
+		memcpy(&ew->ib_eqe, eqe, sizeof(*eqe));
 		ew->ib_dev = ibdev;
 		/* need to queue only for port owner, which uses GEN_EQE */
 		if (mlx4_is_master(dev))
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 9269cd503443..c2a0f75d7d07 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -247,9 +247,10 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size)
 	s = sizeof(struct mlx4_wqe_ctrl_seg);
 
 	if (qp->ibqp.qp_type = IB_QPT_UD) {
-		struct mlx4_wqe_datagram_seg *dgram = wqe + sizeof *ctrl;
+		struct mlx4_wqe_datagram_seg *dgram = wqe + sizeof(*ctrl);
 		struct mlx4_av *av = (struct mlx4_av *)dgram->av;
-		memset(dgram, 0, sizeof *dgram);
+
+		memset(dgram, 0, sizeof(*dgram));
 		av->port_pd = cpu_to_be32((qp->port << 24) | to_mpd(qp->ibqp.pd)->pdn);
 		s += sizeof(struct mlx4_wqe_datagram_seg);
 	}
@@ -257,7 +258,8 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size)
 	/* Pad the remainder of the WQE with an inline data segment. */
 	if (size > s) {
 		inl = wqe + s;
-		inl->byte_count = cpu_to_be32(1 << 31 | (size - s - sizeof *inl));
+		inl->byte_count = cpu_to_be32(1 << 31
+					      | (size - s - sizeof(*inl)));
 	}
 	ctrl->srcrb_flags = 0;
 	ctrl->qpn_vlan.fence_size = size / 16;
@@ -726,7 +728,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
 	if (pd->uobject) {
 		struct mlx4_ib_create_qp ucmd;
 
-		if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+		if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
 			err = -EFAULT;
 			goto err;
 		}
@@ -1179,7 +1181,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd,
 	case IB_QPT_RC:
 	case IB_QPT_UC:
 	case IB_QPT_RAW_PACKET:
-		qp = kzalloc(sizeof *qp, gfp);
+		qp = kzalloc(sizeof(*qp), gfp);
 		if (!qp)
 			return ERR_PTR(-ENOMEM);
 		qp->pri.vid = 0xFFFF;
@@ -1634,7 +1636,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 	    IB_LINK_LAYER_ETHERNET)
 		return -ENOTSUPP;
 
-	context = kzalloc(sizeof *context, GFP_KERNEL);
+	context = kzalloc(sizeof(*context), GFP_KERNEL);
 	if (!context)
 		return -ENOMEM;
 
@@ -2298,7 +2300,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	struct mlx4_ib_dev *mdev = to_mdev(sqp->qp.ibqp.device);
 	struct ib_device *ib_dev = &mdev->ib_dev;
 	struct mlx4_wqe_mlx_seg *mlx = wqe;
-	struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
+	struct mlx4_wqe_inline_seg *inl = wqe + sizeof(*mlx);
 	struct mlx4_ib_ah *ah = to_mah(wr->ah);
 	u16 pkey;
 	u32 qkey;
@@ -2447,7 +2449,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 	struct mlx4_ib_dev *ibdev = to_mdev(ib_dev);
 	struct mlx4_wqe_mlx_seg *mlx = wqe;
 	struct mlx4_wqe_ctrl_seg *ctrl = wqe;
-	struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
+	struct mlx4_wqe_inline_seg *inl = wqe + sizeof(*mlx);
 	struct mlx4_ib_ah *ah = to_mah(wr->ah);
 	union ib_gid sgid;
 	u16 pkey;
@@ -2820,7 +2822,7 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 	int spc;
 	int i;
 
-	memcpy(&hdr.av, &ah->av, sizeof hdr.av);
+	memcpy(&hdr.av, &ah->av, sizeof(hdr.av));
 	hdr.remote_qpn = cpu_to_be32(wr->remote_qpn);
 	hdr.pkey_index = cpu_to_be16(wr->pkey_index);
 	hdr.qkey = cpu_to_be32(wr->remote_qkey);
@@ -2899,7 +2901,7 @@ static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_ud_wr *wr,
 			 struct mlx4_ib_qp *qp, unsigned *lso_seg_len,
 			 __be32 *lso_hdr_sz, __be32 *blh)
 {
-	unsigned halign = ALIGN(sizeof *wqe + wr->hlen, 16);
+	unsigned int halign = ALIGN(sizeof(*wqe) + wr->hlen, 16);
 
 	if (unlikely(halign > MLX4_IB_CACHE_LINE_SIZE))
 		*blh = cpu_to_be32(1 << 6);
@@ -3017,9 +3019,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			qp->sq_signal_bits;
 
 		ctrl->imm = send_ieth(wr);
-
-		wqe += sizeof *ctrl;
-		size = sizeof *ctrl / 16;
+		wqe += sizeof(*ctrl);
+		size = sizeof(*ctrl) / 16;
 
 		switch (qp->mlx4_ib_qp_type) {
 		case MLX4_IB_QPT_RC:
@@ -3400,7 +3401,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
 	struct mlx4_dev *dev = ibdev->dev;
 	int is_eth;
 
-	memset(ib_ah_attr, 0, sizeof *ib_ah_attr);
+	memset(ib_ah_attr, 0, sizeof(*ib_ah_attr));
 	ib_ah_attr->port_num	  = path->sched_queue & 0x40 ? 2 : 1;
 
 	if (ib_ah_attr->port_num = 0 || ib_ah_attr->port_num > dev->caps.num_ports)
@@ -3426,7 +3427,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
 		ib_ah_attr->grh.flow_label  			be32_to_cpu(path->tclass_flowlabel) & 0xfffff;
 		memcpy(ib_ah_attr->grh.dgid.raw,
-			path->rgid, sizeof ib_ah_attr->grh.dgid.raw);
+			path->rgid, sizeof(ib_ah_attr->grh.dgid.raw));
 	}
 }
 
-- 
2.12.2


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

* [PATCH v2 09/17] IB/mlx4: Split a condition check in six functions
  2017-04-21 18:17       ` SF Markus Elfring
  (?)
@ 2017-04-21 18:40           ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:40 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 21 Apr 2017 18:13:16 +0200

The kfree() function was called in up to two cases during error handling
even if the passed variable contained a null pointer.

* Split a condition check for memory allocation failures.

* Adjust jump targets according to the Linux coding style convention.

* Delete initialisations for variables at the beginning
  which became unnecessary with this refactoring.

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

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  | 14 +++---
 drivers/infiniband/hw/mlx4/main.c | 90 +++++++++++++++++++++++++--------------
 2 files changed, 68 insertions(+), 36 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 41461aeb7c5e..b26817f0669f 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1129,17 +1129,20 @@ static void propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
 static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 				      u32 guid_tbl_blk_num, u32 change_bitmap)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad  = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	u16 i;
 
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
 	in_mad  = kmalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad)
+		goto free_in_mad;
 
 	guid_tbl_blk_num  *= 4;
 
@@ -1172,8 +1175,9 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	}
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 8f0e37c4f381..e18e46a68809 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -435,8 +435,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 				struct ib_udata *uhw)
 {
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int err;
 	int have_ib_ports;
 	struct mlx4_uverbs_ex_query_device cmd;
@@ -461,10 +461,14 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	resp.response_length = offsetof(typeof(resp), response_length) +
 		sizeof(resp.response_length);
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	err = -ENOMEM;
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
@@ -573,9 +577,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 			goto out;
 	}
 out:
-	kfree(in_mad);
 	kfree(out_mad);
-
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -591,16 +595,21 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num)
 static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 			      struct ib_port_attr *props, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int ext_active_speed;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -673,8 +682,9 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 		 props->active_speed = IB_SPEED_SDR;
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -766,17 +776,22 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
 int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 			union ib_gid *gid, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
-	int err = -ENOMEM;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
+	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
 	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -814,8 +829,9 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 out:
 	if (clear)
 		memset(gid->raw + 8, 0, 8);
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -905,15 +921,20 @@ static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
 int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 			 u16 *pkey, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PKEY_TABLE;
@@ -930,8 +951,9 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 	*pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -2086,15 +2108,20 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 
 static int init_node_data(struct mlx4_ib_dev *dev)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
@@ -2117,8 +2144,9 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
-- 
2.12.2

--
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] 179+ messages in thread

* [PATCH v2 09/17] IB/mlx4: Split a condition check in six functions
@ 2017-04-21 18:40           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:40 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:13:16 +0200

The kfree() function was called in up to two cases during error handling
even if the passed variable contained a null pointer.

* Split a condition check for memory allocation failures.

* Adjust jump targets according to the Linux coding style convention.

* Delete initialisations for variables at the beginning
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  | 14 +++---
 drivers/infiniband/hw/mlx4/main.c | 90 +++++++++++++++++++++++++--------------
 2 files changed, 68 insertions(+), 36 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 41461aeb7c5e..b26817f0669f 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1129,17 +1129,20 @@ static void propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
 static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 				      u32 guid_tbl_blk_num, u32 change_bitmap)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad  = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	u16 i;
 
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
 	in_mad  = kmalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad)
+		goto free_in_mad;
 
 	guid_tbl_blk_num  *= 4;
 
@@ -1172,8 +1175,9 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	}
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 8f0e37c4f381..e18e46a68809 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -435,8 +435,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 				struct ib_udata *uhw)
 {
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int err;
 	int have_ib_ports;
 	struct mlx4_uverbs_ex_query_device cmd;
@@ -461,10 +461,14 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	resp.response_length = offsetof(typeof(resp), response_length) +
 		sizeof(resp.response_length);
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	err = -ENOMEM;
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
@@ -573,9 +577,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 			goto out;
 	}
 out:
-	kfree(in_mad);
 	kfree(out_mad);
-
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -591,16 +595,21 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num)
 static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 			      struct ib_port_attr *props, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int ext_active_speed;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -673,8 +682,9 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 		 props->active_speed = IB_SPEED_SDR;
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -766,17 +776,22 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
 int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 			union ib_gid *gid, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
-	int err = -ENOMEM;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
+	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
 	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -814,8 +829,9 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 out:
 	if (clear)
 		memset(gid->raw + 8, 0, 8);
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -905,15 +921,20 @@ static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
 int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 			 u16 *pkey, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PKEY_TABLE;
@@ -930,8 +951,9 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 	*pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -2086,15 +2108,20 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 
 static int init_node_data(struct mlx4_ib_dev *dev)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
@@ -2117,8 +2144,9 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
-- 
2.12.2

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

* [PATCH v2 09/17] IB/mlx4: Split a condition check in six functions
@ 2017-04-21 18:40           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:40 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:13:16 +0200

The kfree() function was called in up to two cases during error handling
even if the passed variable contained a null pointer.

* Split a condition check for memory allocation failures.

* Adjust jump targets according to the Linux coding style convention.

* Delete initialisations for variables at the beginning
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Changes were rebased on source files from Linux next-20170421.
These were recombined as requested by Doug Ledford.

 drivers/infiniband/hw/mlx4/mad.c  | 14 +++---
 drivers/infiniband/hw/mlx4/main.c | 90 +++++++++++++++++++++++++--------------
 2 files changed, 68 insertions(+), 36 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 41461aeb7c5e..b26817f0669f 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1129,17 +1129,20 @@ static void propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
 static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 				      u32 guid_tbl_blk_num, u32 change_bitmap)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad  = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	u16 i;
 
 	if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
 		return;
 
 	in_mad  = kmalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad)
+		goto free_in_mad;
 
 	guid_tbl_blk_num  *= 4;
 
@@ -1172,8 +1175,9 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
 	}
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 }
 
 void handle_port_mgmt_change_event(struct work_struct *work)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 8f0e37c4f381..e18e46a68809 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -435,8 +435,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 				struct ib_udata *uhw)
 {
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int err;
 	int have_ib_ports;
 	struct mlx4_uverbs_ex_query_device cmd;
@@ -461,10 +461,14 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 	resp.response_length = offsetof(typeof(resp), response_length) +
 		sizeof(resp.response_length);
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	err = -ENOMEM;
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
@@ -573,9 +577,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
 			goto out;
 	}
 out:
-	kfree(in_mad);
 	kfree(out_mad);
-
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -591,16 +595,21 @@ mlx4_ib_port_link_layer(struct ib_device *device, u8 port_num)
 static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 			      struct ib_port_attr *props, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int ext_active_speed;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -673,8 +682,9 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 		 props->active_speed = IB_SPEED_SDR;
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -766,17 +776,22 @@ static int mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
 int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 			union ib_gid *gid, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
-	int err = -ENOMEM;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
+	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
 	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PORT_INFO;
@@ -814,8 +829,9 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 out:
 	if (clear)
 		memset(gid->raw + 8, 0, 8);
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -905,15 +921,20 @@ static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
 int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 			 u16 *pkey, int netw_view)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id  = IB_SMP_ATTR_PKEY_TABLE;
@@ -930,8 +951,9 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
 	*pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
@@ -2086,15 +2108,20 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 
 static int init_node_data(struct mlx4_ib_dev *dev)
 {
-	struct ib_smp *in_mad  = NULL;
-	struct ib_smp *out_mad = NULL;
+	struct ib_smp *in_mad;
+	struct ib_smp *out_mad;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
-	int err = -ENOMEM;
+	int err;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+	if (!in_mad)
+		return -ENOMEM;
+
 	out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
-	if (!in_mad || !out_mad)
-		goto out;
+	if (!out_mad) {
+		err = -ENOMEM;
+		goto free_in_mad;
+	}
 
 	init_query_mad(in_mad);
 	in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
@@ -2117,8 +2144,9 @@ static int init_node_data(struct mlx4_ib_dev *dev)
 	memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
 
 out:
-	kfree(in_mad);
 	kfree(out_mad);
+free_in_mad:
+	kfree(in_mad);
 	return err;
 }
 
-- 
2.12.2


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

* [PATCH v2 10/17] IB/mlx4: Delete an unnecessary variable in __mlx4_ib_query_gid()
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:42         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:42 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:22:42 +0200

* Call the function "memset" directly in an if branch without using
  an intermediate variable.

* Delete the local variable "clear" which became unnecessary with
  this refactoring.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index e18e46a68809..a54e2f04929b 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -780,7 +780,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	struct ib_smp *out_mad;
 	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
@@ -809,8 +808,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	if (mlx4_is_mfunc(dev->dev) && !netw_view) {
 		if (index) {
 			/* For any index > 0, return the null guid */
+			memset(gid->raw + 8, 0, 8);
 			err = 0;
-			clear = 1;
 			goto out;
 		}
 	}
@@ -827,8 +826,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
 
 out:
-	if (clear)
-		memset(gid->raw + 8, 0, 8);
 	kfree(out_mad);
 free_in_mad:
 	kfree(in_mad);
-- 
2.12.2

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

* [PATCH v2 10/17] IB/mlx4: Delete an unnecessary variable in __mlx4_ib_query_gid()
@ 2017-04-21 18:42         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:42 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:22:42 +0200

* Call the function "memset" directly in an if branch without using
  an intermediate variable.

* Delete the local variable "clear" which became unnecessary with
  this refactoring.

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index e18e46a68809..a54e2f04929b 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -780,7 +780,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	struct ib_smp *out_mad;
 	int err;
 	struct mlx4_ib_dev *dev = to_mdev(ibdev);
-	int clear = 0;
 	int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
 
 	in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
@@ -809,8 +808,8 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	if (mlx4_is_mfunc(dev->dev) && !netw_view) {
 		if (index) {
 			/* For any index > 0, return the null guid */
+			memset(gid->raw + 8, 0, 8);
 			err = 0;
-			clear = 1;
 			goto out;
 		}
 	}
@@ -827,8 +826,6 @@ int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
 	memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
 
 out:
-	if (clear)
-		memset(gid->raw + 8, 0, 8);
 	kfree(out_mad);
 free_in_mad:
 	kfree(in_mad);
-- 
2.12.2


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

* [PATCH v2 11/17] IB/mlx4: Delete an unnecessary variable initialisation in mlx4_ib_add()
  2017-04-21 18:17       ` SF Markus Elfring
  (?)
@ 2017-04-21 18:44           ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:44 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 21 Apr 2017 18:44:15 +0200

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

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index a54e2f04929b..d08b9b154c97 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2615,7 +2615,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	int num_req_counters;
 	int allocated;
 	u32 counter_index;
-	struct counter_index *new_counter_index = NULL;
+	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
 
-- 
2.12.2

--
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] 179+ messages in thread

* [PATCH v2 11/17] IB/mlx4: Delete an unnecessary variable initialisation in mlx4_ib_add()
@ 2017-04-21 18:44           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:44 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:44:15 +0200

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

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index a54e2f04929b..d08b9b154c97 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2615,7 +2615,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	int num_req_counters;
 	int allocated;
 	u32 counter_index;
-	struct counter_index *new_counter_index = NULL;
+	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
 
-- 
2.12.2

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

* [PATCH v2 11/17] IB/mlx4: Delete an unnecessary variable initialisation in mlx4_ib_add()
@ 2017-04-21 18:44           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:44 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:44:15 +0200

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

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

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index a54e2f04929b..d08b9b154c97 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2615,7 +2615,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	int num_req_counters;
 	int allocated;
 	u32 counter_index;
-	struct counter_index *new_counter_index = NULL;
+	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
 
-- 
2.12.2


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

* [PATCH v2 12/17] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add()
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:45         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:45 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:52:03 +0200

Delete an assignment for the local variable "num_ports" at the beginning
because it was initialised with the same value.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
---
 drivers/infiniband/hw/mlx4/main.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index d08b9b154c97..4eb2466530dc 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2618,8 +2618,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
-
-	num_ports = 0;
 	mlx4_foreach_ib_transport_port(i, dev)
 		num_ports++;
 
-- 
2.12.2

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

* [PATCH v2 12/17] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add()
@ 2017-04-21 18:45         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:45 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:52:03 +0200

Delete an assignment for the local variable "num_ports" at the beginning
because it was initialised with the same value.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
---
 drivers/infiniband/hw/mlx4/main.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index d08b9b154c97..4eb2466530dc 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2618,8 +2618,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	struct counter_index *new_counter_index;
 
 	pr_info_once("%s", mlx4_ib_version);
-
-	num_ports = 0;
 	mlx4_foreach_ib_transport_port(i, dev)
 		num_ports++;
 
-- 
2.12.2


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

* [PATCH v2 13/17] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add()
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:46         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:46 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:55:35 +0200

Omit an extra message for a memory allocation failure in this function.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 4eb2466530dc..67368dea9b6a 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2626,11 +2626,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		return NULL;
 
 	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
-	if (!ibdev) {
-		dev_err(&dev->persist->pdev->dev,
-			"Device struct alloc failed\n");
+	if (!ibdev)
 		return NULL;
-	}
 
 	iboe = &ibdev->iboe;
 
-- 
2.12.2

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

* [PATCH v2 13/17] IB/mlx4: Delete an error message for a failed memory allocation in mlx4_ib_add()
@ 2017-04-21 18:46         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:46 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:55:35 +0200

Omit an extra message for a memory allocation failure in this function.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 4eb2466530dc..67368dea9b6a 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2626,11 +2626,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		return NULL;
 
 	ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof(*ibdev));
-	if (!ibdev) {
-		dev_err(&dev->persist->pdev->dev,
-			"Device struct alloc failed\n");
+	if (!ibdev)
 		return NULL;
-	}
 
 	iboe = &ibdev->iboe;
 
-- 
2.12.2


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

* [PATCH v2 14/17] IB/mlx4: Delete unnecessary braces in mlx4_ib_add()
  2017-04-21 18:17       ` SF Markus Elfring
  (?)
@ 2017-04-21 18:48           ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:48 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	trivial-DgEjT+Ai2ygdnm+yROfE0A

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Fri, 21 Apr 2017 18:58:43 +0200

Do not use curly brackets at one source code place
where a single statement should be sufficient.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Reviewed-by: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 drivers/infiniband/hw/mlx4/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 67368dea9b6a..7dd5468cd4b8 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2901,9 +2901,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		}
 		if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
 			err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
-			if (err) {
+			if (err)
 				goto err_notif;
-			}
 		}
 	}
 
-- 
2.12.2

--
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] 179+ messages in thread

* [PATCH v2 14/17] IB/mlx4: Delete unnecessary braces in mlx4_ib_add()
@ 2017-04-21 18:48           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:48 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, trivial

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:58:43 +0200

Do not use curly brackets at one source code place
where a single statement should be sufficient.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
---
 drivers/infiniband/hw/mlx4/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 67368dea9b6a..7dd5468cd4b8 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2901,9 +2901,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		}
 		if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
 			err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
-			if (err) {
+			if (err)
 				goto err_notif;
-			}
 		}
 	}
 
-- 
2.12.2

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

* [PATCH v2 14/17] IB/mlx4: Delete unnecessary braces in mlx4_ib_add()
@ 2017-04-21 18:48           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:48 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	trivial-DgEjT+Ai2ygdnm+yROfE0A

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 18:58:43 +0200

Do not use curly brackets at one source code place
where a single statement should be sufficient.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
---
 drivers/infiniband/hw/mlx4/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 67368dea9b6a..7dd5468cd4b8 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2901,9 +2901,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 		}
 		if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
 			err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
-			if (err) {
+			if (err)
 				goto err_notif;
-			}
 		}
 	}
 
-- 
2.12.2


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

* [PATCH v2 15/17] IB/mlx4: Delete unwanted spaces behind usages of the sizeof operator
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:50         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:50 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, trivial

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 19:11:59 +0200

* Replace the source code "sizeof (" by "sizeof("
  according to the Linux coding style convention.

* Adjust indentation at a few places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/qp.c | 128 ++++++++++++++++++++--------------------
 1 file changed, 63 insertions(+), 65 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index c2a0f75d7d07..068abfdc9d01 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -342,39 +342,39 @@ static int send_wqe_overhead(enum mlx4_ib_qp_type type, u32 flags)
 	 */
 	switch (type) {
 	case MLX4_IB_QPT_UD:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg) +
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg) +
 			((flags & MLX4_IB_QP_LSO) ? MLX4_IB_LSO_HEADER_SPARE : 0);
 	case MLX4_IB_QPT_PROXY_SMI_OWNER:
 	case MLX4_IB_QPT_PROXY_SMI:
 	case MLX4_IB_QPT_PROXY_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg) + 64;
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg) + 64;
 	case MLX4_IB_QPT_TUN_SMI_OWNER:
 	case MLX4_IB_QPT_TUN_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg);
 
 	case MLX4_IB_QPT_UC:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_raddr_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_raddr_seg);
 	case MLX4_IB_QPT_RC:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_masked_atomic_seg) +
-			sizeof (struct mlx4_wqe_raddr_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_masked_atomic_seg) +
+			sizeof(struct mlx4_wqe_raddr_seg);
 	case MLX4_IB_QPT_SMI:
 	case MLX4_IB_QPT_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
 			ALIGN(MLX4_IB_UD_HEADER_SIZE +
 			      DIV_ROUND_UP(MLX4_IB_UD_HEADER_SIZE,
 					   MLX4_INLINE_ALIGN) *
-			      sizeof (struct mlx4_wqe_inline_seg),
-			      sizeof (struct mlx4_wqe_data_seg)) +
+			      sizeof(struct mlx4_wqe_inline_seg),
+			      sizeof(struct mlx4_wqe_data_seg)) +
 			ALIGN(4 +
-			      sizeof (struct mlx4_wqe_inline_seg),
-			      sizeof (struct mlx4_wqe_data_seg));
+			      sizeof(struct mlx4_wqe_inline_seg),
+			      sizeof(struct mlx4_wqe_data_seg));
 	default:
-		return sizeof (struct mlx4_wqe_ctrl_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg);
 	}
 }
 
@@ -398,7 +398,8 @@ static int set_rq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 
 		qp->rq.wqe_cnt	 = roundup_pow_of_two(max(1U, cap->max_recv_wr));
 		qp->rq.max_gs	 = roundup_pow_of_two(max(1U, cap->max_recv_sge));
-		qp->rq.wqe_shift = ilog2(qp->rq.max_gs * sizeof (struct mlx4_wqe_data_seg));
+		qp->rq.wqe_shift = ilog2(qp->rq.max_gs
+					 * sizeof(struct mlx4_wqe_data_seg));
 	}
 
 	/* leave userspace return values as they were, so as not to break ABI */
@@ -426,7 +427,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	if (cap->max_send_wr  > (dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE) ||
 	    cap->max_send_sge > min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg) ||
 	    cap->max_inline_data + send_wqe_overhead(type, qp->flags) +
-	    sizeof (struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
+	    sizeof(struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
 		return -EINVAL;
 
 	/*
@@ -438,8 +439,8 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	    cap->max_send_sge + 2 > dev->dev->caps.max_sq_sg)
 		return -EINVAL;
 
-	s = max(cap->max_send_sge * sizeof (struct mlx4_wqe_data_seg),
-		cap->max_inline_data + sizeof (struct mlx4_wqe_inline_seg)) +
+	s = max(cap->max_send_sge * sizeof(struct mlx4_wqe_data_seg),
+		cap->max_inline_data + sizeof(struct mlx4_wqe_inline_seg)) +
 		send_wqe_overhead(type, qp->flags);
 
 	if (s > dev->dev->caps.max_sq_desc_sz)
@@ -509,7 +510,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	qp->sq.max_gs = (min(dev->dev->caps.max_sq_desc_sz,
 			     (qp->sq_max_wqes_per_wr << qp->sq.wqe_shift)) -
 			 send_wqe_overhead(type, qp->flags)) /
-		sizeof (struct mlx4_wqe_data_seg);
+		sizeof(struct mlx4_wqe_data_seg);
 
 	qp->buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) +
 		(qp->sq.wqe_cnt << qp->sq.wqe_shift);
@@ -563,13 +564,13 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 		return -ENOMEM;
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
 		qp->sqp_proxy_rcv[i].addr =
-			kmalloc(sizeof (struct mlx4_ib_proxy_sqp_hdr),
+			kmalloc(sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				GFP_KERNEL);
 		if (!qp->sqp_proxy_rcv[i].addr)
 			goto err;
 		qp->sqp_proxy_rcv[i].map =
 			ib_dma_map_single(dev, qp->sqp_proxy_rcv[i].addr,
-					  sizeof (struct mlx4_ib_proxy_sqp_hdr),
+					  sizeof(struct mlx4_ib_proxy_sqp_hdr),
 					  DMA_FROM_DEVICE);
 		if (ib_dma_mapping_error(dev, qp->sqp_proxy_rcv[i].map)) {
 			kfree(qp->sqp_proxy_rcv[i].addr);
@@ -582,7 +583,7 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 	while (i > 0) {
 		--i;
 		ib_dma_unmap_single(dev, qp->sqp_proxy_rcv[i].map,
-				    sizeof (struct mlx4_ib_proxy_sqp_hdr),
+				    sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				    DMA_FROM_DEVICE);
 		kfree(qp->sqp_proxy_rcv[i].addr);
 	}
@@ -597,7 +598,7 @@ static void free_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
 		ib_dma_unmap_single(dev, qp->sqp_proxy_rcv[i].map,
-				    sizeof (struct mlx4_ib_proxy_sqp_hdr),
+				    sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				    DMA_FROM_DEVICE);
 		kfree(qp->sqp_proxy_rcv[i].addr);
 	}
@@ -2320,7 +2321,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	/* for proxy-qp0 sends, need to add in size of tunnel header */
 	/* for tunnel-qp0 sends, tunnel header is already in s/g list */
 	if (sqp->qp.mlx4_ib_qp_type == MLX4_IB_QPT_PROXY_SMI_OWNER)
-		send_size += sizeof (struct mlx4_ib_tunnel_header);
+		send_size += sizeof(struct mlx4_ib_tunnel_header);
 
 	ib_ud_header_init(send_size, 1, 0, 0, 0, 0, 0, 0, &sqp->ud_header);
 
@@ -2402,7 +2403,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	}
 
 	*mlx_seg_len =
-	ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + header_size, 16);
+	ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + header_size, 16);
 	return 0;
 }
 
@@ -2692,7 +2693,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 	}
 
 	*mlx_seg_len =
-		ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + header_size, 16);
+		ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + header_size, 16);
 	return 0;
 }
 
@@ -2783,7 +2784,7 @@ static void set_masked_atomic_seg(struct mlx4_wqe_masked_atomic_seg *aseg,
 static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
 			     struct ib_ud_wr *wr)
 {
-	memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof (struct mlx4_av));
+	memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof(struct mlx4_av));
 	dseg->dqpn = cpu_to_be32(wr->remote_qpn);
 	dseg->qkey = cpu_to_be32(wr->remote_qkey);
 	dseg->vlan = to_mah(wr->ah)->av.eth.vlan;
@@ -2805,7 +2806,7 @@ static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev,
 	sqp_av.sl_tclass_flowlabel = av->ib.sl_tclass_flowlabel &
 			cpu_to_be32(0xf0000000);
 
-	memcpy(dseg->av, &sqp_av, sizeof (struct mlx4_av));
+	memcpy(dseg->av, &sqp_av, sizeof(struct mlx4_av));
 	if (qpt == MLX4_IB_QPT_PROXY_GSI)
 		dseg->dqpn = cpu_to_be32(dev->dev->caps.qp1_tunnel[port - 1]);
 	else
@@ -2831,10 +2832,10 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 
 	spc = MLX4_INLINE_ALIGN -
 		((unsigned long) (inl + 1) & (MLX4_INLINE_ALIGN - 1));
-	if (sizeof (hdr) <= spc) {
-		memcpy(inl + 1, &hdr, sizeof (hdr));
+	if (sizeof(hdr) <= spc) {
+		memcpy(inl + 1, &hdr, sizeof(hdr));
 		wmb();
-		inl->byte_count = cpu_to_be32(1 << 31 | sizeof (hdr));
+		inl->byte_count = cpu_to_be32(1 << 31 | sizeof(hdr));
 		i = 1;
 	} else {
 		memcpy(inl + 1, &hdr, spc);
@@ -2842,14 +2843,14 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 		inl->byte_count = cpu_to_be32(1 << 31 | spc);
 
 		inl = (void *) (inl + 1) + spc;
-		memcpy(inl + 1, (void *) &hdr + spc, sizeof (hdr) - spc);
+		memcpy(inl + 1, (void *) &hdr + spc, sizeof(hdr) - spc);
 		wmb();
-		inl->byte_count = cpu_to_be32(1 << 31 | (sizeof (hdr) - spc));
+		inl->byte_count = cpu_to_be32(1 << 31 | (sizeof(hdr) - spc));
 		i = 2;
 	}
 
 	*mlx_seg_len =
-		ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + sizeof (hdr), 16);
+		ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + sizeof(hdr), 16);
 }
 
 static void set_mlx_icrc_seg(void *dseg)
@@ -3031,27 +3032,23 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			case IB_WR_MASKED_ATOMIC_FETCH_AND_ADD:
 				set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
 					      atomic_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
 				set_atomic_seg(wqe, atomic_wr(wr));
-				wqe  += sizeof (struct mlx4_wqe_atomic_seg);
-
-				size += (sizeof (struct mlx4_wqe_raddr_seg) +
-					 sizeof (struct mlx4_wqe_atomic_seg)) / 16;
-
+				wqe  += sizeof(struct mlx4_wqe_atomic_seg);
+				size += (sizeof(struct mlx4_wqe_raddr_seg) +
+					 sizeof(struct mlx4_wqe_atomic_seg))
+					/ 16;
 				break;
 
 			case IB_WR_MASKED_ATOMIC_CMP_AND_SWP:
 				set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
 					      atomic_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
 				set_masked_atomic_seg(wqe, atomic_wr(wr));
-				wqe  += sizeof (struct mlx4_wqe_masked_atomic_seg);
-
-				size += (sizeof (struct mlx4_wqe_raddr_seg) +
-					 sizeof (struct mlx4_wqe_masked_atomic_seg)) / 16;
-
+				wqe  += sizeof(struct mlx4_wqe_masked_atomic_seg);
+				size += (sizeof(struct mlx4_wqe_raddr_seg) +
+					 sizeof(struct mlx4_wqe_masked_atomic_seg))
+					/ 16;
 				break;
 
 			case IB_WR_RDMA_READ:
@@ -3059,16 +3056,17 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			case IB_WR_RDMA_WRITE_WITH_IMM:
 				set_raddr_seg(wqe, rdma_wr(wr)->remote_addr,
 					      rdma_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-				size += sizeof (struct mlx4_wqe_raddr_seg) / 16;
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
+				size += sizeof(struct mlx4_wqe_raddr_seg) / 16;
 				break;
 
 			case IB_WR_LOCAL_INV:
 				ctrl->srcrb_flags |=
 					cpu_to_be32(MLX4_WQE_CTRL_STRONG_ORDER);
 				set_local_inv_seg(wqe, wr->ex.invalidate_rkey);
-				wqe  += sizeof (struct mlx4_wqe_local_inval_seg);
-				size += sizeof (struct mlx4_wqe_local_inval_seg) / 16;
+				wqe  += sizeof(struct mlx4_wqe_local_inval_seg);
+				size += sizeof(struct mlx4_wqe_local_inval_seg)
+					/ 16;
 				break;
 
 			case IB_WR_REG_MR:
@@ -3101,13 +3099,13 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			set_datagram_seg(wqe, ud_wr(wr));
 			/* set the forced-loopback bit in the data seg av */
 			*(__be32 *) wqe |= cpu_to_be32(0x80000000);
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 			break;
 		case MLX4_IB_QPT_UD:
 			set_datagram_seg(wqe, ud_wr(wr));
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 
 			if (wr->opcode == IB_WR_LSO) {
 				err = build_lso_seg(wqe, ud_wr(wr), qp, &seglen,
@@ -3148,8 +3146,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			set_tunnel_datagram_seg(to_mdev(ibqp->device), wqe,
 						ud_wr(wr),
 						qp->mlx4_ib_qp_type);
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 			build_tunnel_header(ud_wr(wr), wqe, &seglen);
 			wqe  += seglen;
 			size += seglen / 16;
@@ -3180,7 +3178,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 
 		dseg = wqe;
 		dseg += wr->num_sge - 1;
-		size += wr->num_sge * (sizeof (struct mlx4_wqe_data_seg) / 16);
+		size += wr->num_sge * (sizeof(struct mlx4_wqe_data_seg) / 16);
 
 		/* Add one more inline data segment for ICRC for MLX sends */
 		if (unlikely(qp->mlx4_ib_qp_type == MLX4_IB_QPT_SMI ||
@@ -3188,7 +3186,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			     qp->mlx4_ib_qp_type &
 			     (MLX4_IB_QPT_PROXY_SMI_OWNER | MLX4_IB_QPT_TUN_SMI_OWNER))) {
 			set_mlx_icrc_seg(dseg + 1);
-			size += sizeof (struct mlx4_wqe_data_seg) / 16;
+			size += sizeof(struct mlx4_wqe_data_seg) / 16;
 		}
 
 		for (i = wr->num_sge - 1; i >= 0; --i, --dseg)
@@ -3313,10 +3311,10 @@ int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
 		    MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) {
 			ib_dma_sync_single_for_device(ibqp->device,
 						      qp->sqp_proxy_rcv[ind].map,
-						      sizeof (struct mlx4_ib_proxy_sqp_hdr),
+						      sizeof(struct mlx4_ib_proxy_sqp_hdr),
 						      DMA_FROM_DEVICE);
 			scat->byte_count =
-				cpu_to_be32(sizeof (struct mlx4_ib_proxy_sqp_hdr));
+				cpu_to_be32(sizeof(struct mlx4_ib_proxy_sqp_hdr));
 			/* use dma lkey from upper layer entry */
 			scat->lkey = cpu_to_be32(wr->sg_list->lkey);
 			scat->addr = cpu_to_be64(qp->sqp_proxy_rcv[ind].map);
-- 
2.12.2

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

* [PATCH v2 15/17] IB/mlx4: Delete unwanted spaces behind usages of the sizeof operator
@ 2017-04-21 18:50         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:50 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, trivial

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 19:11:59 +0200

* Replace the source code "sizeof (" by "sizeof("
  according to the Linux coding style convention.

* Adjust indentation at a few places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/qp.c | 128 ++++++++++++++++++++--------------------
 1 file changed, 63 insertions(+), 65 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index c2a0f75d7d07..068abfdc9d01 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -342,39 +342,39 @@ static int send_wqe_overhead(enum mlx4_ib_qp_type type, u32 flags)
 	 */
 	switch (type) {
 	case MLX4_IB_QPT_UD:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg) +
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg) +
 			((flags & MLX4_IB_QP_LSO) ? MLX4_IB_LSO_HEADER_SPARE : 0);
 	case MLX4_IB_QPT_PROXY_SMI_OWNER:
 	case MLX4_IB_QPT_PROXY_SMI:
 	case MLX4_IB_QPT_PROXY_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg) + 64;
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg) + 64;
 	case MLX4_IB_QPT_TUN_SMI_OWNER:
 	case MLX4_IB_QPT_TUN_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_datagram_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_datagram_seg);
 
 	case MLX4_IB_QPT_UC:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_raddr_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_raddr_seg);
 	case MLX4_IB_QPT_RC:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
-			sizeof (struct mlx4_wqe_masked_atomic_seg) +
-			sizeof (struct mlx4_wqe_raddr_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
+			sizeof(struct mlx4_wqe_masked_atomic_seg) +
+			sizeof(struct mlx4_wqe_raddr_seg);
 	case MLX4_IB_QPT_SMI:
 	case MLX4_IB_QPT_GSI:
-		return sizeof (struct mlx4_wqe_ctrl_seg) +
+		return sizeof(struct mlx4_wqe_ctrl_seg) +
 			ALIGN(MLX4_IB_UD_HEADER_SIZE +
 			      DIV_ROUND_UP(MLX4_IB_UD_HEADER_SIZE,
 					   MLX4_INLINE_ALIGN) *
-			      sizeof (struct mlx4_wqe_inline_seg),
-			      sizeof (struct mlx4_wqe_data_seg)) +
+			      sizeof(struct mlx4_wqe_inline_seg),
+			      sizeof(struct mlx4_wqe_data_seg)) +
 			ALIGN(4 +
-			      sizeof (struct mlx4_wqe_inline_seg),
-			      sizeof (struct mlx4_wqe_data_seg));
+			      sizeof(struct mlx4_wqe_inline_seg),
+			      sizeof(struct mlx4_wqe_data_seg));
 	default:
-		return sizeof (struct mlx4_wqe_ctrl_seg);
+		return sizeof(struct mlx4_wqe_ctrl_seg);
 	}
 }
 
@@ -398,7 +398,8 @@ static int set_rq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 
 		qp->rq.wqe_cnt	 = roundup_pow_of_two(max(1U, cap->max_recv_wr));
 		qp->rq.max_gs	 = roundup_pow_of_two(max(1U, cap->max_recv_sge));
-		qp->rq.wqe_shift = ilog2(qp->rq.max_gs * sizeof (struct mlx4_wqe_data_seg));
+		qp->rq.wqe_shift = ilog2(qp->rq.max_gs
+					 * sizeof(struct mlx4_wqe_data_seg));
 	}
 
 	/* leave userspace return values as they were, so as not to break ABI */
@@ -426,7 +427,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	if (cap->max_send_wr  > (dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE) ||
 	    cap->max_send_sge > min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg) ||
 	    cap->max_inline_data + send_wqe_overhead(type, qp->flags) +
-	    sizeof (struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
+	    sizeof(struct mlx4_wqe_inline_seg) > dev->dev->caps.max_sq_desc_sz)
 		return -EINVAL;
 
 	/*
@@ -438,8 +439,8 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	    cap->max_send_sge + 2 > dev->dev->caps.max_sq_sg)
 		return -EINVAL;
 
-	s = max(cap->max_send_sge * sizeof (struct mlx4_wqe_data_seg),
-		cap->max_inline_data + sizeof (struct mlx4_wqe_inline_seg)) +
+	s = max(cap->max_send_sge * sizeof(struct mlx4_wqe_data_seg),
+		cap->max_inline_data + sizeof(struct mlx4_wqe_inline_seg)) +
 		send_wqe_overhead(type, qp->flags);
 
 	if (s > dev->dev->caps.max_sq_desc_sz)
@@ -509,7 +510,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
 	qp->sq.max_gs = (min(dev->dev->caps.max_sq_desc_sz,
 			     (qp->sq_max_wqes_per_wr << qp->sq.wqe_shift)) -
 			 send_wqe_overhead(type, qp->flags)) /
-		sizeof (struct mlx4_wqe_data_seg);
+		sizeof(struct mlx4_wqe_data_seg);
 
 	qp->buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) +
 		(qp->sq.wqe_cnt << qp->sq.wqe_shift);
@@ -563,13 +564,13 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 		return -ENOMEM;
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
 		qp->sqp_proxy_rcv[i].addr -			kmalloc(sizeof (struct mlx4_ib_proxy_sqp_hdr),
+			kmalloc(sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				GFP_KERNEL);
 		if (!qp->sqp_proxy_rcv[i].addr)
 			goto err;
 		qp->sqp_proxy_rcv[i].map  			ib_dma_map_single(dev, qp->sqp_proxy_rcv[i].addr,
-					  sizeof (struct mlx4_ib_proxy_sqp_hdr),
+					  sizeof(struct mlx4_ib_proxy_sqp_hdr),
 					  DMA_FROM_DEVICE);
 		if (ib_dma_mapping_error(dev, qp->sqp_proxy_rcv[i].map)) {
 			kfree(qp->sqp_proxy_rcv[i].addr);
@@ -582,7 +583,7 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 	while (i > 0) {
 		--i;
 		ib_dma_unmap_single(dev, qp->sqp_proxy_rcv[i].map,
-				    sizeof (struct mlx4_ib_proxy_sqp_hdr),
+				    sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				    DMA_FROM_DEVICE);
 		kfree(qp->sqp_proxy_rcv[i].addr);
 	}
@@ -597,7 +598,7 @@ static void free_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 
 	for (i = 0; i < qp->rq.wqe_cnt; i++) {
 		ib_dma_unmap_single(dev, qp->sqp_proxy_rcv[i].map,
-				    sizeof (struct mlx4_ib_proxy_sqp_hdr),
+				    sizeof(struct mlx4_ib_proxy_sqp_hdr),
 				    DMA_FROM_DEVICE);
 		kfree(qp->sqp_proxy_rcv[i].addr);
 	}
@@ -2320,7 +2321,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	/* for proxy-qp0 sends, need to add in size of tunnel header */
 	/* for tunnel-qp0 sends, tunnel header is already in s/g list */
 	if (sqp->qp.mlx4_ib_qp_type = MLX4_IB_QPT_PROXY_SMI_OWNER)
-		send_size += sizeof (struct mlx4_ib_tunnel_header);
+		send_size += sizeof(struct mlx4_ib_tunnel_header);
 
 	ib_ud_header_init(send_size, 1, 0, 0, 0, 0, 0, 0, &sqp->ud_header);
 
@@ -2402,7 +2403,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 	}
 
 	*mlx_seg_len -	ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + header_size, 16);
+	ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + header_size, 16);
 	return 0;
 }
 
@@ -2692,7 +2693,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 	}
 
 	*mlx_seg_len -		ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + header_size, 16);
+		ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + header_size, 16);
 	return 0;
 }
 
@@ -2783,7 +2784,7 @@ static void set_masked_atomic_seg(struct mlx4_wqe_masked_atomic_seg *aseg,
 static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
 			     struct ib_ud_wr *wr)
 {
-	memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof (struct mlx4_av));
+	memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof(struct mlx4_av));
 	dseg->dqpn = cpu_to_be32(wr->remote_qpn);
 	dseg->qkey = cpu_to_be32(wr->remote_qkey);
 	dseg->vlan = to_mah(wr->ah)->av.eth.vlan;
@@ -2805,7 +2806,7 @@ static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev,
 	sqp_av.sl_tclass_flowlabel = av->ib.sl_tclass_flowlabel &
 			cpu_to_be32(0xf0000000);
 
-	memcpy(dseg->av, &sqp_av, sizeof (struct mlx4_av));
+	memcpy(dseg->av, &sqp_av, sizeof(struct mlx4_av));
 	if (qpt = MLX4_IB_QPT_PROXY_GSI)
 		dseg->dqpn = cpu_to_be32(dev->dev->caps.qp1_tunnel[port - 1]);
 	else
@@ -2831,10 +2832,10 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 
 	spc = MLX4_INLINE_ALIGN -
 		((unsigned long) (inl + 1) & (MLX4_INLINE_ALIGN - 1));
-	if (sizeof (hdr) <= spc) {
-		memcpy(inl + 1, &hdr, sizeof (hdr));
+	if (sizeof(hdr) <= spc) {
+		memcpy(inl + 1, &hdr, sizeof(hdr));
 		wmb();
-		inl->byte_count = cpu_to_be32(1 << 31 | sizeof (hdr));
+		inl->byte_count = cpu_to_be32(1 << 31 | sizeof(hdr));
 		i = 1;
 	} else {
 		memcpy(inl + 1, &hdr, spc);
@@ -2842,14 +2843,14 @@ static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_se
 		inl->byte_count = cpu_to_be32(1 << 31 | spc);
 
 		inl = (void *) (inl + 1) + spc;
-		memcpy(inl + 1, (void *) &hdr + spc, sizeof (hdr) - spc);
+		memcpy(inl + 1, (void *) &hdr + spc, sizeof(hdr) - spc);
 		wmb();
-		inl->byte_count = cpu_to_be32(1 << 31 | (sizeof (hdr) - spc));
+		inl->byte_count = cpu_to_be32(1 << 31 | (sizeof(hdr) - spc));
 		i = 2;
 	}
 
 	*mlx_seg_len -		ALIGN(i * sizeof (struct mlx4_wqe_inline_seg) + sizeof (hdr), 16);
+		ALIGN(i * sizeof(struct mlx4_wqe_inline_seg) + sizeof(hdr), 16);
 }
 
 static void set_mlx_icrc_seg(void *dseg)
@@ -3031,27 +3032,23 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			case IB_WR_MASKED_ATOMIC_FETCH_AND_ADD:
 				set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
 					      atomic_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
 				set_atomic_seg(wqe, atomic_wr(wr));
-				wqe  += sizeof (struct mlx4_wqe_atomic_seg);
-
-				size += (sizeof (struct mlx4_wqe_raddr_seg) +
-					 sizeof (struct mlx4_wqe_atomic_seg)) / 16;
-
+				wqe  += sizeof(struct mlx4_wqe_atomic_seg);
+				size += (sizeof(struct mlx4_wqe_raddr_seg) +
+					 sizeof(struct mlx4_wqe_atomic_seg))
+					/ 16;
 				break;
 
 			case IB_WR_MASKED_ATOMIC_CMP_AND_SWP:
 				set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
 					      atomic_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
 				set_masked_atomic_seg(wqe, atomic_wr(wr));
-				wqe  += sizeof (struct mlx4_wqe_masked_atomic_seg);
-
-				size += (sizeof (struct mlx4_wqe_raddr_seg) +
-					 sizeof (struct mlx4_wqe_masked_atomic_seg)) / 16;
-
+				wqe  += sizeof(struct mlx4_wqe_masked_atomic_seg);
+				size += (sizeof(struct mlx4_wqe_raddr_seg) +
+					 sizeof(struct mlx4_wqe_masked_atomic_seg))
+					/ 16;
 				break;
 
 			case IB_WR_RDMA_READ:
@@ -3059,16 +3056,17 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			case IB_WR_RDMA_WRITE_WITH_IMM:
 				set_raddr_seg(wqe, rdma_wr(wr)->remote_addr,
 					      rdma_wr(wr)->rkey);
-				wqe  += sizeof (struct mlx4_wqe_raddr_seg);
-				size += sizeof (struct mlx4_wqe_raddr_seg) / 16;
+				wqe  += sizeof(struct mlx4_wqe_raddr_seg);
+				size += sizeof(struct mlx4_wqe_raddr_seg) / 16;
 				break;
 
 			case IB_WR_LOCAL_INV:
 				ctrl->srcrb_flags | 					cpu_to_be32(MLX4_WQE_CTRL_STRONG_ORDER);
 				set_local_inv_seg(wqe, wr->ex.invalidate_rkey);
-				wqe  += sizeof (struct mlx4_wqe_local_inval_seg);
-				size += sizeof (struct mlx4_wqe_local_inval_seg) / 16;
+				wqe  += sizeof(struct mlx4_wqe_local_inval_seg);
+				size += sizeof(struct mlx4_wqe_local_inval_seg)
+					/ 16;
 				break;
 
 			case IB_WR_REG_MR:
@@ -3101,13 +3099,13 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			set_datagram_seg(wqe, ud_wr(wr));
 			/* set the forced-loopback bit in the data seg av */
 			*(__be32 *) wqe |= cpu_to_be32(0x80000000);
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 			break;
 		case MLX4_IB_QPT_UD:
 			set_datagram_seg(wqe, ud_wr(wr));
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 
 			if (wr->opcode = IB_WR_LSO) {
 				err = build_lso_seg(wqe, ud_wr(wr), qp, &seglen,
@@ -3148,8 +3146,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			set_tunnel_datagram_seg(to_mdev(ibqp->device), wqe,
 						ud_wr(wr),
 						qp->mlx4_ib_qp_type);
-			wqe  += sizeof (struct mlx4_wqe_datagram_seg);
-			size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+			wqe  += sizeof(struct mlx4_wqe_datagram_seg);
+			size += sizeof(struct mlx4_wqe_datagram_seg) / 16;
 			build_tunnel_header(ud_wr(wr), wqe, &seglen);
 			wqe  += seglen;
 			size += seglen / 16;
@@ -3180,7 +3178,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 
 		dseg = wqe;
 		dseg += wr->num_sge - 1;
-		size += wr->num_sge * (sizeof (struct mlx4_wqe_data_seg) / 16);
+		size += wr->num_sge * (sizeof(struct mlx4_wqe_data_seg) / 16);
 
 		/* Add one more inline data segment for ICRC for MLX sends */
 		if (unlikely(qp->mlx4_ib_qp_type = MLX4_IB_QPT_SMI ||
@@ -3188,7 +3186,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			     qp->mlx4_ib_qp_type &
 			     (MLX4_IB_QPT_PROXY_SMI_OWNER | MLX4_IB_QPT_TUN_SMI_OWNER))) {
 			set_mlx_icrc_seg(dseg + 1);
-			size += sizeof (struct mlx4_wqe_data_seg) / 16;
+			size += sizeof(struct mlx4_wqe_data_seg) / 16;
 		}
 
 		for (i = wr->num_sge - 1; i >= 0; --i, --dseg)
@@ -3313,10 +3311,10 @@ int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
 		    MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) {
 			ib_dma_sync_single_for_device(ibqp->device,
 						      qp->sqp_proxy_rcv[ind].map,
-						      sizeof (struct mlx4_ib_proxy_sqp_hdr),
+						      sizeof(struct mlx4_ib_proxy_sqp_hdr),
 						      DMA_FROM_DEVICE);
 			scat->byte_count -				cpu_to_be32(sizeof (struct mlx4_ib_proxy_sqp_hdr));
+				cpu_to_be32(sizeof(struct mlx4_ib_proxy_sqp_hdr));
 			/* use dma lkey from upper layer entry */
 			scat->lkey = cpu_to_be32(wr->sg_list->lkey);
 			scat->addr = cpu_to_be64(qp->sqp_proxy_rcv[ind].map);
-- 
2.12.2


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

* [PATCH v2 16/17] IB/mlx4: Add spaces for better code readability
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:54         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:54 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, trivial

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 19:14:11 +0200

Use space characters at some source code places according to
the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 068abfdc9d01..15240163c399 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1065,7 +1065,7 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
 	list_del(&qp->cq_recv_list);
 	if (!is_user) {
 		__mlx4_ib_cq_clean(recv_cq, qp->mqp.qpn,
-				 qp->ibqp.srq ? to_msrq(qp->ibqp.srq): NULL);
+				   qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
 		if (send_cq != recv_cq)
 			__mlx4_ib_cq_clean(send_cq, qp->mqp.qpn, NULL);
 	}
@@ -2599,7 +2599,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 		u16 ether_type;
 		u16 pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 29) << 13;
 
-		ether_type = (!is_udp) ? ETH_P_IBOE:
+		ether_type = (!is_udp) ? ETH_P_IBOE :
 			(ip_version == 4 ? ETH_P_IP : ETH_P_IPV6);
 
 		mlx->sched_prio = cpu_to_be16(pcp);
-- 
2.12.2

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

* [PATCH v2 16/17] IB/mlx4: Add spaces for better code readability
@ 2017-04-21 18:54         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:54 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, trivial

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 19:14:11 +0200

Use space characters at some source code places according to
the Linux coding style convention.

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

diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 068abfdc9d01..15240163c399 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1065,7 +1065,7 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
 	list_del(&qp->cq_recv_list);
 	if (!is_user) {
 		__mlx4_ib_cq_clean(recv_cq, qp->mqp.qpn,
-				 qp->ibqp.srq ? to_msrq(qp->ibqp.srq): NULL);
+				   qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
 		if (send_cq != recv_cq)
 			__mlx4_ib_cq_clean(send_cq, qp->mqp.qpn, NULL);
 	}
@@ -2599,7 +2599,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 		u16 ether_type;
 		u16 pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 29) << 13;
 
-		ether_type = (!is_udp) ? ETH_P_IBOE:
+		ether_type = (!is_udp) ? ETH_P_IBOE :
 			(ip_version = 4 ? ETH_P_IP : ETH_P_IPV6);
 
 		mlx->sched_prio = cpu_to_be16(pcp);
-- 
2.12.2


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

* [PATCH v2 17/17] IB/mlx5: Less function calls in create_kernel_qp() after error detection
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-04-21 18:55         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:55 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 19:19:20 +0200

The kfree() function was called in up to five cases
by the create_kernel_qp() function during error handling
even if the passed data structure member contained a null pointer.

* Adjust jump targets according to the Linux coding style convention.

* Split a condition check for memory allocation failures so that
  each pointer from these function calls will be checked immediately.

  See also background information:
  Topic "CWE-754: Improper check for unusual or exceptional conditions"
  Link: https://cwe.mitre.org/data/definitions/754.html

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx5/qp.c | 43 ++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 1e98a8c9fab8..c7bfa8ffaf0d 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -934,7 +934,7 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 	*in = mlx5_vzalloc(*inlen);
 	if (!*in) {
 		err = -ENOMEM;
-		goto err_buf;
+		goto free_buffer;
 	}
 
 	qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
@@ -956,45 +956,56 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 	err = mlx5_db_alloc(dev->mdev, &qp->db);
 	if (err) {
 		mlx5_ib_dbg(dev, "err %d\n", err);
-		goto err_free;
+		goto vfree_in;
 	}
 
 	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
 				    sizeof(*qp->sq.wrid),
 				    GFP_KERNEL);
+	if (!qp->sq.wrid)
+		goto free_db;
+
 	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
 				       sizeof(*qp->sq.wr_data),
 				       GFP_KERNEL);
+	if (!qp->sq.wr_data)
+		goto free_sq_wrid;
+
 	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
 				    sizeof(*qp->rq.wrid),
 				    GFP_KERNEL);
+	if (!qp->rq.wrid)
+		goto free_sq_wr_data;
+
 	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
 				      sizeof(*qp->sq.w_list),
 				      GFP_KERNEL);
+	if (!qp->sq.w_list)
+		goto free_rq_wrid;
+
 	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
 					sizeof(*qp->sq.wqe_head),
 					GFP_KERNEL);
-	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
-	    !qp->sq.w_list || !qp->sq.wqe_head) {
-		err = -ENOMEM;
-		goto err_wrid;
-	}
+	if (!qp->sq.wqe_head)
+		goto free_sq_w_list;
+
 	qp->create_type = MLX5_QP_KERNEL;
 
 	return 0;
-
-err_wrid:
-	kfree(qp->sq.wqe_head);
+free_sq_w_list:
 	kfree(qp->sq.w_list);
-	kfree(qp->sq.wrid);
-	kfree(qp->sq.wr_data);
+free_rq_wrid:
 	kfree(qp->rq.wrid);
+free_sq_wr_data:
+	kfree(qp->sq.wr_data);
+free_sq_wrid:
+	kfree(qp->sq.wrid);
+free_db:
 	mlx5_db_free(dev->mdev, &qp->db);
-
-err_free:
+	err = -ENOMEM;
+vfree_in:
 	kvfree(*in);
-
-err_buf:
+free_buffer:
 	mlx5_buf_free(dev->mdev, &qp->buf);
 	return err;
 }
-- 
2.12.2

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

* [PATCH v2 17/17] IB/mlx5: Less function calls in create_kernel_qp() after error detection
@ 2017-04-21 18:55         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 18:55 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Apr 2017 19:19:20 +0200

The kfree() function was called in up to five cases
by the create_kernel_qp() function during error handling
even if the passed data structure member contained a null pointer.

* Adjust jump targets according to the Linux coding style convention.

* Split a condition check for memory allocation failures so that
  each pointer from these function calls will be checked immediately.

  See also background information:
  Topic "CWE-754: Improper check for unusual or exceptional conditions"
  Link: https://cwe.mitre.org/data/definitions/754.html

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx5/qp.c | 43 ++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 1e98a8c9fab8..c7bfa8ffaf0d 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -934,7 +934,7 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 	*in = mlx5_vzalloc(*inlen);
 	if (!*in) {
 		err = -ENOMEM;
-		goto err_buf;
+		goto free_buffer;
 	}
 
 	qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
@@ -956,45 +956,56 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
 	err = mlx5_db_alloc(dev->mdev, &qp->db);
 	if (err) {
 		mlx5_ib_dbg(dev, "err %d\n", err);
-		goto err_free;
+		goto vfree_in;
 	}
 
 	qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt,
 				    sizeof(*qp->sq.wrid),
 				    GFP_KERNEL);
+	if (!qp->sq.wrid)
+		goto free_db;
+
 	qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt,
 				       sizeof(*qp->sq.wr_data),
 				       GFP_KERNEL);
+	if (!qp->sq.wr_data)
+		goto free_sq_wrid;
+
 	qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt,
 				    sizeof(*qp->rq.wrid),
 				    GFP_KERNEL);
+	if (!qp->rq.wrid)
+		goto free_sq_wr_data;
+
 	qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt,
 				      sizeof(*qp->sq.w_list),
 				      GFP_KERNEL);
+	if (!qp->sq.w_list)
+		goto free_rq_wrid;
+
 	qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt,
 					sizeof(*qp->sq.wqe_head),
 					GFP_KERNEL);
-	if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
-	    !qp->sq.w_list || !qp->sq.wqe_head) {
-		err = -ENOMEM;
-		goto err_wrid;
-	}
+	if (!qp->sq.wqe_head)
+		goto free_sq_w_list;
+
 	qp->create_type = MLX5_QP_KERNEL;
 
 	return 0;
-
-err_wrid:
-	kfree(qp->sq.wqe_head);
+free_sq_w_list:
 	kfree(qp->sq.w_list);
-	kfree(qp->sq.wrid);
-	kfree(qp->sq.wr_data);
+free_rq_wrid:
 	kfree(qp->rq.wrid);
+free_sq_wr_data:
+	kfree(qp->sq.wr_data);
+free_sq_wrid:
+	kfree(qp->sq.wrid);
+free_db:
 	mlx5_db_free(dev->mdev, &qp->db);
-
-err_free:
+	err = -ENOMEM;
+vfree_in:
 	kvfree(*in);
-
-err_buf:
+free_buffer:
 	mlx5_buf_free(dev->mdev, &qp->buf);
 	return err;
 }
-- 
2.12.2


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

* Re: IB/mlx: Fine-tuning for several function implementations
  2017-04-21 18:29       ` [PATCH v2 00/17] IB/mlx: Fine-tuning for several function implementations Bart Van Assche
@ 2017-04-21 19:21           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 19:21 UTC (permalink / raw)
  To: Bart Van Assche, linux-rdma
  Cc: linux-kernel, kernel-janitors, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Majd Dibbiny, Matan Barak, Sean Hefty,
	Yishai Hadas

> Patches should either be useful to users of the Linux kernel, e.g. by adding
> new functionality or by fixing a bug, or to kernel developers, e.g. by making
> their workflow easier.

Such an expectation is generally fine.


> I don't think this patch series falls in either category

I find that my update suggestion touches some aspects for the desired
source code quality, doesn't it?


> so please drop these patches.

I hope that corresponding software improvements will be clarified further.

Regards,
Markus

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

* Re: IB/mlx: Fine-tuning for several function implementations
@ 2017-04-21 19:21           ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-04-21 19:21 UTC (permalink / raw)
  To: Bart Van Assche, linux-rdma
  Cc: linux-kernel, kernel-janitors, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Majd Dibbiny, Matan Barak, Sean Hefty,
	Yishai Hadas

> Patches should either be useful to users of the Linux kernel, e.g. by adding
> new functionality or by fixing a bug, or to kernel developers, e.g. by making
> their workflow easier.

Such an expectation is generally fine.


> I don't think this patch series falls in either category

I find that my update suggestion touches some aspects for the desired
source code quality, doesn't it?


> so please drop these patches.

I hope that corresponding software improvements will be clarified further.

Regards,
Markus

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

* Re: [PATCH v2 16/17] IB/mlx4: Add spaces for better code readability
  2017-04-21 18:54         ` SF Markus Elfring
@ 2017-04-21 19:28           ` Joe Perches
  -1 siblings, 0 replies; 179+ messages in thread
From: Joe Perches @ 2017-04-21 19:28 UTC (permalink / raw)
  To: SF Markus Elfring, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Majd Dibbiny, Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, trivial

On Fri, 2017-04-21 at 20:54 +0200, SF Markus Elfring wrote:

> Use space characters at some source code places according to
> the Linux coding style convention.

[]

> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
[]
> @@ -2599,7 +2599,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
>  		u16 ether_type;
>  		u16 pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 29) << 13;
>  
> -		ether_type = (!is_udp) ? ETH_P_IBOE:
> +		ether_type = (!is_udp) ? ETH_P_IBOE :
>  			(ip_version == 4 ? ETH_P_IP : ETH_P_IPV6);

Please refrain from tool generated mechanical changes.

Do try to make the code human readable and correct when
you are also making actual object code differences.

If this is to be modified at all then also please use
consistent ?: condition testing parentheses or perhaps
don't use parentheses at all.

Maybe even align the ETH_P_ uses like:

		ether_type = !is_udp		? ETH_P_IBOE :
			     ip_version == 4	? ETH_P_IP :
						  ETH_P_IPV6;


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

* Re: [PATCH v2 16/17] IB/mlx4: Add spaces for better code readability
@ 2017-04-21 19:28           ` Joe Perches
  0 siblings, 0 replies; 179+ messages in thread
From: Joe Perches @ 2017-04-21 19:28 UTC (permalink / raw)
  To: SF Markus Elfring, Doug Ledford, Hal Rosenstock, Leon Romanovsky,
	Majd Dibbiny, Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors, trivial

On Fri, 2017-04-21 at 20:54 +0200, SF Markus Elfring wrote:

> Use space characters at some source code places according to
> the Linux coding style convention.

[]

> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
[]
> @@ -2599,7 +2599,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
>  		u16 ether_type;
>  		u16 pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 29) << 13;
>  
> -		ether_type = (!is_udp) ? ETH_P_IBOE:
> +		ether_type = (!is_udp) ? ETH_P_IBOE :
>  			(ip_version = 4 ? ETH_P_IP : ETH_P_IPV6);

Please refrain from tool generated mechanical changes.

Do try to make the code human readable and correct when
you are also making actual object code differences.

If this is to be modified at all then also please use
consistent ?: condition testing parentheses or perhaps
don't use parentheses at all.

Maybe even align the ETH_P_ uses like:

		ether_type = !is_udp		? ETH_P_IBOE :
			     ip_version = 4	? ETH_P_IP :
						  ETH_P_IPV6;


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

* Re: IB/mlx: Fine-tuning for several function implementations
  2017-04-21 19:21           ` SF Markus Elfring
  (?)
@ 2017-04-21 19:55               ` Bart Van Assche
  -1 siblings, 0 replies; 179+ messages in thread
From: Bart Van Assche @ 2017-04-21 19:55 UTC (permalink / raw)
  To: elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: leonro-VPRAkNaXOzVWk0Htik3J/w,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	yishaih-VPRAkNaXOzVWk0Htik3J/w,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w, majd-VPRAkNaXOzVWk0Htik3J/w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA, matanb-VPRAkNaXOzVWk0Htik3J/w

On Fri, 2017-04-21 at 21:21 +0200, SF Markus Elfring wrote:
> > I don't think this patch series falls in either category
> 
> I find that my update suggestion touches some aspects for the desired
> source code quality, doesn't it?

No.

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] 179+ messages in thread

* Re: IB/mlx: Fine-tuning for several function implementations
@ 2017-04-21 19:55               ` Bart Van Assche
  0 siblings, 0 replies; 179+ messages in thread
From: Bart Van Assche @ 2017-04-21 19:55 UTC (permalink / raw)
  To: elfring, linux-rdma
  Cc: leonro, linux-kernel, kernel-janitors, yishaih, sean.hefty, majd,
	hal.rosenstock, dledford, matanb

On Fri, 2017-04-21 at 21:21 +0200, SF Markus Elfring wrote:
> > I don't think this patch series falls in either category
> 
> I find that my update suggestion touches some aspects for the desired
> source code quality, doesn't it?

No.

Bart.

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

* Re: IB/mlx: Fine-tuning for several function implementations
@ 2017-04-21 19:55               ` Bart Van Assche
  0 siblings, 0 replies; 179+ messages in thread
From: Bart Van Assche @ 2017-04-21 19:55 UTC (permalink / raw)
  To: elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: leonro-VPRAkNaXOzVWk0Htik3J/w,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	yishaih-VPRAkNaXOzVWk0Htik3J/w,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w, majd-VPRAkNaXOzVWk0Htik3J/w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA, matanb-VPRAkNaXOzVWk0Htik3J/w

On Fri, 2017-04-21 at 21:21 +0200, SF Markus Elfring wrote:
> > I don't think this patch series falls in either category
> 
> I find that my update suggestion touches some aspects for the desired
> source code quality, doesn't it?

No.

Bart.

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

* Re: [PATCH v2 00/17] IB/mlx: Fine-tuning for several function implementations
  2017-04-21 18:17       ` SF Markus Elfring
@ 2017-08-06 14:00         ` SF Markus Elfring
  -1 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-08-06 14:00 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

> Date: Fri, 21 Apr 2017 19:56:54 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (17):
>   Use kcalloc() in mlx4_ib_alloc_pv_bufs()
>   Use kmalloc_array() in six functions
>   Improve size determinations in six functions
>   Fix a typo in a comment line
>   Delete four unnecessary return statements
>   Delete an unnecessary check before kfree() in free_pv_object()
>   Move an assignment out of a check in forward_trap()
>   Enclose 46 expressions for sizeof by parentheses
>   Split a condition check in six functions
>   Delete an unnecessary variable in __mlx4_ib_query_gid()
>   Delete an unnecessary variable initialisation in mlx4_ib_add()
>   Delete an unnecessary variable assignment in mlx4_ib_add()
>   Delete an error message for a failed memory allocation in mlx4_ib_add()
>   Delete unnecessary braces in mlx4_ib_add()
>   Delete unwanted spaces behind usages of the sizeof operator
>   Add spaces for better code readability
>   Less function calls in create_kernel_qp() after error detection
> ---
> 
> v2:
> Changes were rebased on source files from Linux next-20170421.
> Some of them were recombined as requested by Doug Ledford.
> 
>  drivers/infiniband/hw/mlx4/mad.c  |  72 ++++++++--------
>  drivers/infiniband/hw/mlx4/main.c | 164 ++++++++++++++++++++----------------
>  drivers/infiniband/hw/mlx4/qp.c   | 173 +++++++++++++++++++-------------------
>  drivers/infiniband/hw/mlx5/qp.c   |  66 ++++++++++-----
>  drivers/infiniband/hw/mlx5/srq.c  |   5 +-
>  5 files changed, 261 insertions(+), 219 deletions(-)

Will the clarification be continued for the shown change possibilities?

Regards,
Markus

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

* Re: [PATCH v2 00/17] IB/mlx: Fine-tuning for several function implementations
@ 2017-08-06 14:00         ` SF Markus Elfring
  0 siblings, 0 replies; 179+ messages in thread
From: SF Markus Elfring @ 2017-08-06 14:00 UTC (permalink / raw)
  To: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Majd Dibbiny,
	Matan Barak, Sean Hefty, Yishai Hadas, linux-rdma
  Cc: LKML, kernel-janitors

> Date: Fri, 21 Apr 2017 19:56:54 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (17):
>   Use kcalloc() in mlx4_ib_alloc_pv_bufs()
>   Use kmalloc_array() in six functions
>   Improve size determinations in six functions
>   Fix a typo in a comment line
>   Delete four unnecessary return statements
>   Delete an unnecessary check before kfree() in free_pv_object()
>   Move an assignment out of a check in forward_trap()
>   Enclose 46 expressions for sizeof by parentheses
>   Split a condition check in six functions
>   Delete an unnecessary variable in __mlx4_ib_query_gid()
>   Delete an unnecessary variable initialisation in mlx4_ib_add()
>   Delete an unnecessary variable assignment in mlx4_ib_add()
>   Delete an error message for a failed memory allocation in mlx4_ib_add()
>   Delete unnecessary braces in mlx4_ib_add()
>   Delete unwanted spaces behind usages of the sizeof operator
>   Add spaces for better code readability
>   Less function calls in create_kernel_qp() after error detection
> ---
> 
> v2:
> Changes were rebased on source files from Linux next-20170421.
> Some of them were recombined as requested by Doug Ledford.
> 
>  drivers/infiniband/hw/mlx4/mad.c  |  72 ++++++++--------
>  drivers/infiniband/hw/mlx4/main.c | 164 ++++++++++++++++++++----------------
>  drivers/infiniband/hw/mlx4/qp.c   | 173 +++++++++++++++++++-------------------
>  drivers/infiniband/hw/mlx5/qp.c   |  66 ++++++++++-----
>  drivers/infiniband/hw/mlx5/srq.c  |   5 +-
>  5 files changed, 261 insertions(+), 219 deletions(-)

Will the clarification be continued for the shown change possibilities?

Regards,
Markus

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

end of thread, other threads:[~2017-08-06 14:00 UTC | newest]

Thread overview: 179+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-18 20:45 [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations SF Markus Elfring
2017-02-18 20:45 ` SF Markus Elfring
2017-02-18 20:51 ` [PATCH 04/29] IB/mlx4: Improve another size determination in alloc_pv_object() SF Markus Elfring
2017-02-18 20:51   ` SF Markus Elfring
2017-02-19 17:06   ` Majd Dibbiny
2017-02-18 20:52 ` [PATCH 05/29] IB/mlx4: Fix a typo in a comment line SF Markus Elfring
2017-02-18 20:52   ` SF Markus Elfring
2017-02-19 17:06   ` Majd Dibbiny
2017-02-18 21:00 ` [PATCH 12/29] IB/mlx4: Enclose 17 expressions for the sizeof operator by parentheses SF Markus Elfring
2017-02-18 21:00   ` SF Markus Elfring
2017-02-19 17:21   ` Majd Dibbiny
2017-02-19 17:21     ` Majd Dibbiny
     [not found] ` <1935365a-bd7c-461e-6a84-0c5d3a501fff-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-02-18 20:47   ` [PATCH 01/29] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs() SF Markus Elfring
2017-02-18 20:47     ` SF Markus Elfring
2017-02-18 20:47     ` SF Markus Elfring
2017-02-19 17:06     ` Majd Dibbiny
2017-02-18 20:49   ` [PATCH 02/29] IB/mlx4: Improve another size determination " SF Markus Elfring
2017-02-18 20:49     ` SF Markus Elfring
2017-02-18 20:49     ` SF Markus Elfring
     [not found]     ` <14b2089f-f52c-0b18-90d5-810abc9f9fd6-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-02-19 17:06       ` Majd Dibbiny
2017-02-19 17:06         ` Majd Dibbiny
2017-02-19 17:06         ` Majd Dibbiny
2017-02-18 20:50   ` [PATCH 03/29] IB/mlx4: Improve another size determination in mlx4_ib_alloc_demux_ctx() SF Markus Elfring
2017-02-18 20:50     ` SF Markus Elfring
2017-02-18 20:50     ` SF Markus Elfring
2017-02-19 17:06     ` Majd Dibbiny
2017-02-18 20:54   ` [PATCH 06/29] IB/mlx4: Delete three unnecessary return statements SF Markus Elfring
2017-02-18 20:54     ` SF Markus Elfring
2017-02-18 20:54     ` SF Markus Elfring
2017-02-19 17:06     ` Majd Dibbiny
2017-02-18 20:55   ` [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change() SF Markus Elfring
2017-02-18 20:55     ` SF Markus Elfring
2017-02-18 20:55     ` SF Markus Elfring
     [not found]     ` <951c0746-b88e-8ee7-78e8-5be2a53a2e43-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-02-19 17:09       ` Majd Dibbiny
2017-02-19 17:09         ` Majd Dibbiny
2017-02-19 17:09         ` Majd Dibbiny
2017-02-18 20:56   ` [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object() SF Markus Elfring
2017-02-18 20:56     ` [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_objec SF Markus Elfring
2017-02-18 20:56     ` [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_object() SF Markus Elfring
2017-02-19 17:11     ` Majd Dibbiny
2017-02-19 17:11       ` [PATCH 08/29] IB/mlx4: Delete an unnecessary check before the function call "kfree" in free_pv_o Majd Dibbiny
2017-02-18 20:57   ` [PATCH 09/29] IB/mlx4: Move an assignment out of a check in forward_trap() SF Markus Elfring
2017-02-18 20:57     ` SF Markus Elfring
2017-02-18 20:57     ` SF Markus Elfring
2017-02-19 17:12     ` Majd Dibbiny
2017-02-18 20:58   ` [PATCH 10/29] IB/mlx4: Enclose 15 expressions for the sizeof operator by parentheses SF Markus Elfring
2017-02-18 20:58     ` SF Markus Elfring
2017-02-18 20:58     ` SF Markus Elfring
2017-02-19 17:21     ` Majd Dibbiny
2017-02-19 17:21       ` Majd Dibbiny
2017-02-18 20:59   ` [PATCH 11/29] IB/mlx4: Use kmalloc_array() in three functions SF Markus Elfring
2017-02-18 20:59     ` SF Markus Elfring
2017-02-18 20:59     ` SF Markus Elfring
2017-02-19 17:21     ` Majd Dibbiny
2017-02-18 21:01   ` [PATCH 13/29] IB/mlx4: Split a condition check in five functions SF Markus Elfring
2017-02-18 21:01     ` SF Markus Elfring
2017-02-18 21:01     ` SF Markus Elfring
2017-02-19 17:21     ` Majd Dibbiny
2017-02-18 21:02   ` [PATCH 14/29] IB/mlx4: Delete an unnecessary variable in __mlx4_ib_query_gid() SF Markus Elfring
2017-02-18 21:02     ` SF Markus Elfring
2017-02-18 21:02     ` SF Markus Elfring
2017-02-18 21:04   ` [PATCH 16/29] IB/mlx4: Improve another size determination in do_slave_init() SF Markus Elfring
2017-02-18 21:04     ` SF Markus Elfring
2017-02-18 21:04     ` SF Markus Elfring
2017-02-18 21:05   ` [PATCH 17/29] IB/mlx4: Improve another size determination in mlx4_ib_add() SF Markus Elfring
2017-02-18 21:05     ` SF Markus Elfring
2017-02-18 21:05     ` SF Markus Elfring
2017-02-19 17:36     ` Majd Dibbiny
     [not found]     ` <2269d63f-433d-b62b-06f2-38a4d9d466f4-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-02-19 17:36       ` Majd Dibbiny
2017-02-19 17:36         ` Majd Dibbiny
2017-02-19 17:36         ` Majd Dibbiny
2017-02-18 21:06   ` [PATCH 18/29] IB/mlx4: Delete an unnecessary variable initialisation " SF Markus Elfring
2017-02-18 21:06     ` SF Markus Elfring
2017-02-18 21:06     ` SF Markus Elfring
2017-02-18 21:08   ` [PATCH 19/29] IB/mlx4: Delete an unnecessary variable assignment " SF Markus Elfring
2017-02-18 21:08     ` SF Markus Elfring
2017-02-18 21:08     ` SF Markus Elfring
     [not found]     ` <3f4e69c8-a030-fb75-26bb-e14208c141c5-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-02-19 19:42       ` Majd Dibbiny
2017-02-19 19:42         ` Majd Dibbiny
2017-02-19 19:42         ` Majd Dibbiny
2017-02-18 21:10   ` [PATCH 20/29] IB/mlx4: Delete an error message for a failed memory allocation " SF Markus Elfring
2017-02-18 21:10     ` SF Markus Elfring
2017-02-18 21:10     ` SF Markus Elfring
2017-02-19 19:48     ` Majd Dibbiny
2017-02-18 21:12   ` [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs() SF Markus Elfring
2017-02-18 21:12     ` SF Markus Elfring
2017-02-18 21:12     ` SF Markus Elfring
     [not found]     ` <b7f36e89-a3c8-0842-d496-0dbb64fdd73f-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-02-19 19:53       ` Majd Dibbiny
2017-02-19 19:53         ` Majd Dibbiny
2017-02-19 19:53         ` Majd Dibbiny
2017-02-18 21:15   ` [PATCH 25/29] IB/mlx4: Add spaces for better code readability SF Markus Elfring
2017-02-18 21:15     ` SF Markus Elfring
2017-02-18 21:15     ` SF Markus Elfring
2017-02-18 21:17   ` [PATCH 27/29] IB/mlx5: Use kmalloc_array() in create_kernel_qp() SF Markus Elfring
2017-02-18 21:17     ` SF Markus Elfring
2017-02-18 21:17     ` SF Markus Elfring
2017-02-18 21:18   ` [PATCH 28/29] IB/mlx5: Less function calls in create_kernel_qp() after error detection SF Markus Elfring
2017-02-18 21:18     ` SF Markus Elfring
2017-02-18 21:18     ` SF Markus Elfring
2017-02-18 21:19   ` [PATCH 29/29] IB/mlx5: Use kmalloc_array() in create_srq_kernel() SF Markus Elfring
2017-02-18 21:19     ` SF Markus Elfring
2017-02-18 21:19     ` SF Markus Elfring
2017-04-20 20:37   ` [PATCH 00/29] IB/mlx: Fine-tuning for several function implementations Doug Ledford
2017-04-20 20:37     ` Doug Ledford
2017-04-20 20:37     ` Doug Ledford
2017-04-20 21:02     ` SF Markus Elfring
2017-04-20 21:02       ` SF Markus Elfring
     [not found]       ` <8f433ee0-4dde-44db-cd36-fc2831b45df6-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-04-21  2:23         ` Doug Ledford
2017-04-21  2:23           ` Doug Ledford
2017-04-21  2:23           ` Doug Ledford
2017-04-21 18:17     ` [PATCH v2 00/17] " SF Markus Elfring
2017-04-21 18:17       ` SF Markus Elfring
2017-04-21 18:21       ` [PATCH v2 01/17] IB/mlx4: Use kcalloc() in mlx4_ib_alloc_pv_bufs() SF Markus Elfring
2017-04-21 18:21         ` SF Markus Elfring
2017-04-21 18:29       ` [PATCH v2 00/17] IB/mlx: Fine-tuning for several function implementations Bart Van Assche
2017-04-21 19:21         ` SF Markus Elfring
2017-04-21 19:21           ` SF Markus Elfring
     [not found]           ` <6c7fd04f-5c46-a35e-822c-567dd7538521-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-04-21 19:55             ` Bart Van Assche
2017-04-21 19:55               ` Bart Van Assche
2017-04-21 19:55               ` Bart Van Assche
2017-04-21 18:30       ` [PATCH v2 04/17] IB/mlx4: Fix a typo in a comment line SF Markus Elfring
2017-04-21 18:30         ` SF Markus Elfring
2017-04-21 18:33       ` [PATCH v2 05/17] IB/mlx4: Delete four unnecessary return statements SF Markus Elfring
2017-04-21 18:33         ` SF Markus Elfring
2017-04-21 18:36       ` [PATCH v2 06/17] IB/mlx4: Delete an unnecessary check before kfree() in free_pv_object() SF Markus Elfring
2017-04-21 18:36         ` SF Markus Elfring
     [not found]       ` <a56f9301-e116-c59c-681a-9108519920e5-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-04-21 18:24         ` [PATCH v2 02/17] IB/mlx: Use kmalloc_array() in six functions SF Markus Elfring
2017-04-21 18:24           ` SF Markus Elfring
2017-04-21 18:24           ` SF Markus Elfring
2017-04-21 18:28         ` [PATCH v2 03/17] IB/mlx4: Improve size determinations " SF Markus Elfring
2017-04-21 18:28           ` SF Markus Elfring
2017-04-21 18:28           ` SF Markus Elfring
2017-04-21 18:37         ` [PATCH v2 07/17] IB/mlx4: Move an assignment out of a check in forward_trap() SF Markus Elfring
2017-04-21 18:37           ` SF Markus Elfring
2017-04-21 18:37           ` SF Markus Elfring
2017-04-21 18:40         ` [PATCH v2 09/17] IB/mlx4: Split a condition check in six functions SF Markus Elfring
2017-04-21 18:40           ` SF Markus Elfring
2017-04-21 18:40           ` SF Markus Elfring
2017-04-21 18:44         ` [PATCH v2 11/17] IB/mlx4: Delete an unnecessary variable initialisation in mlx4_ib_add() SF Markus Elfring
2017-04-21 18:44           ` SF Markus Elfring
2017-04-21 18:44           ` SF Markus Elfring
2017-04-21 18:48         ` [PATCH v2 14/17] IB/mlx4: Delete unnecessary braces " SF Markus Elfring
2017-04-21 18:48           ` SF Markus Elfring
2017-04-21 18:48           ` SF Markus Elfring
2017-04-21 18:38       ` [PATCH v2 08/17] IB/mlx4: Enclose 46 expressions for sizeof by parentheses SF Markus Elfring
2017-04-21 18:38         ` SF Markus Elfring
2017-04-21 18:42       ` [PATCH v2 10/17] IB/mlx4: Delete an unnecessary variable in __mlx4_ib_query_gid() SF Markus Elfring
2017-04-21 18:42         ` SF Markus Elfring
2017-04-21 18:45       ` [PATCH v2 12/17] IB/mlx4: Delete an unnecessary variable assignment in mlx4_ib_add() SF Markus Elfring
2017-04-21 18:45         ` SF Markus Elfring
2017-04-21 18:46       ` [PATCH v2 13/17] IB/mlx4: Delete an error message for a failed memory allocation " SF Markus Elfring
2017-04-21 18:46         ` SF Markus Elfring
2017-04-21 18:50       ` [PATCH v2 15/17] IB/mlx4: Delete unwanted spaces behind usages of the sizeof operator SF Markus Elfring
2017-04-21 18:50         ` SF Markus Elfring
2017-04-21 18:54       ` [PATCH v2 16/17] IB/mlx4: Add spaces for better code readability SF Markus Elfring
2017-04-21 18:54         ` SF Markus Elfring
2017-04-21 19:28         ` Joe Perches
2017-04-21 19:28           ` Joe Perches
2017-04-21 18:55       ` [PATCH v2 17/17] IB/mlx5: Less function calls in create_kernel_qp() after error detection SF Markus Elfring
2017-04-21 18:55         ` SF Markus Elfring
2017-08-06 14:00       ` [PATCH v2 00/17] IB/mlx: Fine-tuning for several function implementations SF Markus Elfring
2017-08-06 14:00         ` SF Markus Elfring
2017-02-18 21:03 ` [PATCH 15/29] IB/mlx4: Delete an unnecessary return statement in do_slave_init() SF Markus Elfring
2017-02-18 21:03   ` SF Markus Elfring
2017-02-19 17:36   ` Majd Dibbiny
2017-02-18 21:11 ` [PATCH 21/29] IB/mlx4: Delete unnecessary braces in mlx4_ib_add() SF Markus Elfring
2017-02-18 21:11   ` SF Markus Elfring
     [not found]   ` <6abe0f08-b308-08ac-9f84-868887c0218c-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-02-19 19:51     ` Majd Dibbiny
2017-02-19 19:51       ` Majd Dibbiny
2017-02-19 19:51       ` Majd Dibbiny
2017-02-18 21:13 ` [PATCH 23/29] IB/mlx4: Improve size determinations in create_qp_common() SF Markus Elfring
2017-02-18 21:13   ` SF Markus Elfring
     [not found]   ` <9b7e9f1c-ccf4-6de6-158f-cd9f86f5edb4-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-02-19 19:54     ` Majd Dibbiny
2017-02-19 19:54       ` Majd Dibbiny
2017-02-19 19:54       ` Majd Dibbiny
2017-02-18 21:14 ` [PATCH 24/29] IB/mlx4: Delete unwanted spaces behind usages of the sizeof operator SF Markus Elfring
2017-02-18 21:14   ` SF Markus Elfring
2017-02-18 21:16 ` [PATCH 26/29] IB/mlx4: Enclose 14 expressions for the sizeof operator by parentheses SF Markus Elfring
2017-02-18 21:16   ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.