From patchwork Tue May 31 10:51:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9144241 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EC99C60777 for ; Tue, 31 May 2016 10:51:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFB312793B for ; Tue, 31 May 2016 10:51:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D46E9281B4; Tue, 31 May 2016 10:51:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DD5B2793B for ; Tue, 31 May 2016 10:51:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751670AbcEaKvu (ORCPT ); Tue, 31 May 2016 06:51:50 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:62730 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752241AbcEaKvs convert rfc822-to-8bit (ORCPT ); Tue, 31 May 2016 06:51:48 -0400 Received: from wuerfel.localnet ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue004) with ESMTPSA (Nemesis) id 0MErYk-1bJDqp3qMk-00G2Iv; Tue, 31 May 2016 12:51:26 +0200 From: Arnd Bergmann To: Roman Volkov Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Boyd , Michael Turquette , Roman Volkov , Tony Prisk Subject: Re: [PATCH 2/2] clk/vt8500: Fix compilation warnings Date: Tue, 31 May 2016 12:51:55 +0200 Message-ID: <4814911.mY88HjlURn@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-22-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <1464120473-1808-3-git-send-email-v1ron@mail.ru> References: <1464120473-1808-1-git-send-email-v1ron@mail.ru> <1464120473-1808-3-git-send-email-v1ron@mail.ru> MIME-Version: 1.0 X-Provags-ID: V03:K0:/iDPvas8JxENQoAkDaMHHNU9I+yrcOkfrJ3dwxSg+F62i+6uam0 fYEg2HTLz07muNE4nK9YyvydIaoRAPR+YJ4+nnr7yX9oLxEGtkX1TdYHEHWzkMoZ0B4AQGL hCCu8cWXLD1e25vxkR2yq8wXBIidqBOoVJmhvh6FYePlzODC5dSLbFps1g2pxjvTyrjGf08 x6O3yZKx6IqKaFPS5OhGg== X-UI-Out-Filterresults: notjunk:1; V01:K0:TbCEpfAB68w=:6fqVVvYxxz7FGz4PXO9MRy LWJsaTtC/BNlGjMDhaRekFXKDdHz8JVZJLJxXPCU5XnUwxuzQu6DIt53azj30miEej8w2G/co gOjYcrBOJP2hdAVOPRvsBHt+5gK67lfzV74Y5A1v7L6/UWjARcHgldJ0rFKEHzo31o/HOuaeh nPvWFfk2J0jWR+B0/f7qTt0758eV+ZNIuWjxtpXjY6VQQ6G0KghTzLjThVFDYd1vK/k+FoL4g k+Vl3JIlbN03DV6VlUMZUkuojtzooMl5p246uazxuIyuqQrthw2HP1ox9axbOVVXXOMGFD2pE 09rYd/UmSCDUmuqp334ylnmJ5AKxg3QxtGQljPehb45hcJ5L7dQCsARqS6A6fYS1ddNyurgEH O8Y3yu/Uz9P/Yt097eqmGfvVr69aP3QHvjAzPzMK1roqvx7fg9sp649KFtlNMiTMTYGlJF/fH ktWQ3z82zRxw7weVR2b1lmJH92slYZ8PoDZF7QhkI0soG+ixDu37f5mXJIir6AdaXECNId0+F q51Hk05tTzaP2esh/xbQzc5QlhkG+ElOHoUGKdA8SyScIJS+XV5xu85q/YQVT8Y0ZY9jXzeC3 m9W/F+MidPpTxWMH0Zeiv3ayaOOwwi2Ql/q2btO1v3jbdwZYpE8HC6h0o9K1FYlAi9NiIBnvM sHng04upxLTQy4yrBYgQoaJ1QQjyKLP0A/mfmqsqHf4dEs0TZrvco8nR052LknH5+cQ1ho5s4 mnxHH6eFIHAPeNou Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tuesday, May 24, 2016 11:07:53 PM CEST Roman Volkov wrote: > From: Roman Volkov > > GCC 5.3.0 still throws the following warnings for functions > wm8750_find_pll_bits() and wm8850_find_pll_bits(): > > warning: 'best_div2' may be used uninitialized in this function > warning: 'best_div1' may be used uninitialized in this function > warning: 'best_mul' may be used uninitialized in this function > > These warnings are false positives, the variables are controlled > by checking the value of the variable 'best_err' which is -1 by > default. It is safe to initialize all these variables to zero. > > Fixes: 090341b0a95d ("clk: vt8500: fix sign of possible PLL values") > Signed-off-by: Roman Volkov With gcc-5.3 and linux-4.7-rc1, they should be gone now (no longer warning about this with gcov enabled), but I still get them with gcc-4.9. > diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c > index 77650f19a9b6..7c970d7c0a6a 100644 > --- a/drivers/clk/clk-vt8500.c > +++ b/drivers/clk/clk-vt8500.c > @@ -461,7 +461,7 @@ static int wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate, > { > u32 mul; > int div1, div2; > - u32 best_mul, best_div1, best_div2; > + u32 best_mul = 0, best_div1 = 0, best_div2 = 0; > unsigned long tclk, rate_err, best_err; > > best_err = (unsigned long)-1; > @@ -513,7 +513,7 @@ static int wm8850_find_pll_bits(unsigned long rate, unsigned long parent_rate, > { > u32 mul; > int div1, div2; > - u32 best_mul, best_div1, best_div2; > + u32 best_mul = 0, best_div1 = 0, best_div2 = 0; > unsigned long tclk, rate_err, best_err; > > best_err = (unsigned long)-1; > I see you only patch two instances but not the third one. I think we should do it consistently at least. Coincidentally, I've just done another patch for this myself, since it's the last gcc-4.9 warning we get in linux-4.7. My version below commit a38daeb34a2dc9d39ee1f153244cfcd83e865e0d Author: Arnd Bergmann Date: Tue May 31 10:41:26 2016 +0200 clk: vt8500: fix gcc-4.9 warnings This fixes some false positive warnings we get with older compiler versions: clk-vt8500.c: In function ‘wm8650_find_pll_bits’: clk-vt8500.c:430:12: ‘best_div2’ may be used uninitialized in this function clk-vt8500.c:429:12: ‘best_div1’ may be used uninitialized in this function clk-vt8500.c:428:14: ‘best_mul’ may be used uninitialized in this function clk-vt8500.c: In function ‘wm8750_find_pll_bits’: clk-vt8500.c:509:12: ‘best_div2’ may be used uninitialized in this function clk-vt8500.c:508:12: ‘best_div1’ may be used uninitialized in this function clk-vt8500.c:507:14: ‘best_mul’ may be used uninitialized in this function clk-vt8500.c: In function ‘wm8850_find_pll_bits’: clk-vt8500.c:560:12: ‘best_div2’ may be used uninitialized in this function clk-vt8500.c:559:12: ‘best_div1’ may be used uninitialized in this function clk-vt8500.c:558:14: ‘best_mul’ may be used uninitialized in this function As the local variables are only use for temporaries, we can just as well assign the final values directly, which also makes the code slightly shorter. Signed-off-by: Arnd Bergmann Signed-off-by: below mine). --- To unsubscribe from this list: send the line "unsubscribe linux-clk" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c index b0f76a84f1e9..d5a3453970d0 100644 --- a/drivers/clk/clk-vt8500.c +++ b/drivers/clk/clk-vt8500.c @@ -388,7 +388,6 @@ static int wm8650_find_pll_bits(unsigned long rate, unsigned long parent_rate, { u32 mul, div1; int div2; - u32 best_mul, best_div1, best_div2; unsigned long tclk, rate_err, best_err; best_err = (unsigned long)-1; @@ -411,9 +410,9 @@ static int wm8650_find_pll_bits(unsigned long rate, unsigned long parent_rate, if (rate_err < best_err) { best_err = rate_err; - best_mul = mul; - best_div1 = div1; - best_div2 = div2; + *multiplier = mul; + *divisor1 = div1; + *divisor2 = div2; } } @@ -425,10 +424,6 @@ static int wm8650_find_pll_bits(unsigned long rate, unsigned long parent_rate, /* if we got here, it wasn't an exact match */ pr_warn("%s: requested rate %lu, found rate %lu\n", __func__, rate, rate - best_err); - *multiplier = best_mul; - *divisor1 = best_div1; - *divisor2 = best_div2; - return 0; } @@ -464,7 +459,6 @@ static int wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate, { u32 mul; int div1, div2; - u32 best_mul, best_div1, best_div2; unsigned long tclk, rate_err, best_err; best_err = (unsigned long)-1; @@ -488,9 +482,9 @@ static int wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate, if (rate_err < best_err) { best_err = rate_err; - best_mul = mul; - best_div1 = div1; - best_div2 = div2; + *multiplier = mul; + *divisor1 = div1; + *divisor2 = div2; } } @@ -503,10 +497,7 @@ static int wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate, pr_warn("%s: requested rate %lu, found rate %lu\n", __func__, rate, rate - best_err); - *filter = wm8750_get_filter(parent_rate, best_div1); - *multiplier = best_mul; - *divisor1 = best_div1; - *divisor2 = best_div2; + *filter = wm8750_get_filter(parent_rate, *divisor1); return 0; } @@ -516,7 +507,6 @@ static int wm8850_find_pll_bits(unsigned long rate, unsigned long parent_rate, { u32 mul; int div1, div2; - u32 best_mul, best_div1, best_div2; unsigned long tclk, rate_err, best_err; best_err = (unsigned long)-1; @@ -540,9 +530,9 @@ static int wm8850_find_pll_bits(unsigned long rate, unsigned long parent_rate, if (rate_err < best_err) { best_err = rate_err; - best_mul = mul; - best_div1 = div1; - best_div2 = div2; + *multiplier = mul; + *divisor1 = div1; + *divisor2 = div2; } } @@ -555,10 +545,6 @@ static int wm8850_find_pll_bits(unsigned long rate, unsigned long parent_rate, pr_warn("%s: requested rate %lu, found rate %lu\n", __func__, rate, rate - best_err); - *multiplier = best_mul; - *divisor1 = best_div1; - *divisor2 = best_div2; - return 0; }