linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used
@ 2021-04-08  6:18 Zhen Lei
  2021-04-08  6:18 ` [PATCH 1/3] scsi: mptfusion: Remove unused local variable 'time_count' Zhen Lei
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Zhen Lei @ 2021-04-08  6:18 UTC (permalink / raw)
  To: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
	MPT-FusionLinux . pdl, linux-scsi, linux-kernel
  Cc: Zhen Lei

Fix below warnings:
drivers/message/fusion/mptctl.c: In function ‘mptctl_do_taskmgmt’:
drivers/message/fusion/mptctl.c:324:17: warning: variable ‘time_count’ set but not used [-Wunused-but-set-variable]
  324 |  unsigned long  time_count;
      |                 ^~~~~~~~~~
drivers/message/fusion/mptctl.c: In function ‘mptctl_gettargetinfo’:
drivers/message/fusion/mptctl.c:1372:7: warning: variable ‘port’ set but not used [-Wunused-but-set-variable]
 1372 |  u8   port;
      |       ^~~~
drivers/message/fusion/mptctl.c: In function ‘mptctl_hp_hostinfo’:
drivers/message/fusion/mptctl.c:2337:8: warning: variable ‘retval’ set but not used [-Wunused-but-set-variable]
 2337 |  int   retval;
      |        ^~~~~~


Zhen Lei (3):
  scsi: mptfusion: Remove unused local variable 'time_count'
  scsi: mptfusion: Remove unused local variable 'port'
  scsi: mptfusion: Fix error return code of mptctl_hp_hostinfo()

 drivers/message/fusion/mptctl.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

-- 
2.21.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] scsi: mptfusion: Remove unused local variable 'time_count'
  2021-04-08  6:18 [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used Zhen Lei
@ 2021-04-08  6:18 ` Zhen Lei
  2021-04-08  6:18 ` [PATCH 2/3] scsi: mptfusion: Remove unused local variable 'port' Zhen Lei
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Zhen Lei @ 2021-04-08  6:18 UTC (permalink / raw)
  To: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
	MPT-FusionLinux . pdl, linux-scsi, linux-kernel
  Cc: Zhen Lei

Fixes the following W=1 kernel build warning:

drivers/message/fusion/mptctl.c: In function ‘mptctl_do_taskmgmt:
drivers/message/fusion/mptctl.c:324:17: warning: variable ‘time_count’ set but not used [-Wunused-but-set-variable]

Fixes: 7d757f185540 ("[SCSI] mptfusion: Updated SCSI IO IOCTL error handling.")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/message/fusion/mptctl.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 24aebad60366..0a9321239e76 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -321,7 +321,6 @@ mptctl_do_taskmgmt(MPT_ADAPTER *ioc, u8 tm_type, u8 bus_id, u8 target_id)
 	int		 ii;
 	int		 retval;
 	unsigned long	 timeout;
-	unsigned long	 time_count;
 	u16		 iocstatus;
 
 
@@ -383,7 +382,6 @@ mptctl_do_taskmgmt(MPT_ADAPTER *ioc, u8 tm_type, u8 bus_id, u8 target_id)
 		ioc->name, tm_type, timeout));
 
 	INITIALIZE_MGMT_STATUS(ioc->taskmgmt_cmds.status)
-	time_count = jiffies;
 	if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) &&
 	    (ioc->facts.MsgVersion >= MPI_VERSION_01_05))
 		mpt_put_msg_frame_hi_pri(mptctl_taskmgmt_id, ioc, mf);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] scsi: mptfusion: Remove unused local variable 'port'
  2021-04-08  6:18 [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used Zhen Lei
  2021-04-08  6:18 ` [PATCH 1/3] scsi: mptfusion: Remove unused local variable 'time_count' Zhen Lei
@ 2021-04-08  6:18 ` Zhen Lei
  2021-04-08  6:18 ` [PATCH 3/3] scsi: mptfusion: Fix error return code of mptctl_hp_hostinfo() Zhen Lei
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Zhen Lei @ 2021-04-08  6:18 UTC (permalink / raw)
  To: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
	MPT-FusionLinux . pdl, linux-scsi, linux-kernel
  Cc: Zhen Lei

Fixes the following W=1 kernel build warning:

drivers/message/fusion/mptctl.c: In function ‘mptctl_gettargetinfo
drivers/message/fusion/mptctl.c:1372:7: warning: variable ‘port’ set but not used [-Wunused-but-set-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/message/fusion/mptctl.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 0a9321239e76..72025996cd70 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -1367,7 +1367,6 @@ mptctl_gettargetinfo (MPT_ADAPTER *ioc, unsigned long arg)
 	int			lun;
 	int			maxWordsLeft;
 	int			numBytes;
-	u8			port;
 	struct scsi_device 	*sdev;
 
 	if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) {
@@ -1379,13 +1378,8 @@ mptctl_gettargetinfo (MPT_ADAPTER *ioc, unsigned long arg)
 
 	dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_gettargetinfo called.\n",
 	    ioc->name));
-	/* Get the port number and set the maximum number of bytes
-	 * in the returned structure.
-	 * Ignore the port setting.
-	 */
 	numBytes = karg.hdr.maxDataSize - sizeof(mpt_ioctl_header);
 	maxWordsLeft = numBytes/sizeof(int);
-	port = karg.hdr.port;
 
 	if (maxWordsLeft <= 0) {
 		printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo() - no memory available!\n",
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] scsi: mptfusion: Fix error return code of mptctl_hp_hostinfo()
  2021-04-08  6:18 [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used Zhen Lei
  2021-04-08  6:18 ` [PATCH 1/3] scsi: mptfusion: Remove unused local variable 'time_count' Zhen Lei
  2021-04-08  6:18 ` [PATCH 2/3] scsi: mptfusion: Remove unused local variable 'port' Zhen Lei
@ 2021-04-08  6:18 ` Zhen Lei
  2021-04-13  5:07 ` [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used Martin K. Petersen
  2021-04-16  2:51 ` Martin K. Petersen
  4 siblings, 0 replies; 7+ messages in thread
From: Zhen Lei @ 2021-04-08  6:18 UTC (permalink / raw)
  To: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
	MPT-FusionLinux . pdl, linux-scsi, linux-kernel
  Cc: Zhen Lei

Ensure that all "goto out" error branches return correct error codes.
Currently, always returns 0.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/message/fusion/mptctl.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 72025996cd70..57bf511245b6 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -2326,7 +2326,7 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
 	ToolboxIstwiReadWriteRequest_t	*IstwiRWRequest;
 	MPT_FRAME_HDR		*mf = NULL;
 	unsigned long		timeleft;
-	int			retval;
+	int			retval = 0;
 	u32			msgcontext;
 
 	/* Reset long to int. Should affect IA64 and SPARC only
@@ -2453,6 +2453,7 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
 	if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
 		dfailprintk(ioc, printk(MYIOC_s_WARN_FMT
 			"%s, no msg frames!!\n", ioc->name, __func__));
+		retval = -EFAULT;
 		goto out;
 	}
 
@@ -2471,12 +2472,13 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
 		IstwiRWRequest->DeviceAddr = 0xB0;
 
 	pbuf = pci_alloc_consistent(ioc->pcidev, 4, &buf_dma);
-	if (!pbuf)
+	if (!pbuf) {
+		retval = -ENOMEM;
 		goto out;
+	}
 	ioc->add_sge((char *)&IstwiRWRequest->SGL,
 	    (MPT_SGE_FLAGS_SSIMPLE_READ|4), buf_dma);
 
-	retval = 0;
 	SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context,
 				IstwiRWRequest->MsgContext);
 	INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status)
@@ -2486,10 +2488,10 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
 	timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done,
 			HZ*MPT_IOCTL_DEFAULT_TIMEOUT);
 	if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
-		retval = -ETIME;
 		printk(MYIOC_s_WARN_FMT "%s: failed\n", ioc->name, __func__);
 		if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) {
 			mpt_free_msg_frame(ioc, mf);
+			retval = -ETIME;
 			goto out;
 		}
 		if (!timeleft) {
@@ -2497,9 +2499,11 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
 			       "HOST INFO command timeout, doorbell=0x%08x\n",
 			       ioc->name, mpt_GetIocState(ioc, 0));
 			mptctl_timeout_expired(ioc, mf);
-		} else
-			goto retry_wait;
-		goto out;
+			retval = -ETIME;
+			goto out;
+		}
+
+		goto retry_wait;
 	}
 
 	/*
@@ -2530,7 +2534,7 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
 		return -EFAULT;
 	}
 
-	return 0;
+	return retval;
 
 }
 
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used
  2021-04-08  6:18 [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used Zhen Lei
                   ` (2 preceding siblings ...)
  2021-04-08  6:18 ` [PATCH 3/3] scsi: mptfusion: Fix error return code of mptctl_hp_hostinfo() Zhen Lei
@ 2021-04-13  5:07 ` Martin K. Petersen
  2021-04-13  7:25   ` Leizhen (ThunderTown)
  2021-04-16  2:51 ` Martin K. Petersen
  4 siblings, 1 reply; 7+ messages in thread
From: Martin K. Petersen @ 2021-04-13  5:07 UTC (permalink / raw)
  To: Zhen Lei
  Cc: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
	MPT-FusionLinux . pdl, linux-scsi, linux-kernel


Zhen,

> Zhen Lei (3):
>   scsi: mptfusion: Remove unused local variable 'time_count'
>   scsi: mptfusion: Remove unused local variable 'port'
>   scsi: mptfusion: Fix error return code of mptctl_hp_hostinfo()

I applied patches 1+2. I hesitate making functional changes to such an
old driver.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used
  2021-04-13  5:07 ` [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used Martin K. Petersen
@ 2021-04-13  7:25   ` Leizhen (ThunderTown)
  0 siblings, 0 replies; 7+ messages in thread
From: Leizhen (ThunderTown) @ 2021-04-13  7:25 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
	MPT-FusionLinux . pdl, linux-scsi, linux-kernel



On 2021/4/13 13:07, Martin K. Petersen wrote:
> 
> Zhen,
> 
>> Zhen Lei (3):
>>   scsi: mptfusion: Remove unused local variable 'time_count'
>>   scsi: mptfusion: Remove unused local variable 'port'
>>   scsi: mptfusion: Fix error return code of mptctl_hp_hostinfo()
> 
> I applied patches 1+2. I hesitate making functional changes to such an
> old driver.

I think patch 3 does not change any functions. The current modification only
ensures that error codes are correctly returned in the error branch. In the
previous version, 0 is always returned.

> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used
  2021-04-08  6:18 [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used Zhen Lei
                   ` (3 preceding siblings ...)
  2021-04-13  5:07 ` [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used Martin K. Petersen
@ 2021-04-16  2:51 ` Martin K. Petersen
  4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2021-04-16  2:51 UTC (permalink / raw)
  To: linux-scsi, Zhen Lei, Sathya Prakash, MPT-FusionLinux . pdl,
	linux-kernel, Sreekanth Reddy, Suganath Prabu Subramani
  Cc: Martin K . Petersen

On Thu, 8 Apr 2021 14:18:48 +0800, Zhen Lei wrote:

> Fix below warnings:
> drivers/message/fusion/mptctl.c: In function ‘mptctl_do_taskmgmt’:
> drivers/message/fusion/mptctl.c:324:17: warning: variable ‘time_count’ set but not used [-Wunused-but-set-variable]
>   324 |  unsigned long  time_count;
>       |                 ^~~~~~~~~~
> drivers/message/fusion/mptctl.c: In function ‘mptctl_gettargetinfo’:
> drivers/message/fusion/mptctl.c:1372:7: warning: variable ‘port’ set but not used [-Wunused-but-set-variable]
>  1372 |  u8   port;
>       |       ^~~~
> drivers/message/fusion/mptctl.c: In function ‘mptctl_hp_hostinfo’:
> drivers/message/fusion/mptctl.c:2337:8: warning: variable ‘retval’ set but not used [-Wunused-but-set-variable]
>  2337 |  int   retval;
>       |        ^~~~~~
> 
> [...]

Applied to 5.13/scsi-queue, thanks!

[1/3] scsi: mptfusion: Remove unused local variable 'time_count'
      https://git.kernel.org/mkp/scsi/c/039cf3816648
[2/3] scsi: mptfusion: Remove unused local variable 'port'
      https://git.kernel.org/mkp/scsi/c/30264737bd95

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-04-16  2:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08  6:18 [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used Zhen Lei
2021-04-08  6:18 ` [PATCH 1/3] scsi: mptfusion: Remove unused local variable 'time_count' Zhen Lei
2021-04-08  6:18 ` [PATCH 2/3] scsi: mptfusion: Remove unused local variable 'port' Zhen Lei
2021-04-08  6:18 ` [PATCH 3/3] scsi: mptfusion: Fix error return code of mptctl_hp_hostinfo() Zhen Lei
2021-04-13  5:07 ` [PATCH 0/3] scsi: mptfusion: Clear the warnings indicating that the variable is not used Martin K. Petersen
2021-04-13  7:25   ` Leizhen (ThunderTown)
2021-04-16  2:51 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).