diff mbox series

[v2,2/4] qla2xxx: Simplify return value logic in qla2x00_get_sp_from_handle()

Message ID 20200831161854.70879-3-dwagner@suse.de (mailing list archive)
State Superseded
Headers show
Series qla2xxx: A couple crash fixes | expand

Commit Message

Daniel Wagner Aug. 31, 2020, 4:18 p.m. UTC
Refactor qla2x00_get_sp_from_handle() to avoid the unecessary
goto if early returns are used. With this we can also avoid
preinitilzing the sp pointer.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 drivers/scsi/qla2xxx/qla_isr.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Arun Easi Sept. 8, 2020, 6:43 a.m. UTC | #1
On Mon, 31 Aug 2020, 9:18am, Daniel Wagner wrote:

> 
> Refactor qla2x00_get_sp_from_handle() to avoid the unecessary
> goto if early returns are used. With this we can also avoid
> preinitilzing the sp pointer.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  drivers/scsi/qla2xxx/qla_isr.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
> index 27bcd346af7c..5d278155e4e7 100644
> --- a/drivers/scsi/qla2xxx/qla_isr.c
> +++ b/drivers/scsi/qla2xxx/qla_isr.c
> @@ -1716,7 +1716,7 @@ qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
>  {
>  	struct qla_hw_data *ha = vha->hw;
>  	sts_entry_t *pkt = iocb;
> -	srb_t *sp = NULL;
> +	srb_t *sp;
>  	uint16_t index;
>  
>  	index = LSW(pkt->handle);
> @@ -1728,13 +1728,13 @@ qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
>  			set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
>  		else
>  			set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
> -		goto done;
> +		return NULL;
>  	}
>  	sp = req->outstanding_cmds[index];
>  	if (!sp) {
>  		ql_log(ql_log_warn, vha, 0x5032,
>  		    "Invalid completion handle (%x) -- timed-out.\n", index);
> -		return sp;
> +		return NULL;
>  	}
>  	if (sp->handle != index) {
>  		ql_log(ql_log_warn, vha, 0x5033,
> @@ -1743,8 +1743,6 @@ qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
>  	}
>  
>  	req->outstanding_cmds[index] = NULL;
> -
> -done:
>  	return sp;
>  }
>  

Looks good.

Regards,
-Arun
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 27bcd346af7c..5d278155e4e7 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1716,7 +1716,7 @@  qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
 {
 	struct qla_hw_data *ha = vha->hw;
 	sts_entry_t *pkt = iocb;
-	srb_t *sp = NULL;
+	srb_t *sp;
 	uint16_t index;
 
 	index = LSW(pkt->handle);
@@ -1728,13 +1728,13 @@  qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
 			set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
 		else
 			set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
-		goto done;
+		return NULL;
 	}
 	sp = req->outstanding_cmds[index];
 	if (!sp) {
 		ql_log(ql_log_warn, vha, 0x5032,
 		    "Invalid completion handle (%x) -- timed-out.\n", index);
-		return sp;
+		return NULL;
 	}
 	if (sp->handle != index) {
 		ql_log(ql_log_warn, vha, 0x5033,
@@ -1743,8 +1743,6 @@  qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
 	}
 
 	req->outstanding_cmds[index] = NULL;
-
-done:
 	return sp;
 }