linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mwifiex: fix compile warning of unused variable
@ 2017-07-06  7:50 Shawn Lin
  2017-07-06  7:57 ` Kalle Valo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Shawn Lin @ 2017-07-06  7:50 UTC (permalink / raw)
  To: Amitkumar Karwar, Kalle Valo
  Cc: linux-wireless, netdev, Nishant Sarmukadam, Xinming Hu, Shawn Lin

We got a compile warning shows below:

drivers/net/wireless/marvell/mwifiex/sdio.c: In function
'mwifiex_sdio_remove':
drivers/net/wireless/marvell/mwifiex/sdio.c:377:6: warning: variable
'ret' set but not used [-Wunused-but-set-variable]

Per the code, it didn't check if mwifiex_sdio_read_fw_status
finish successfully. We should at least check the return of
mwifiex_sdio_read_fw_status, otherwise the following check of
firmware_stat and adapter->mfg_mode is pointless as the device
is probably dead.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/net/wireless/marvell/mwifiex/sdio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
index f81a006..fd5183c 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -390,7 +390,8 @@ static int mwifiex_check_winner_status(struct mwifiex_adapter *adapter)
 	mwifiex_dbg(adapter, INFO, "info: SDIO func num=%d\n", func->num);
 
 	ret = mwifiex_sdio_read_fw_status(adapter, &firmware_stat);
-	if (firmware_stat == FIRMWARE_READY_SDIO && !adapter->mfg_mode) {
+	if (!ret && firmware_stat == FIRMWARE_READY_SDIO &&
+	    !adapter->mfg_mode) {
 		mwifiex_deauthenticate_all(adapter);
 
 		priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
-- 
1.9.1

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

* Re: [PATCH] mwifiex: fix compile warning of unused variable
  2017-07-06  7:50 [PATCH] mwifiex: fix compile warning of unused variable Shawn Lin
@ 2017-07-06  7:57 ` Kalle Valo
  2017-07-06  8:18   ` Shawn Lin
  2017-07-06 17:11 ` Brian Norris
  2017-07-28 14:50 ` Kalle Valo
  2 siblings, 1 reply; 6+ messages in thread
From: Kalle Valo @ 2017-07-06  7:57 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Amitkumar Karwar, linux-wireless, netdev, Nishant Sarmukadam, Xinming Hu

Shawn Lin <shawn.lin@rock-chips.com> writes:

> We got a compile warning shows below:
>
> drivers/net/wireless/marvell/mwifiex/sdio.c: In function
> 'mwifiex_sdio_remove':
> drivers/net/wireless/marvell/mwifiex/sdio.c:377:6: warning: variable
> 'ret' set but not used [-Wunused-but-set-variable]
>
> Per the code, it didn't check if mwifiex_sdio_read_fw_status
> finish successfully. We should at least check the return of
> mwifiex_sdio_read_fw_status, otherwise the following check of
> firmware_stat and adapter->mfg_mode is pointless as the device
> is probably dead.

I don't see that warning, any ideas why? My compiler:

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609


-- 
Kalle Valo

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

* Re: [PATCH] mwifiex: fix compile warning of unused variable
  2017-07-06  7:57 ` Kalle Valo
@ 2017-07-06  8:18   ` Shawn Lin
  0 siblings, 0 replies; 6+ messages in thread
From: Shawn Lin @ 2017-07-06  8:18 UTC (permalink / raw)
  To: Kalle Valo
  Cc: shawn.lin, Amitkumar Karwar, linux-wireless, netdev,
	Nishant Sarmukadam, Xinming Hu

Hi Kalle,

On 2017/7/6 15:57, Kalle Valo wrote:
> Shawn Lin <shawn.lin@rock-chips.com> writes:
> 
>> We got a compile warning shows below:
>>
>> drivers/net/wireless/marvell/mwifiex/sdio.c: In function
>> 'mwifiex_sdio_remove':
>> drivers/net/wireless/marvell/mwifiex/sdio.c:377:6: warning: variable
>> 'ret' set but not used [-Wunused-but-set-variable]
>>
>> Per the code, it didn't check if mwifiex_sdio_read_fw_status
>> finish successfully. We should at least check the return of
>> mwifiex_sdio_read_fw_status, otherwise the following check of
>> firmware_stat and adapter->mfg_mode is pointless as the device
>> is probably dead.
> 
> I don't see that warning, any ideas why? My compiler:
> 
> gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

I was using gcc-arm-eabi-4.8- , but it doesn't matter.

Could you add W=1 to compile the code, for instance, "make W=1  -j32"

> 
> 

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

* Re: [PATCH] mwifiex: fix compile warning of unused variable
  2017-07-06  7:50 [PATCH] mwifiex: fix compile warning of unused variable Shawn Lin
  2017-07-06  7:57 ` Kalle Valo
@ 2017-07-06 17:11 ` Brian Norris
  2017-07-25 12:33   ` Kalle Valo
  2017-07-28 14:50 ` Kalle Valo
  2 siblings, 1 reply; 6+ messages in thread
From: Brian Norris @ 2017-07-06 17:11 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Amitkumar Karwar, Kalle Valo, linux-wireless, netdev,
	Nishant Sarmukadam, Xinming Hu

On Thu, Jul 06, 2017 at 03:50:33PM +0800, Shawn Lin wrote:
> We got a compile warning shows below:
> 
> drivers/net/wireless/marvell/mwifiex/sdio.c: In function
> 'mwifiex_sdio_remove':
> drivers/net/wireless/marvell/mwifiex/sdio.c:377:6: warning: variable
> 'ret' set but not used [-Wunused-but-set-variable]

It's probably worth noting that this is not a default warning [1],
especially if you resend. It already confused Kalle.

[1] In Makefile:

# These warnings generated too much noise in a regular build.
# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)

> Per the code, it didn't check if mwifiex_sdio_read_fw_status
> finish successfully. We should at least check the return of
> mwifiex_sdio_read_fw_status, otherwise the following check of
> firmware_stat and adapter->mfg_mode is pointless as the device
> is probably dead.
> 
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
> 
>  drivers/net/wireless/marvell/mwifiex/sdio.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
> index f81a006..fd5183c 100644
> --- a/drivers/net/wireless/marvell/mwifiex/sdio.c
> +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
> @@ -390,7 +390,8 @@ static int mwifiex_check_winner_status(struct mwifiex_adapter *adapter)
>  	mwifiex_dbg(adapter, INFO, "info: SDIO func num=%d\n", func->num);
>  
>  	ret = mwifiex_sdio_read_fw_status(adapter, &firmware_stat);
> -	if (firmware_stat == FIRMWARE_READY_SDIO && !adapter->mfg_mode) {
> +	if (!ret && firmware_stat == FIRMWARE_READY_SDIO &&
> +	    !adapter->mfg_mode) {

The PCIe driver has the same code structure. Might change both, if
you're changing one of them? The PCIe one is technically safe I guess,
since it will write to the 'firmware_stat' variable regardless of
success or failure, whereas this SDIO one will not. But it would keep
things clear and obvious.

With (or without) that change:

Reviewed-by: Brian Norris <briannorris@chromium.org>

Brian

>  		mwifiex_deauthenticate_all(adapter);
>  
>  		priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
> -- 
> 1.9.1
> 
> 

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

* Re: [PATCH] mwifiex: fix compile warning of unused variable
  2017-07-06 17:11 ` Brian Norris
@ 2017-07-25 12:33   ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2017-07-25 12:33 UTC (permalink / raw)
  To: Brian Norris
  Cc: Shawn Lin, Amitkumar Karwar, linux-wireless, netdev,
	Nishant Sarmukadam, Xinming Hu

Brian Norris <briannorris@chromium.org> writes:

> On Thu, Jul 06, 2017 at 03:50:33PM +0800, Shawn Lin wrote:
>> We got a compile warning shows below:
>> 
>> drivers/net/wireless/marvell/mwifiex/sdio.c: In function
>> 'mwifiex_sdio_remove':
>> drivers/net/wireless/marvell/mwifiex/sdio.c:377:6: warning: variable
>> 'ret' set but not used [-Wunused-but-set-variable]
>
> It's probably worth noting that this is not a default warning [1],
> especially if you resend. It already confused Kalle.

Exactly, that way I can prioritise the patch accordingly. (W=1 warnings
are not that important so they go automatically to -next)

-- 
Kalle Valo

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

* Re: mwifiex: fix compile warning of unused variable
  2017-07-06  7:50 [PATCH] mwifiex: fix compile warning of unused variable Shawn Lin
  2017-07-06  7:57 ` Kalle Valo
  2017-07-06 17:11 ` Brian Norris
@ 2017-07-28 14:50 ` Kalle Valo
  2 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2017-07-28 14:50 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Amitkumar Karwar, linux-wireless, netdev, Nishant Sarmukadam,
	Xinming Hu, Shawn Lin

Shawn Lin <shawn.lin@rock-chips.com> wrote:

> We got a compile warning shows below:
> 
> drivers/net/wireless/marvell/mwifiex/sdio.c: In function
> 'mwifiex_sdio_remove':
> drivers/net/wireless/marvell/mwifiex/sdio.c:377:6: warning: variable
> 'ret' set but not used [-Wunused-but-set-variable]
> 
> Per the code, it didn't check if mwifiex_sdio_read_fw_status
> finish successfully. We should at least check the return of
> mwifiex_sdio_read_fw_status, otherwise the following check of
> firmware_stat and adapter->mfg_mode is pointless as the device
> is probably dead.
> 
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> Reviewed-by: Brian Norris <briannorris@chromium.org>

Patch applied to wireless-drivers-next.git, thanks.

f46a5b0156b1 mwifiex: fix compile warning of unused variable

-- 
https://patchwork.kernel.org/patch/9827585/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

end of thread, other threads:[~2017-07-28 14:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-06  7:50 [PATCH] mwifiex: fix compile warning of unused variable Shawn Lin
2017-07-06  7:57 ` Kalle Valo
2017-07-06  8:18   ` Shawn Lin
2017-07-06 17:11 ` Brian Norris
2017-07-25 12:33   ` Kalle Valo
2017-07-28 14:50 ` Kalle Valo

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).