diff mbox series

qla2xxx: fix sparse warning in func qla24xx_build_scsi_type_6_iocbs

Message ID 20230824151626.35334-1-njavali@marvell.com (mailing list archive)
State Accepted
Headers show
Series qla2xxx: fix sparse warning in func qla24xx_build_scsi_type_6_iocbs | expand

Commit Message

Nilesh Javali Aug. 24, 2023, 3:16 p.m. UTC
Sparse warning reported,

drivers/scsi/qla2xxx/qla_iocb.c: In function 'qla24xx_build_scsi_type_6_iocbs':
>> drivers/scsi/qla2xxx/qla_iocb.c:594:29: warning: variable 'ha' set but not used [-Wunused-but-set-variable]
     594 |         struct qla_hw_data *ha;
         |                             ^~

Define variable 'ha' before exiting the routine.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202308230757.VKMIztAB-lkp@intel.com/
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qla2xxx/qla_iocb.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Martin K. Petersen Aug. 25, 2023, 1:24 a.m. UTC | #1
Nilesh,

> Sparse warning reported,
>
> drivers/scsi/qla2xxx/qla_iocb.c: In function 'qla24xx_build_scsi_type_6_iocbs':
>>> drivers/scsi/qla2xxx/qla_iocb.c:594:29: warning: variable 'ha' set but not used [-Wunused-but-set-variable]
>      594 |         struct qla_hw_data *ha;
>          |                             ^~
>
> Define variable 'ha' before exiting the routine.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202308230757.VKMIztAB-lkp@intel.com/
> Signed-off-by: Nilesh Javali <njavali@marvell.com>
> ---
>  drivers/scsi/qla2xxx/qla_iocb.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
> index 7fbd917f6e1f..0eb8df5ee73c 100644
> --- a/drivers/scsi/qla2xxx/qla_iocb.c
> +++ b/drivers/scsi/qla2xxx/qla_iocb.c
> @@ -591,8 +591,8 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
>  	uint16_t tot_dsds)
>  {
>  	struct dsd64 *cur_dsd = NULL, *next_dsd;
> -	scsi_qla_host_t	*vha;
> -	struct qla_hw_data *ha;
> +	scsi_qla_host_t	*vha = sp->vha;
> +	struct qla_hw_data *ha = vha->hw;

It doesn't appear that either of these are used at all in that function.
What am I missing?
Nilesh Javali Aug. 25, 2023, 6:57 a.m. UTC | #2
Martin,

> -----Original Message-----
> From: Martin K. Petersen <martin.petersen@oracle.com>
> Sent: Friday, August 25, 2023 6:54 AM
> To: Nilesh Javali <njavali@marvell.com>
> Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org; GR-QLogic-
> Storage-Upstream <GR-QLogic-Storage-Upstream@marvell.com>; Anil
> Gurumurthy <agurumurthy@marvell.com>; Shreyas Deodhar
> <sdeodhar@marvell.com>
> Subject: [EXT] Re: [PATCH] qla2xxx: fix sparse warning in func
> qla24xx_build_scsi_type_6_iocbs
> 
> External Email
> 
> ----------------------------------------------------------------------
> 
> Nilesh,
> 
> > Sparse warning reported,
> >
> > drivers/scsi/qla2xxx/qla_iocb.c: In function
> 'qla24xx_build_scsi_type_6_iocbs':
> >>> drivers/scsi/qla2xxx/qla_iocb.c:594:29: warning: variable 'ha' set but not
> used [-Wunused-but-set-variable]
> >      594 |         struct qla_hw_data *ha;
> >          |                             ^~
> >
> > Define variable 'ha' before exiting the routine.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__lore.kernel.org_oe-2Dkbuild-2Dall_202308230757.VKMIztAB-2Dlkp-
> 40intel.com_&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FAW9wuzbtHIZL
> 7SV63sr8rG59Hctu-
> eGu0G9pxwOXgQ&m=TN8k607nHWpfz1FmLLOobTs3fJwzwYurDnbRAyMwDi
> S95QYsQ8IIX2XJsUy_SuUW&s=ODpU0qHQ2MPh7GQA6i-
> 08iusSGol9W145Tb2U0EqYfg&e=
> > Signed-off-by: Nilesh Javali <njavali@marvell.com>
> > ---
> >  drivers/scsi/qla2xxx/qla_iocb.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
> > index 7fbd917f6e1f..0eb8df5ee73c 100644
> > --- a/drivers/scsi/qla2xxx/qla_iocb.c
> > +++ b/drivers/scsi/qla2xxx/qla_iocb.c
> > @@ -591,8 +591,8 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct
> cmd_type_6 *cmd_pkt,
> >  	uint16_t tot_dsds)
> >  {
> >  	struct dsd64 *cur_dsd = NULL, *next_dsd;
> > -	scsi_qla_host_t	*vha;
> > -	struct qla_hw_data *ha;
> > +	scsi_qla_host_t	*vha = sp->vha;
> > +	struct qla_hw_data *ha = vha->hw;
> 
> It doesn't appear that either of these are used at all in that function.
> What am I missing?

You are correct. My bad, all statistics were moved from vha to qpair rendering the variables unused.
Thanks for the review.
I will post the v2 soon.

Regards,
Nilesh
Martin K. Petersen Aug. 31, 2023, 1:48 a.m. UTC | #3
On Thu, 24 Aug 2023 20:46:26 +0530, Nilesh Javali wrote:

> Sparse warning reported,
> 
> drivers/scsi/qla2xxx/qla_iocb.c: In function 'qla24xx_build_scsi_type_6_iocbs':
> >> drivers/scsi/qla2xxx/qla_iocb.c:594:29: warning: variable 'ha' set but not used [-Wunused-but-set-variable]
>      594 |         struct qla_hw_data *ha;
>          |                             ^~
> 
> [...]

Applied to 6.6/scsi-queue, thanks!

[1/1] scsi: qla2xxx: Remove unused variables in qla24xx_build_scsi_type_6_iocbs()
      https://git.kernel.org/mkp/scsi/c/659d36cc732a
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 7fbd917f6e1f..0eb8df5ee73c 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -591,8 +591,8 @@  qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
 	uint16_t tot_dsds)
 {
 	struct dsd64 *cur_dsd = NULL, *next_dsd;
-	scsi_qla_host_t	*vha;
-	struct qla_hw_data *ha;
+	scsi_qla_host_t	*vha = sp->vha;
+	struct qla_hw_data *ha = vha->hw;
 	struct scsi_cmnd *cmd;
 	struct	scatterlist *cur_seg;
 	uint8_t avail_dsds;
@@ -614,9 +614,6 @@  qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
 		return 0;
 	}
 
-	vha = sp->vha;
-	ha = vha->hw;
-
 	/* Set transfer direction */
 	if (cmd->sc_data_direction == DMA_TO_DEVICE) {
 		cmd_pkt->control_flags = cpu_to_le16(CF_WRITE_DATA);