diff mbox series

[linux-next,v2] RDMA: simplify if-if to if-else

Message ID 20220331130525.14750-1-guozhengkui@vivo.com (mailing list archive)
State Changes Requested
Delegated to: Jason Gunthorpe
Headers show
Series [linux-next,v2] RDMA: simplify if-if to if-else | expand

Commit Message

Guo Zhengkui March 31, 2022, 1:05 p.m. UTC
Replace `if (!ret)` with `else` for simplification and
fix the unbalanced curly brackets.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
 drivers/infiniband/hw/irdma/puda.c |  8 ++++----
 drivers/infiniband/hw/mlx4/mcg.c   | 29 +++++++++++++++++------------
 2 files changed, 21 insertions(+), 16 deletions(-)

Comments

Shiraz Saleem March 31, 2022, 1:58 p.m. UTC | #1
> Subject: [PATCH linux-next v2] RDMA: simplify if-if to if-else
> 
> Replace `if (!ret)` with `else` for simplification and fix the unbalanced curly
> brackets.
> 
> Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
> ---
>  drivers/infiniband/hw/irdma/puda.c |  8 ++++----

Acked-by: Shiraz Saleem <shiraz.saleem@intel.com>
Jason Gunthorpe April 4, 2022, 1:56 p.m. UTC | #2
On Thu, Mar 31, 2022 at 09:05:25PM +0800, Guo Zhengkui wrote:
> @@ -632,7 +632,7 @@ static int handle_join_req(struct mcast_group *group, u8 join_mask,
>  			kfree(req);
>  			ref = 1;
>  			group->state = group->prev_state;
> -		} else
> +		} else {
>  			group->state = MCAST_JOIN_SENT;
>  	}

This doesn't compile.

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/irdma/puda.c b/drivers/infiniband/hw/irdma/puda.c
index 397f3d070f90..8dd38e1f6cf0 100644
--- a/drivers/infiniband/hw/irdma/puda.c
+++ b/drivers/infiniband/hw/irdma/puda.c
@@ -838,11 +838,11 @@  static void irdma_puda_free_qp(struct irdma_puda_rsrc *rsrc)
 	}
 
 	ret = irdma_sc_qp_destroy(&rsrc->qp, 0, false, true, true);
-	if (ret)
+	if (ret) {
 		ibdev_dbg(to_ibdev(dev),
 			  "PUDA: error puda qp destroy wqe, status = %d\n",
 			  ret);
-	if (!ret) {
+	} else {
 		ret = irdma_sc_poll_for_cqp_op_done(dev->cqp, IRDMA_CQP_OP_DESTROY_QP,
 						    &compl_info);
 		if (ret)
@@ -869,9 +869,9 @@  static void irdma_puda_free_cq(struct irdma_puda_rsrc *rsrc)
 	}
 
 	ret = irdma_sc_cq_destroy(&rsrc->cq, 0, true);
-	if (ret)
+	if (ret) {
 		ibdev_dbg(to_ibdev(dev), "PUDA: error ieq cq destroy\n");
-	if (!ret) {
+	} else {
 		ret = irdma_sc_poll_for_cqp_op_done(dev->cqp, IRDMA_CQP_OP_DESTROY_CQ,
 						    &compl_info);
 		if (ret)
diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
index 33f525b744f2..c0beb9f4030a 100644
--- a/drivers/infiniband/hw/mlx4/mcg.c
+++ b/drivers/infiniband/hw/mlx4/mcg.c
@@ -304,13 +304,11 @@  static int send_leave_to_wire(struct mcast_group *group, u8 join_state)
 	ret = send_mad_to_wire(group->demux, (struct ib_mad *)&mad);
 	if (ret)
 		group->state = MCAST_IDLE;
-
 	/* set timeout handler */
-	if (!ret) {
+	else
 		/* calls mlx4_ib_mcg_timeout_handler */
 		queue_delayed_work(group->demux->mcg_wq, &group->timeout_work,
 				msecs_to_jiffies(MAD_TIMEOUT_MS));
-	}
 
 	return ret;
 }
@@ -561,8 +559,9 @@  static void mlx4_ib_mcg_timeout_handler(struct work_struct *work)
 				return;
 			}
 			mutex_lock(&group->lock);
-		} else
+		} else {
 			mcg_warn_group(group, "DRIVER BUG\n");
+		}
 	} else if (group->state == MCAST_LEAVE_SENT) {
 		if (group->rec.scope_join_state & 0xf)
 			group->rec.scope_join_state &= 0xf0;
@@ -571,8 +570,9 @@  static void mlx4_ib_mcg_timeout_handler(struct work_struct *work)
 		if (release_group(group, 1))
 			return;
 		mutex_lock(&group->lock);
-	} else
+	} else {
 		mcg_warn_group(group, "invalid state %s\n", get_state_string(group->state));
+	}
 	group->state = MCAST_IDLE;
 	atomic_inc(&group->refcount);
 	if (!queue_work(group->demux->mcg_wq, &group->work))
@@ -632,7 +632,7 @@  static int handle_join_req(struct mcast_group *group, u8 join_mask,
 			kfree(req);
 			ref = 1;
 			group->state = group->prev_state;
-		} else
+		} else {
 			group->state = MCAST_JOIN_SENT;
 	}
 
@@ -681,10 +681,12 @@  static void mlx4_ib_mcg_work_handler(struct work_struct *work)
 						list_del(&req->func_list);
 						kfree(req);
 						++rc;
-					} else
+					} else {
 						mcg_warn_group(group, "no request for failed join\n");
-			} else if (method == IB_SA_METHOD_DELETE_RESP && group->demux->flushing)
+					}
+			} else if (method == IB_SA_METHOD_DELETE_RESP && group->demux->flushing) {
 				++rc;
+			}
 		} else {
 			u8 resp_join_state;
 			u8 cur_join_state;
@@ -697,8 +699,9 @@  static void mlx4_ib_mcg_work_handler(struct work_struct *work)
 				/* successfull join */
 				if (!cur_join_state && resp_join_state)
 					--rc;
-			} else if (!resp_join_state)
-					++rc;
+			} else if (!resp_join_state) {
+				++rc;
+			}
 			memcpy(&group->rec, group->response_sa_mad.data, sizeof group->rec);
 		}
 		group->state = MCAST_IDLE;
@@ -730,8 +733,9 @@  static void mlx4_ib_mcg_work_handler(struct work_struct *work)
 			if (send_leave_to_wire(group, req_join_state)) {
 				group->state = group->prev_state;
 				++rc;
-			} else
+			} else {
 				group->state = MCAST_LEAVE_SENT;
+			}
 		}
 	}
 
@@ -898,8 +902,9 @@  int mlx4_ib_mcg_demux_handler(struct ib_device *ibdev, int port, int slave,
 				__be64 tid = mad->mad_hdr.tid;
 				*(u8 *)(&tid) = (u8)slave; /* in group we kept the modified TID */
 				group = search_relocate_mgid0_group(ctx, tid, &rec->mgid);
-			} else
+			} else {
 				group = NULL;
+			}
 		}
 
 		if (!group)