All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtlwifi: Remove unnecessary NULL check in rtl_regd_init
@ 2019-10-23  0:47 Nathan Chancellor
  2019-10-23  5:38 ` Pkshih
  2019-10-24  5:47 ` Kalle Valo
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2019-10-23  0:47 UTC (permalink / raw)
  To: Ping-Ke Shih, Kalle Valo
  Cc: Larry Finger, linux-wireless, netdev, linux-kernel,
	clang-built-linux, 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:

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")
Link:https://github.com/ClangBuiltLinux/linux/issues/750
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/net/wireless/realtek/rtlwifi/regd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/regd.c b/drivers/net/wireless/realtek/rtlwifi/regd.c
index c10432cd703e..8be31e0ad878 100644
--- a/drivers/net/wireless/realtek/rtlwifi/regd.c
+++ b/drivers/net/wireless/realtek/rtlwifi/regd.c
@@ -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 */
-- 
2.23.0


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

* Re: [PATCH] rtlwifi: Remove unnecessary NULL check in rtl_regd_init
  2019-10-23  0:47 [PATCH] rtlwifi: Remove unnecessary NULL check in rtl_regd_init Nathan Chancellor
@ 2019-10-23  5:38 ` Pkshih
  2019-10-24  5:47 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Pkshih @ 2019-10-23  5:38 UTC (permalink / raw)
  To: kvalo, natechancellor
  Cc: linux-wireless, netdev, linux-kernel, Larry.Finger, clang-built-linux

On Tue, 2019-10-22 at 17:47 -0700, Nathan Chancellor wrote:
> 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")
> Link:https://github.com/ClangBuiltLinux/linux/issues/750
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Looks good.
Thanks for your fix.

Acked-by: Ping-Ke Shih <pkshih@realtek.com>

> ---
>  drivers/net/wireless/realtek/rtlwifi/regd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/regd.c
> b/drivers/net/wireless/realtek/rtlwifi/regd.c
> index c10432cd703e..8be31e0ad878 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/regd.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/regd.c
> @@ -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 */



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

* Re: [PATCH] rtlwifi: Remove unnecessary NULL check in rtl_regd_init
  2019-10-23  0:47 [PATCH] rtlwifi: Remove unnecessary NULL check in rtl_regd_init Nathan Chancellor
  2019-10-23  5:38 ` Pkshih
@ 2019-10-24  5:47 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2019-10-24  5:47 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Ping-Ke Shih, Larry Finger, linux-wireless, netdev, linux-kernel,
	clang-built-linux, Nathan Chancellor

Nathan Chancellor <natechancellor@gmail.com> wrote:

> 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")
> Link:https://github.com/ClangBuiltLinux/linux/issues/750
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> Acked-by: Ping-Ke Shih <pkshih@realtek.com>

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

091c6e9c083f rtlwifi: Remove unnecessary NULL check in rtl_regd_init

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

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


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

end of thread, other threads:[~2019-10-24  5:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23  0:47 [PATCH] rtlwifi: Remove unnecessary NULL check in rtl_regd_init Nathan Chancellor
2019-10-23  5:38 ` Pkshih
2019-10-24  5:47 ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.