Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934292AbcKVSZu (ORCPT ); Tue, 22 Nov 2016 13:25:50 -0500 Received: from smtprelay.synopsys.com ([198.182.60.111]:42128 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752965AbcKVSZt (ORCPT ); Tue, 22 Nov 2016 13:25:49 -0500 Subject: Re: [PATCH] clocksource: nps: avoid maybe-uninitialized warning To: Arnd Bergmann , Daniel Lezcano , Thomas Gleixner References: <20161122143401.1889409-1-arnd@arndb.de> CC: Noam Camus , Liviu Dudau , "linux-kernel@vger.kernel.org" From: Vineet Gupta Message-ID: <375fd3c2-a037-afda-e77b-ba0f9654d36c@synopsys.com> Date: Tue, 22 Nov 2016 10:25:38 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161122143401.1889409-1-arnd@arndb.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.10.161.58] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1405 Lines: 40 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 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);