linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] rtlwifi: Simplify bool comparison
@ 2021-01-26  8:31 Jiapeng Zhong
  2021-01-26 16:46 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Zhong @ 2021-01-26  8:31 UTC (permalink / raw)
  To: kvalo
  Cc: pkshih, davem, kuba, linux-wireless, netdev, linux-kernel, Jiapeng Zhong

Fix the following coccicheck warning:
./drivers/net/wireless/realtek/rtlwifi/ps.c:798:7-21: WARNING:
Comparison to bool
./drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c:3848:7-17:
WARNING: Comparison of 0/1 to bool variable

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Zhong <abaci-bugfix@linux.alibaba.com>
---

Changes in v3:
-modify email address to a unique one
-modify subject prefix to "rtlwifi"
-merge this patch with another patch 

 drivers/net/wireless/realtek/rtlwifi/ps.c            | 4 ++--
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c b/drivers/net/wireless/realtek/rtlwifi/ps.c
index f9988225..629c032 100644
--- a/drivers/net/wireless/realtek/rtlwifi/ps.c
+++ b/drivers/net/wireless/realtek/rtlwifi/ps.c
@@ -798,9 +798,9 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data,
 		ie += 3 + noa_len;
 	}
 
-	if (find_p2p_ie == true) {
+	if (find_p2p_ie) {
 		if ((p2pinfo->p2p_ps_mode > P2P_PS_NONE) &&
-		    (find_p2p_ps_ie == false))
+		    (!find_p2p_ps_ie))
 			rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);
 	}
 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
index 372d6f8..1fb857c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
@@ -3848,7 +3848,7 @@ static void _rtl8821ae_iqk_tx(struct ieee80211_hw *hw, enum radio_path path)
 			else
 				rtl_write_dword(rtlpriv, 0xc8c, 0x00163e96);
 
-			if (vdf_enable == 1) {
+			if (vdf_enable) {
 				rtl_dbg(rtlpriv, COMP_IQK, DBG_LOUD, "VDF_enable\n");
 				for (k = 0; k <= 2; k++) {
 					switch (k) {
-- 
1.8.3.1


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

* Re: [PATCH v3] rtlwifi: Simplify bool comparison
  2021-01-26  8:31 [PATCH v3] rtlwifi: Simplify bool comparison Jiapeng Zhong
@ 2021-01-26 16:46 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2021-01-26 16:46 UTC (permalink / raw)
  To: Jiapeng Zhong, kvalo
  Cc: pkshih, davem, kuba, linux-wireless, netdev, linux-kernel

On Tue, 2021-01-26 at 16:31 +0800, Jiapeng Zhong wrote:
> Fix the following coccicheck warning:
> ./drivers/net/wireless/realtek/rtlwifi/ps.c:798:7-21: WARNING:
> Comparison to bool
> ./drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c:3848:7-17:
> WARNING: Comparison of 0/1 to bool variable
[]
> diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c b/drivers/net/wireless/realtek/rtlwifi/ps.c
[]
> @@ -798,9 +798,9 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data,
>  		ie += 3 + noa_len;
>  	}
>  
> 
> -	if (find_p2p_ie == true) {
> +	if (find_p2p_ie) {
>  		if ((p2pinfo->p2p_ps_mode > P2P_PS_NONE) &&
> -		    (find_p2p_ps_ie == false))
> +		    (!find_p2p_ps_ie))
>  			rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);
>  	}

Always review suggested coccinelle patches before submission and
see if there are ways to improve the code beyond what the spatch
tool suggests.

Perhaps integrate these tests and removed an indent level too:

	if (find_p2p_ie && !find_p2p_ps_ie &&
	    p2pinfo->p2p_ps_mode > P2P_PS_NONE)
		rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);



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

end of thread, other threads:[~2021-01-27  0:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26  8:31 [PATCH v3] rtlwifi: Simplify bool comparison Jiapeng Zhong
2021-01-26 16:46 ` Joe Perches

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