linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtw88: Initialize ret in rtw_wow_check_fw_status
@ 2020-01-30  1:33 Nathan Chancellor
  2020-01-31 10:23 ` Tony Chuang
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2020-01-30  1:33 UTC (permalink / raw)
  To: Yan-Hsuan Chuang, Kalle Valo
  Cc: linux-wireless, netdev, linux-kernel, clang-built-linux,
	Nathan Chancellor

Clang warns a few times (trimmed for brevity):

../drivers/net/wireless/realtek/rtw88/wow.c:295:7: warning: variable
'ret' is used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]

Initialize ret to true and change the other assignments to false because
it is a boolean value.

Fixes: 44bc17f7f5b3 ("rtw88: support wowlan feature for 8822c")
Link: https://github.com/ClangBuiltLinux/linux/issues/850
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/net/wireless/realtek/rtw88/wow.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/wow.c b/drivers/net/wireless/realtek/rtw88/wow.c
index af5c27e1bb07..5db49802c72c 100644
--- a/drivers/net/wireless/realtek/rtw88/wow.c
+++ b/drivers/net/wireless/realtek/rtw88/wow.c
@@ -283,18 +283,18 @@ static void rtw_wow_rx_dma_start(struct rtw_dev *rtwdev)
 
 static bool rtw_wow_check_fw_status(struct rtw_dev *rtwdev, bool wow_enable)
 {
-	bool ret;
+	bool ret = true;
 
 	/* wait 100ms for wow firmware to finish work */
 	msleep(100);
 
 	if (wow_enable) {
 		if (!rtw_read8(rtwdev, REG_WOWLAN_WAKE_REASON))
-			ret = 0;
+			ret = false;
 	} else {
 		if (rtw_read32_mask(rtwdev, REG_FE1IMR, BIT_FS_RXDONE) == 0 &&
 		    rtw_read32_mask(rtwdev, REG_RXPKT_NUM, BIT_RW_RELEASE) == 0)
-			ret = 0;
+			ret = false;
 	}
 
 	if (ret)
-- 
2.25.0


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

* RE: [PATCH] rtw88: Initialize ret in rtw_wow_check_fw_status
  2020-01-30  1:33 [PATCH] rtw88: Initialize ret in rtw_wow_check_fw_status Nathan Chancellor
@ 2020-01-31 10:23 ` Tony Chuang
  2020-01-31 11:03   ` Kalle Valo
  0 siblings, 1 reply; 3+ messages in thread
From: Tony Chuang @ 2020-01-31 10:23 UTC (permalink / raw)
  To: Nathan Chancellor, Kalle Valo
  Cc: linux-wireless, netdev, linux-kernel, clang-built-linux

From: Nathan Chancellor
> Subject: [PATCH] rtw88: Initialize ret in rtw_wow_check_fw_status
> 
> Clang warns a few times (trimmed for brevity):
> 
> ../drivers/net/wireless/realtek/rtw88/wow.c:295:7: warning: variable
> 'ret' is used uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized]
> 
> Initialize ret to true and change the other assignments to false because
> it is a boolean value.
> 
> Fixes: 44bc17f7f5b3 ("rtw88: support wowlan feature for 8822c")
> Link: https://github.com/ClangBuiltLinux/linux/issues/850
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/net/wireless/realtek/rtw88/wow.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/wow.c
> b/drivers/net/wireless/realtek/rtw88/wow.c
> index af5c27e1bb07..5db49802c72c 100644
> --- a/drivers/net/wireless/realtek/rtw88/wow.c
> +++ b/drivers/net/wireless/realtek/rtw88/wow.c
> @@ -283,18 +283,18 @@ static void rtw_wow_rx_dma_start(struct rtw_dev
> *rtwdev)
> 
>  static bool rtw_wow_check_fw_status(struct rtw_dev *rtwdev, bool
> wow_enable)
>  {
> -	bool ret;
> +	bool ret = true;
> 
>  	/* wait 100ms for wow firmware to finish work */
>  	msleep(100);
> 
>  	if (wow_enable) {
>  		if (!rtw_read8(rtwdev, REG_WOWLAN_WAKE_REASON))
> -			ret = 0;
> +			ret = false;
>  	} else {
>  		if (rtw_read32_mask(rtwdev, REG_FE1IMR, BIT_FS_RXDONE) == 0
> &&
>  		    rtw_read32_mask(rtwdev, REG_RXPKT_NUM,
> BIT_RW_RELEASE) == 0)
> -			ret = 0;
> +			ret = false;
>  	}
> 
>  	if (ret)
> --
> 2.25.0

NACK.

This patch could lead to incorrect behavior of WOW.
I will send a new patch to fix it, and change the type to "int".

Yan-Hsuan

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

* Re: [PATCH] rtw88: Initialize ret in rtw_wow_check_fw_status
  2020-01-31 10:23 ` Tony Chuang
@ 2020-01-31 11:03   ` Kalle Valo
  0 siblings, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2020-01-31 11:03 UTC (permalink / raw)
  To: Tony Chuang
  Cc: Nathan Chancellor, linux-wireless, netdev, linux-kernel,
	clang-built-linux

Tony Chuang <yhchuang@realtek.com> writes:

> From: Nathan Chancellor
>> Subject: [PATCH] rtw88: Initialize ret in rtw_wow_check_fw_status
>> 
>> Clang warns a few times (trimmed for brevity):
>> 
>> ../drivers/net/wireless/realtek/rtw88/wow.c:295:7: warning: variable
>> 'ret' is used uninitialized whenever 'if' condition is false
>> [-Wsometimes-uninitialized]
>> 
>> Initialize ret to true and change the other assignments to false because
>> it is a boolean value.
>> 
>> Fixes: 44bc17f7f5b3 ("rtw88: support wowlan feature for 8822c")
>> Link: https://github.com/ClangBuiltLinux/linux/issues/850
>> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>> ---
>>  drivers/net/wireless/realtek/rtw88/wow.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/realtek/rtw88/wow.c
>> b/drivers/net/wireless/realtek/rtw88/wow.c
>> index af5c27e1bb07..5db49802c72c 100644
>> --- a/drivers/net/wireless/realtek/rtw88/wow.c
>> +++ b/drivers/net/wireless/realtek/rtw88/wow.c
>> @@ -283,18 +283,18 @@ static void rtw_wow_rx_dma_start(struct rtw_dev
>> *rtwdev)
>> 
>>  static bool rtw_wow_check_fw_status(struct rtw_dev *rtwdev, bool
>> wow_enable)
>>  {
>> -	bool ret;
>> +	bool ret = true;
>> 
>>  	/* wait 100ms for wow firmware to finish work */
>>  	msleep(100);
>> 
>>  	if (wow_enable) {
>>  		if (!rtw_read8(rtwdev, REG_WOWLAN_WAKE_REASON))
>> -			ret = 0;
>> +			ret = false;
>>  	} else {
>>  		if (rtw_read32_mask(rtwdev, REG_FE1IMR, BIT_FS_RXDONE) == 0
>> &&
>>  		    rtw_read32_mask(rtwdev, REG_RXPKT_NUM,
>> BIT_RW_RELEASE) == 0)
>> -			ret = 0;
>> +			ret = false;
>>  	}
>> 
>>  	if (ret)
>> --
>> 2.25.0
>
> NACK.
>
> This patch could lead to incorrect behavior of WOW.
> I will send a new patch to fix it, and change the type to "int".

Please send it separately so that I can queue it to v5.6.

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

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

end of thread, other threads:[~2020-01-31 11:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-30  1:33 [PATCH] rtw88: Initialize ret in rtw_wow_check_fw_status Nathan Chancellor
2020-01-31 10:23 ` Tony Chuang
2020-01-31 11:03   ` 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).