Skip to contentSkip to conversation

rtlwifi: Remove unnecessary NULL check in rtl_regd_init

PATCH In review Nathan Chancellor 3 participants 3 messages Oct 23, 2019 – Oct 24, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtlwifi: Remove unnecessary NULL check in rtl_regd_init

When building with Clang + -Wtautological-pointer-compare:

drivers/net/wireless/realtek/rtlwifi/regd.c:389:33: warning: comparison of address of 'rtlpriv->regd' equal to a null pointer is always false [-Wtautological-pointer-compare]

        if (wiphy == NULL || &rtlpriv->regd == NULL)
                              ~~~~~~~~~^~~~    ~~~~

1 warning generated.

The address of an array member is never NULL unless it is the first struct member so remove the unnecessary check. This was addressed in the staging version of the driver in commit f986978b32b3 ("Staging:
rtlwifi: remove unnecessary NULL check").

While we are here, fix the following checkpatch warning:

CHECK: Comparison to NULL could be written "!wiphy" 35: FILE: drivers/net/wireless/realtek/rtlwifi/regd.c:389:
+ if (wiphy == NULL)

Fixes 0c8173385e54 ("rtl8192ce: Add new driver")
---
 drivers/net/wireless/realtek/rtlwifi/regd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtlwifi/regd.c +1 -1
index c10432cd703e..8be31e0ad878 100644
@@ -386,7 +386,7 @@ int rtl_regd_init(struct ieee80211_hw *hw,
 	struct wiphy *wiphy = hw->wiphy;
 	struct country_code_to_enum_rd *country = NULL;
 
-	if (wiphy == NULL || &rtlpriv->regd == NULL)
+	if (!wiphy)
 		return -EINVAL;
 
 	/* init country_code from efuse channel plan */
Signature · 1 line
2.23.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Nathan Chancellor

When building with Clang + -Wtautological-pointer-compare:

drivers/net/wireless/realtek/rtlwifi/regd.c:389:33: warning: comparison of address of 'rtlpriv->regd' equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (wiphy == NULL || &rtlpriv->regd == NULL) ~~~~~~~~~^~~~    ~~~~
1 warning generated.

The address of an array member is never NULL unless it is the first struct member so remove the unnecessary check. This was addressed in the staging version of the driver in commit f986978b32b3 ("Staging:
rtlwifi: remove unnecessary NULL check").

While we are here, fix the following checkpatch warning:

Quoted 7 lines

CHECK: Comparison to NULL could be written "!wiphy" 35: FILE: drivers/net/wireless/realtek/rtlwifi/regd.c:389:
+       if (wiphy == NULL)

Fixes 0c8173385e54 ("rtl8192ce: Add new driver")

Looks good.
Thanks for your fix.

Quoted 18 lines

---
 drivers/net/wireless/realtek/rtlwifi/regd.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtlwifi/regd.c +0 -0
index c10432cd703e..8be31e0ad878 100644
@@ -386,7 +386,7 @@ int rtl_regd_init(struct ieee80211_hw *hw,
  	struct wiphy *wiphy = hw->wiphy;
  	struct country_code_to_enum_rd *country = NULL;

drivers/net/wireless/realtek/rtlwifi/regd.c +1 -1
-	if (wiphy == NULL || &rtlpriv->regd == NULL)
+	if (!wiphy)

  return -EINVAL;

  /* init country_code from efuse channel plan */

#2 lore raw
In reply to Nathan Chancellor
Quoted 16 lines · Nathan Chancellor

When building with Clang + -Wtautological-pointer-compare:

drivers/net/wireless/realtek/rtlwifi/regd.c:389:33: warning: comparison of address of 'rtlpriv->regd' equal to a null pointer is always false [-Wtautological-pointer-compare]

        if (wiphy == NULL || &rtlpriv->regd == NULL)
                              ~~~~~~~~~^~~~    ~~~~

1 warning generated.

The address of an array member is never NULL unless it is the first struct member so remove the unnecessary check. This was addressed in the staging version of the driver in commit f986978b32b3 ("Staging:
rtlwifi: remove unnecessary NULL check").

While we are here, fix the following checkpatch warning:

Quoted 8 lines

CHECK: Comparison to NULL could be written "!wiphy" 35: FILE: drivers/net/wireless/realtek/rtlwifi/regd.c:389:
+ if (wiphy == NULL)

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

091c6e9c083f rtlwifi: Remove unnecessary NULL check in rtl_regd_init

Signature · 3 lines
https://patchwork.kernel.org/patch/11205577/

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