diff mbox

[04/14] RDMA/cxgb4: Use common error handling code in recover_queues()

Message ID e8abf0d7-1f4d-d218-194c-4c831dbf72d5@users.sourceforge.net (mailing list archive)
State Rejected
Headers show

Commit Message

SF Markus Elfring Feb. 8, 2017, 9:14 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 8 Feb 2017 15:51:58 +0100

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

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

Comments

Johannes Thumshirn Feb. 9, 2017, 9:30 a.m. UTC | #1
On 02/08/2017 10:14 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 8 Feb 2017 15:51:58 +0100
> 
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/infiniband/hw/cxgb4/device.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
> index 444c28206dae..46410c4a9afb 100644
> --- a/drivers/infiniband/hw/cxgb4/device.c
> +++ b/drivers/infiniband/hw/cxgb4/device.c
> @@ -1467,10 +1467,9 @@ static void recover_queues(struct uld_ctx *ctx)
>  	idr_for_each(&ctx->dev->qpidr, count_qps, &count);
>  
>  	qp_list.qps = kcalloc(count, sizeof(*qp_list.qps), GFP_ATOMIC);
> -	if (!qp_list.qps) {
> -		spin_unlock_irq(&ctx->dev->lock);
> -		return;
> -	}
> +	if (!qp_list.qps)
> +		goto unlock;
> +
>  	qp_list.idx = 0;
>  
>  	/* add and ref each qp so it doesn't get freed */
> @@ -1488,6 +1487,7 @@ static void recover_queues(struct uld_ctx *ctx)
>  	spin_lock_irq(&ctx->dev->lock);
>  	WARN_ON(ctx->dev->db_state != RECOVERY);
>  	ctx->dev->db_state = STOPPED;
> +unlock:
>  	spin_unlock_irq(&ctx->dev->lock);
>  }
>  
> 

This patch is rather pointless IMHO. Using goto labels only brings
benefits if you have more than one code path jumping to them this one
just confuses the readers.

Byte,
	Johannes
diff mbox

Patch

diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
index 444c28206dae..46410c4a9afb 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -1467,10 +1467,9 @@  static void recover_queues(struct uld_ctx *ctx)
 	idr_for_each(&ctx->dev->qpidr, count_qps, &count);
 
 	qp_list.qps = kcalloc(count, sizeof(*qp_list.qps), GFP_ATOMIC);
-	if (!qp_list.qps) {
-		spin_unlock_irq(&ctx->dev->lock);
-		return;
-	}
+	if (!qp_list.qps)
+		goto unlock;
+
 	qp_list.idx = 0;
 
 	/* add and ref each qp so it doesn't get freed */
@@ -1488,6 +1487,7 @@  static void recover_queues(struct uld_ctx *ctx)
 	spin_lock_irq(&ctx->dev->lock);
 	WARN_ON(ctx->dev->db_state != RECOVERY);
 	ctx->dev->db_state = STOPPED;
+unlock:
 	spin_unlock_irq(&ctx->dev->lock);
 }