All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] b43: shut up clang -Wuninitialized variable warning
@ 2019-03-22 14:37 Arnd Bergmann
  2019-03-22 15:47 ` Larry Finger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arnd Bergmann @ 2019-03-22 14:37 UTC (permalink / raw)
  To: Kalle Valo, David S. Miller, Larry Finger, Arnd Bergmann, Priit Laes
  Cc: clang-built-linux, Nick Desaulniers, Nathan Chancellor,
	linux-wireless, b43-dev, netdev, linux-kernel

Clang warns about what is clearly a case of passing an uninitalized
variable into a static function:

drivers/net/wireless/broadcom/b43/phy_lp.c:1852:23: error: variable 'gains' is uninitialized when used here
      [-Werror,-Wuninitialized]
                lpphy_papd_cal(dev, gains, 0, 1, 30);
                                    ^~~~~
drivers/net/wireless/broadcom/b43/phy_lp.c:1838:2: note: variable 'gains' is declared here
        struct lpphy_tx_gains gains, oldgains;
        ^
1 error generated.

However, this function is empty, and its arguments are never evaluated,
so gcc in contrast does not warn here. Both compilers behave in a
reasonable way as far as I can tell, so we should change the code
to avoid the warning everywhere.

We could just eliminate the lpphy_papd_cal() function entirely,
given that it has had the TODO comment in it for 10 years now
and is rather unlikely to ever get done. I'm doing a simpler
change here, and just pass the 'oldgains' variable in that has
been initialized, based on the guess that this is what was
originally meant.

Fixes: 2c0d6100da3e ("b43: LP-PHY: Begin implementing calibration & software RFKILL support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/wireless/broadcom/b43/phy_lp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/b43/phy_lp.c b/drivers/net/wireless/broadcom/b43/phy_lp.c
index 46408a560814..aedee026c5e2 100644
--- a/drivers/net/wireless/broadcom/b43/phy_lp.c
+++ b/drivers/net/wireless/broadcom/b43/phy_lp.c
@@ -1835,7 +1835,7 @@ static void lpphy_papd_cal(struct b43_wldev *dev, struct lpphy_tx_gains gains,
 static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
 {
 	struct b43_phy_lp *lpphy = dev->phy.lp;
-	struct lpphy_tx_gains gains, oldgains;
+	struct lpphy_tx_gains oldgains;
 	int old_txpctl, old_afe_ovr, old_rf, old_bbmult;
 
 	lpphy_read_tx_pctl_mode_from_hardware(dev);
@@ -1849,9 +1849,9 @@ static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
 	lpphy_set_tx_power_control(dev, B43_LPPHY_TXPCTL_OFF);
 
 	if (dev->dev->chip_id == 0x4325 && dev->dev->chip_rev == 0)
-		lpphy_papd_cal(dev, gains, 0, 1, 30);
+		lpphy_papd_cal(dev, oldgains, 0, 1, 30);
 	else
-		lpphy_papd_cal(dev, gains, 0, 1, 65);
+		lpphy_papd_cal(dev, oldgains, 0, 1, 65);
 
 	if (old_afe_ovr)
 		lpphy_set_tx_gains(dev, oldgains);
-- 
2.20.0


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

* Re: [PATCH] b43: shut up clang -Wuninitialized variable warning
  2019-03-22 14:37 [PATCH] b43: shut up clang -Wuninitialized variable warning Arnd Bergmann
@ 2019-03-22 15:47 ` Larry Finger
  2019-03-22 16:06 ` Nathan Chancellor
  2019-04-04 10:14 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Larry Finger @ 2019-03-22 15:47 UTC (permalink / raw)
  To: Arnd Bergmann, Kalle Valo, David S. Miller, Priit Laes
  Cc: clang-built-linux, Nick Desaulniers, Nathan Chancellor,
	linux-wireless, b43-dev, netdev, linux-kernel

On 3/22/19 9:37 AM, Arnd Bergmann wrote:
> Clang warns about what is clearly a case of passing an uninitalized
> variable into a static function:
> 
> drivers/net/wireless/broadcom/b43/phy_lp.c:1852:23: error: variable 'gains' is uninitialized when used here
>        [-Werror,-Wuninitialized]
>                  lpphy_papd_cal(dev, gains, 0, 1, 30);
>                                      ^~~~~
> drivers/net/wireless/broadcom/b43/phy_lp.c:1838:2: note: variable 'gains' is declared here
>          struct lpphy_tx_gains gains, oldgains;
>          ^
> 1 error generated.
> 
> However, this function is empty, and its arguments are never evaluated,
> so gcc in contrast does not warn here. Both compilers behave in a
> reasonable way as far as I can tell, so we should change the code
> to avoid the warning everywhere.
> 
> We could just eliminate the lpphy_papd_cal() function entirely,
> given that it has had the TODO comment in it for 10 years now
> and is rather unlikely to ever get done. I'm doing a simpler
> change here, and just pass the 'oldgains' variable in that has
> been initialized, based on the guess that this is what was
> originally meant.
> 
> Fixes: 2c0d6100da3e ("b43: LP-PHY: Begin implementing calibration & software RFKILL support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/net/wireless/broadcom/b43/phy_lp.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/b43/phy_lp.c b/drivers/net/wireless/broadcom/b43/phy_lp.c
> index 46408a560814..aedee026c5e2 100644
> --- a/drivers/net/wireless/broadcom/b43/phy_lp.c
> +++ b/drivers/net/wireless/broadcom/b43/phy_lp.c
> @@ -1835,7 +1835,7 @@ static void lpphy_papd_cal(struct b43_wldev *dev, struct lpphy_tx_gains gains,
>   static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
>   {
>   	struct b43_phy_lp *lpphy = dev->phy.lp;
> -	struct lpphy_tx_gains gains, oldgains;
> +	struct lpphy_tx_gains oldgains;
>   	int old_txpctl, old_afe_ovr, old_rf, old_bbmult;
>   
>   	lpphy_read_tx_pctl_mode_from_hardware(dev);
> @@ -1849,9 +1849,9 @@ static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
>   	lpphy_set_tx_power_control(dev, B43_LPPHY_TXPCTL_OFF);
>   
>   	if (dev->dev->chip_id == 0x4325 && dev->dev->chip_rev == 0)
> -		lpphy_papd_cal(dev, gains, 0, 1, 30);
> +		lpphy_papd_cal(dev, oldgains, 0, 1, 30);
>   	else
> -		lpphy_papd_cal(dev, gains, 0, 1, 65);
> +		lpphy_papd_cal(dev, oldgains, 0, 1, 65);
>   
>   	if (old_afe_ovr)
>   		lpphy_set_tx_gains(dev, oldgains);
> 

Acked-by: Larry Finger <Larry.Finger@lwfinger.net>

Thanks. I will submit a patch that removes lpphy_papd_cal(). You are correct 
that it is unlikely ever to be implemented.

Larry


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

* Re: [PATCH] b43: shut up clang -Wuninitialized variable warning
  2019-03-22 14:37 [PATCH] b43: shut up clang -Wuninitialized variable warning Arnd Bergmann
  2019-03-22 15:47 ` Larry Finger
@ 2019-03-22 16:06 ` Nathan Chancellor
  2019-04-04 10:14 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2019-03-22 16:06 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Kalle Valo, David S. Miller, Larry Finger, Priit Laes,
	clang-built-linux, Nick Desaulniers, linux-wireless, b43-dev,
	netdev, linux-kernel

On Fri, Mar 22, 2019 at 03:37:02PM +0100, Arnd Bergmann wrote:
> Clang warns about what is clearly a case of passing an uninitalized
> variable into a static function:
> 
> drivers/net/wireless/broadcom/b43/phy_lp.c:1852:23: error: variable 'gains' is uninitialized when used here
>       [-Werror,-Wuninitialized]
>                 lpphy_papd_cal(dev, gains, 0, 1, 30);
>                                     ^~~~~
> drivers/net/wireless/broadcom/b43/phy_lp.c:1838:2: note: variable 'gains' is declared here
>         struct lpphy_tx_gains gains, oldgains;
>         ^
> 1 error generated.
> 
> However, this function is empty, and its arguments are never evaluated,
> so gcc in contrast does not warn here. Both compilers behave in a
> reasonable way as far as I can tell, so we should change the code
> to avoid the warning everywhere.
> 
> We could just eliminate the lpphy_papd_cal() function entirely,
> given that it has had the TODO comment in it for 10 years now
> and is rather unlikely to ever get done. I'm doing a simpler
> change here, and just pass the 'oldgains' variable in that has
> been initialized, based on the guess that this is what was
> originally meant.
> 
> Fixes: 2c0d6100da3e ("b43: LP-PHY: Begin implementing calibration & software RFKILL support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

> ---
>  drivers/net/wireless/broadcom/b43/phy_lp.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/b43/phy_lp.c b/drivers/net/wireless/broadcom/b43/phy_lp.c
> index 46408a560814..aedee026c5e2 100644
> --- a/drivers/net/wireless/broadcom/b43/phy_lp.c
> +++ b/drivers/net/wireless/broadcom/b43/phy_lp.c
> @@ -1835,7 +1835,7 @@ static void lpphy_papd_cal(struct b43_wldev *dev, struct lpphy_tx_gains gains,
>  static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
>  {
>  	struct b43_phy_lp *lpphy = dev->phy.lp;
> -	struct lpphy_tx_gains gains, oldgains;
> +	struct lpphy_tx_gains oldgains;
>  	int old_txpctl, old_afe_ovr, old_rf, old_bbmult;
>  
>  	lpphy_read_tx_pctl_mode_from_hardware(dev);
> @@ -1849,9 +1849,9 @@ static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
>  	lpphy_set_tx_power_control(dev, B43_LPPHY_TXPCTL_OFF);
>  
>  	if (dev->dev->chip_id == 0x4325 && dev->dev->chip_rev == 0)
> -		lpphy_papd_cal(dev, gains, 0, 1, 30);
> +		lpphy_papd_cal(dev, oldgains, 0, 1, 30);
>  	else
> -		lpphy_papd_cal(dev, gains, 0, 1, 65);
> +		lpphy_papd_cal(dev, oldgains, 0, 1, 65);
>  
>  	if (old_afe_ovr)
>  		lpphy_set_tx_gains(dev, oldgains);
> -- 
> 2.20.0
> 

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

* Re: [PATCH] b43: shut up clang -Wuninitialized variable warning
  2019-03-22 14:37 [PATCH] b43: shut up clang -Wuninitialized variable warning Arnd Bergmann
  2019-03-22 15:47 ` Larry Finger
  2019-03-22 16:06 ` Nathan Chancellor
@ 2019-04-04 10:14 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2019-04-04 10:14 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: David S. Miller, Larry Finger, Arnd Bergmann, Priit Laes,
	clang-built-linux, Nick Desaulniers, Nathan Chancellor,
	linux-wireless, b43-dev, netdev, linux-kernel

Arnd Bergmann <arnd@arndb.de> wrote:

> Clang warns about what is clearly a case of passing an uninitalized
> variable into a static function:
> 
> drivers/net/wireless/broadcom/b43/phy_lp.c:1852:23: error: variable 'gains' is uninitialized when used here
>       [-Werror,-Wuninitialized]
>                 lpphy_papd_cal(dev, gains, 0, 1, 30);
>                                     ^~~~~
> drivers/net/wireless/broadcom/b43/phy_lp.c:1838:2: note: variable 'gains' is declared here
>         struct lpphy_tx_gains gains, oldgains;
>         ^
> 1 error generated.
> 
> However, this function is empty, and its arguments are never evaluated,
> so gcc in contrast does not warn here. Both compilers behave in a
> reasonable way as far as I can tell, so we should change the code
> to avoid the warning everywhere.
> 
> We could just eliminate the lpphy_papd_cal() function entirely,
> given that it has had the TODO comment in it for 10 years now
> and is rather unlikely to ever get done. I'm doing a simpler
> change here, and just pass the 'oldgains' variable in that has
> been initialized, based on the guess that this is what was
> originally meant.
> 
> Fixes: 2c0d6100da3e ("b43: LP-PHY: Begin implementing calibration & software RFKILL support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

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

d825db346270 b43: shut up clang -Wuninitialized variable warning

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

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


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

end of thread, other threads:[~2019-04-04 10:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 14:37 [PATCH] b43: shut up clang -Wuninitialized variable warning Arnd Bergmann
2019-03-22 15:47 ` Larry Finger
2019-03-22 16:06 ` Nathan Chancellor
2019-04-04 10:14 ` 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.