diff mbox series

[v2,4/6] qla2xxx: Suppress Coverity complaints about dseg_r*

Message ID 20210318032840.7611-5-bvanassche@acm.org (mailing list archive)
State Superseded
Headers show
Series qla2xxx patches for kernel v5.12 and v5.13 | expand

Commit Message

Bart Van Assche March 18, 2021, 3:28 a.m. UTC
Change dseq_rq and dseg_rsp from scalar structure members into
single-element arrays such that Coverity does not complain about the
(*cur_dsd)++ statement in append_dsd64().

Cc: Quinn Tran <qutran@marvell.com>
Cc: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla2xxx/qla_mr.c | 12 ++++++------
 drivers/scsi/qla2xxx/qla_mr.h |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

Comments

Lee Duncan March 18, 2021, 4 p.m. UTC | #1
On 3/17/21 8:28 PM, Bart Van Assche wrote:
> Change dseq_rq and dseg_rsp from scalar structure members into
> single-element arrays such that Coverity does not complain about the
> (*cur_dsd)++ statement in append_dsd64().
> 
> Cc: Quinn Tran <qutran@marvell.com>
> Cc: Mike Christie <michael.christie@oracle.com>
> Reviewed-by: Daniel Wagner <dwagner@suse.de>
> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/qla2xxx/qla_mr.c | 12 ++++++------
>  drivers/scsi/qla2xxx/qla_mr.h |  4 ++--
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
> index ca7306685325..61eaf6c4ac47 100644
> --- a/drivers/scsi/qla2xxx/qla_mr.c
> +++ b/drivers/scsi/qla2xxx/qla_mr.c
> @@ -3266,8 +3266,8 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
>  			fx_iocb.req_xfrcnt =
>  			    cpu_to_le16(fxio->u.fxiocb.req_len);
>  			put_unaligned_le64(fxio->u.fxiocb.req_dma_handle,
> -					   &fx_iocb.dseg_rq.address);
> -			fx_iocb.dseg_rq.length =
> +					   &fx_iocb.dseg_rq[0].address);
> +			fx_iocb.dseg_rq[0].length =
>  			    cpu_to_le32(fxio->u.fxiocb.req_len);
>  		}
>  
> @@ -3276,8 +3276,8 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
>  			fx_iocb.rsp_xfrcnt =
>  			    cpu_to_le16(fxio->u.fxiocb.rsp_len);
>  			put_unaligned_le64(fxio->u.fxiocb.rsp_dma_handle,
> -					   &fx_iocb.dseg_rsp.address);
> -			fx_iocb.dseg_rsp.length =
> +					   &fx_iocb.dseg_rsp[0].address);
> +			fx_iocb.dseg_rsp[0].length =
>  			    cpu_to_le32(fxio->u.fxiocb.rsp_len);
>  		}
>  
> @@ -3314,7 +3314,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
>  			    cpu_to_le16(bsg_job->request_payload.sg_cnt);
>  			tot_dsds =
>  			    bsg_job->request_payload.sg_cnt;
> -			cur_dsd = &fx_iocb.dseg_rq;
> +			cur_dsd = &fx_iocb.dseg_rq[0];
>  			avail_dsds = 1;
>  			for_each_sg(bsg_job->request_payload.sg_list, sg,
>  			    tot_dsds, index) {
> @@ -3369,7 +3369,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
>  			fx_iocb.rsp_dsdcnt =
>  			   cpu_to_le16(bsg_job->reply_payload.sg_cnt);
>  			tot_dsds = bsg_job->reply_payload.sg_cnt;
> -			cur_dsd = &fx_iocb.dseg_rsp;
> +			cur_dsd = &fx_iocb.dseg_rsp[0];
>  			avail_dsds = 1;
>  
>  			for_each_sg(bsg_job->reply_payload.sg_list, sg,
> diff --git a/drivers/scsi/qla2xxx/qla_mr.h b/drivers/scsi/qla2xxx/qla_mr.h
> index 73be8348402a..eefbae9d7547 100644
> --- a/drivers/scsi/qla2xxx/qla_mr.h
> +++ b/drivers/scsi/qla2xxx/qla_mr.h
> @@ -176,8 +176,8 @@ struct fxdisc_entry_fx00 {
>  	uint8_t flags;-					   &
>  	uint8_t reserved_1;
>  
> -	struct dsd64 dseg_rq;
> -	struct dsd64 dseg_rsp;
> +	struct dsd64 dseg_rq[1];
> +	struct dsd64 dseg_rsp[1];
>  
>  	__le32 dataword;
>  	__le32 adapid;
> 

I dislike such an uncommented change just to keep a tool happy. Could
you add a comment in qla_mr.h saying why these are one-element-long
arrays, just so nobody optimizes those out later?

If you do that, please add my:

Reviewed-by: Lee Duncan <lduncan@suse.com>
Bart Van Assche March 18, 2021, 7:10 p.m. UTC | #2
On 3/18/21 9:00 AM, Lee Duncan wrote:
> I dislike such an uncommented change just to keep a tool happy. Could
> you add a comment in qla_mr.h saying why these are one-element-long
> arrays, just so nobody optimizes those out later?
I will add a comment. Thanks for the feedback.

Bart.
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
index ca7306685325..61eaf6c4ac47 100644
--- a/drivers/scsi/qla2xxx/qla_mr.c
+++ b/drivers/scsi/qla2xxx/qla_mr.c
@@ -3266,8 +3266,8 @@  qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
 			fx_iocb.req_xfrcnt =
 			    cpu_to_le16(fxio->u.fxiocb.req_len);
 			put_unaligned_le64(fxio->u.fxiocb.req_dma_handle,
-					   &fx_iocb.dseg_rq.address);
-			fx_iocb.dseg_rq.length =
+					   &fx_iocb.dseg_rq[0].address);
+			fx_iocb.dseg_rq[0].length =
 			    cpu_to_le32(fxio->u.fxiocb.req_len);
 		}
 
@@ -3276,8 +3276,8 @@  qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
 			fx_iocb.rsp_xfrcnt =
 			    cpu_to_le16(fxio->u.fxiocb.rsp_len);
 			put_unaligned_le64(fxio->u.fxiocb.rsp_dma_handle,
-					   &fx_iocb.dseg_rsp.address);
-			fx_iocb.dseg_rsp.length =
+					   &fx_iocb.dseg_rsp[0].address);
+			fx_iocb.dseg_rsp[0].length =
 			    cpu_to_le32(fxio->u.fxiocb.rsp_len);
 		}
 
@@ -3314,7 +3314,7 @@  qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
 			    cpu_to_le16(bsg_job->request_payload.sg_cnt);
 			tot_dsds =
 			    bsg_job->request_payload.sg_cnt;
-			cur_dsd = &fx_iocb.dseg_rq;
+			cur_dsd = &fx_iocb.dseg_rq[0];
 			avail_dsds = 1;
 			for_each_sg(bsg_job->request_payload.sg_list, sg,
 			    tot_dsds, index) {
@@ -3369,7 +3369,7 @@  qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb)
 			fx_iocb.rsp_dsdcnt =
 			   cpu_to_le16(bsg_job->reply_payload.sg_cnt);
 			tot_dsds = bsg_job->reply_payload.sg_cnt;
-			cur_dsd = &fx_iocb.dseg_rsp;
+			cur_dsd = &fx_iocb.dseg_rsp[0];
 			avail_dsds = 1;
 
 			for_each_sg(bsg_job->reply_payload.sg_list, sg,
diff --git a/drivers/scsi/qla2xxx/qla_mr.h b/drivers/scsi/qla2xxx/qla_mr.h
index 73be8348402a..eefbae9d7547 100644
--- a/drivers/scsi/qla2xxx/qla_mr.h
+++ b/drivers/scsi/qla2xxx/qla_mr.h
@@ -176,8 +176,8 @@  struct fxdisc_entry_fx00 {
 	uint8_t flags;
 	uint8_t reserved_1;
 
-	struct dsd64 dseg_rq;
-	struct dsd64 dseg_rsp;
+	struct dsd64 dseg_rq[1];
+	struct dsd64 dseg_rsp[1];
 
 	__le32 dataword;
 	__le32 adapid;