diff mbox

mwifiex: fix compile warning of unused variable

Message ID 1499327433-70786-1-git-send-email-shawn.lin@rock-chips.com (mailing list archive)
State Accepted
Commit f46a5b0156b166fcfdf05bca02d13bf482d95bf1
Delegated to: Kalle Valo
Headers show

Commit Message

Shawn Lin July 6, 2017, 7:50 a.m. UTC
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(-)

Comments

Kalle Valo July 6, 2017, 7:57 a.m. UTC | #1
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
Shawn Lin July 6, 2017, 8:18 a.m. UTC | #2
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"

> 
>
Brian Norris July 6, 2017, 5:11 p.m. UTC | #3
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
> 
>
Kalle Valo July 25, 2017, 12:33 p.m. UTC | #4
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 July 28, 2017, 2:50 p.m. UTC | #5
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
diff mbox

Patch

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