mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Daniel Lezcano <daniel.lezcano@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>, Noam Camus <noamca@mellanox.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Liviu Dudau <Liviu.Dudau@arm.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] clocksource: nps: avoid maybe-uninitialized warning
Date: Tue, 22 Nov 2016 15:33:44 +0100	[thread overview]
Message-ID: <20161122143401.1889409-1-arnd@arndb.de> (raw)

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

             reply	other threads:[~2016-11-22 14:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-22 14:33 Arnd Bergmann [this message]
2016-11-22 18:25 ` Vineet Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161122143401.1889409-1-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=Liviu.Dudau@arm.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=noamca@mellanox.com \
    --cc=tglx@linutronix.de \
    --cc=vgupta@synopsys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®