mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] clocksource: nps: avoid maybe-uninitialized warning
@ 2016-11-22 14:33 Arnd Bergmann
  2016-11-22 18:25 ` Vineet Gupta
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-11-22 14:33 UTC (permalink / raw)
  To: Daniel Lezcano, Thomas Gleixner
  Cc: Arnd Bergmann, Noam Camus, Vineet Gupta, Liviu Dudau, linux-kernel

We get a harmless false-positive warning with the newly added nps
clocksource driver:

drivers/clocksource/timer-nps.c: In function 'nps_setup_clocksource':
drivers/clocksource/timer-nps.c:102:6: error: 'nps_timer1_freq' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Gcc here fails to identify that IS_ERR() is only true if PTR_ERR()
has a nonzero value. Using PTR_ERR_OR_ZERO() to convert the result
first makes this obvious and shuts up the warning.

Fixes: 0ee4d9922df5 ("clocksource: Add clockevent support to NPS400 driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/clocksource/timer-nps.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/timer-nps.c b/drivers/clocksource/timer-nps.c
index b4c8a023a2d4..8da5e93b6810 100644
--- a/drivers/clocksource/timer-nps.c
+++ b/drivers/clocksource/timer-nps.c
@@ -53,9 +53,10 @@ static int __init nps_get_timer_clk(struct device_node *node,
 	int ret;
 
 	*clk = of_clk_get(node, 0);
-	if (IS_ERR(*clk)) {
+	ret = PTR_ERR_OR_ZERO(*clk);
+	if (ret) {
 		pr_err("timer missing clk");
-		return PTR_ERR(*clk);
+		return ret;
 	}
 
 	ret = clk_prepare_enable(*clk);
-- 
2.9.0

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

* Re: [PATCH] clocksource: nps: avoid maybe-uninitialized warning
  2016-11-22 14:33 [PATCH] clocksource: nps: avoid maybe-uninitialized warning Arnd Bergmann
@ 2016-11-22 18:25 ` Vineet Gupta
  0 siblings, 0 replies; 2+ messages in thread
From: Vineet Gupta @ 2016-11-22 18:25 UTC (permalink / raw)
  To: Arnd Bergmann, Daniel Lezcano, Thomas Gleixner
  Cc: Noam Camus, Liviu Dudau, linux-kernel

On 11/22/2016 06:34 AM, Arnd Bergmann wrote:
> We get a harmless false-positive warning with the newly added nps
> clocksource driver:
>
> drivers/clocksource/timer-nps.c: In function 'nps_setup_clocksource':
> drivers/clocksource/timer-nps.c:102:6: error: 'nps_timer1_freq' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> Gcc here fails to identify that IS_ERR() is only true if PTR_ERR()
> has a nonzero value. Using PTR_ERR_OR_ZERO() to convert the result
> first makes this obvious and shuts up the warning.
>
> Fixes: 0ee4d9922df5 ("clocksource: Add clockevent support to NPS400 driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thx for this fix Arnd. Since the driver is going via my tree, I added it to the
patchset.

-Vineet

> ---
>  drivers/clocksource/timer-nps.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clocksource/timer-nps.c b/drivers/clocksource/timer-nps.c
> index b4c8a023a2d4..8da5e93b6810 100644
> --- a/drivers/clocksource/timer-nps.c
> +++ b/drivers/clocksource/timer-nps.c
> @@ -53,9 +53,10 @@ static int __init nps_get_timer_clk(struct device_node *node,
>  	int ret;
>  
>  	*clk = of_clk_get(node, 0);
> -	if (IS_ERR(*clk)) {
> +	ret = PTR_ERR_OR_ZERO(*clk);
> +	if (ret) {
>  		pr_err("timer missing clk");
> -		return PTR_ERR(*clk);
> +		return ret;
>  	}
>  
>  	ret = clk_prepare_enable(*clk);

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

end of thread, other threads:[~2016-11-22 18:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-22 14:33 [PATCH] clocksource: nps: avoid maybe-uninitialized warning Arnd Bergmann
2016-11-22 18:25 ` Vineet Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome