From patchwork Mon Jan 25 15:45:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101122 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp1434195lbb; Mon, 25 Jan 2016 07:46:46 -0800 (PST) X-Received: by 10.66.235.36 with SMTP id uj4mr27061609pac.85.1453736806514; Mon, 25 Jan 2016 07:46:46 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v63si34397531pfa.245.2016.01.25.07.46.46; Mon, 25 Jan 2016 07:46:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757661AbcAYPql (ORCPT + 30 others); Mon, 25 Jan 2016 10:46:41 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:56841 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757457AbcAYPqh (ORCPT ); Mon, 25 Jan 2016 10:46:37 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0LfnrC-1ZlyjP1fCs-00pPGv; Mon, 25 Jan 2016 16:46:05 +0100 From: Arnd Bergmann To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: cpufreq-dt: avoid uninitialized variable warnings: Date: Mon, 25 Jan 2016 16:45:48 +0100 Message-Id: <1453736756-1959377-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:JNgP92uCS9y3jKQsK6rsdFnu+Szp+a7B8gPPLbmuajzeLiwDe+J Li0MKOPsCWohF5ZlYXn/ks7G+Vb4QYYWjJaS32ZT7SuXA+BM6NFIX4VSMpZjZ6BIfQbsg11 /SfvZunz9oKHPDYYkv8j7TSfGiSCkWZh984gHUOd/fqvvzq97XcVreX4OTlGavEKKlrPjOS RWmv9Lpdr7qDHIRfA55og== X-UI-Out-Filterresults: notjunk:1; V01:K0:t+yJfRkDJjI=:KMxRKW+GR3BdkobB5qL7Yu FP5FmKuON+DWoUXbb7Jr15QkAFyg2a+zOsPx3ZF5y8s1nTKgzk4MIMzpQp6OCoNortajx5Yxe 4r/aE0XH8t02t7V4O2oo6YDa1izyCzaAY4OIdCRISFoY8WX1jF9w4DB1XJm6nKg/Bzrne65Fk dqPvJdgbWz6lgwTEFZ9TJBc415O3FXZLz5blmS0pnYiD2JaSBQMTS5N4F7LemXmQmWhaAbpTb roVQt0TchPNQE+q+rn13WzsEvOzIDFpjNFwwweZIS4EyHtfn5dsr6TzD8uGzjSFrzwt6I7l+f Yd4ofLfXxXpOtR5t+TcZhVPCZXunsJTc6aybp6QypR8GtlOCLDwa/GiidlRTlSI043jnt0zyj fME1mU3rc6TQSxnwDD3u18kNj2gCg35hOK/fc9o7JrEQv/55Si6VNzkym+1HAMvVZpp712syh AK8uJnKhL5ERlqodcdQClUrCYcBFnIq3FhP+alR7obvhPmNDG4ssWyzKRL7M29VwlOv0/ia+C YqVBOYEphIP4fuAUVLy6j8C2hblglfxWH83U22A17wok1gtTtpQQOc8kCVHLN6WLNqZHBc39F 8JmaPnV4G4XgqeKmBBxczSX2WF+soj16aO/xcW7hgtmYgfT9YGG1aPqPu/EtZirm1gS70F3P0 8a84B1ak4IVDyrcFFXkqemmL0pjvP6HwOhaAjva9BCR1kVhm9NY7ohLiiV+PXlubAaKQ= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc warns quite a bit about values returned from allocate_resources() in cpufreq-dt.c: cpufreq-dt.c: In function 'cpufreq_init': cpufreq-dt.c:327:6: error: 'cpu_dev' may be used uninitialized in this function [-Werror=maybe-uninitialized] cpufreq-dt.c:197:17: note: 'cpu_dev' was declared here cpufreq-dt.c:376:2: error: 'cpu_clk' may be used uninitialized in this function [-Werror=maybe-uninitialized] cpufreq-dt.c:199:14: note: 'cpu_clk' was declared here cpufreq-dt.c: In function 'dt_cpufreq_probe': cpufreq-dt.c:461:2: error: 'cpu_clk' may be used uninitialized in this function [-Werror=maybe-uninitialized] cpufreq-dt.c:447:14: note: 'cpu_clk' was declared here The problem is that it's slightly hard for gcc to follow return codes across PTR_ERR() calls. This patch uses explicit assignments to the "ret" variable to make it easier for gcc to verify that the code is actually correct, without the need to add a bogus initialization. Signed-off-by: Arnd Bergmann --- drivers/cpufreq/cpufreq-dt.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) -- 2.7.0 diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 9bc37c437874..0ca74d070058 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -142,15 +142,16 @@ static int allocate_resources(int cpu, struct device **cdev, try_again: cpu_reg = regulator_get_optional(cpu_dev, reg); - if (IS_ERR(cpu_reg)) { + ret = PTR_ERR_OR_ZERO(cpu_reg); + if (ret) { /* * If cpu's regulator supply node is present, but regulator is * not yet registered, we should try defering probe. */ - if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) { + if (ret == -EPROBE_DEFER) { dev_dbg(cpu_dev, "cpu%d regulator not ready, retry\n", cpu); - return -EPROBE_DEFER; + return ret; } /* Try with "cpu-supply" */ @@ -159,18 +160,16 @@ try_again: goto try_again; } - dev_dbg(cpu_dev, "no regulator for cpu%d: %ld\n", - cpu, PTR_ERR(cpu_reg)); + dev_dbg(cpu_dev, "no regulator for cpu%d: %d\n", cpu, ret); } cpu_clk = clk_get(cpu_dev, NULL); - if (IS_ERR(cpu_clk)) { + ret = PTR_ERR_OR_ZERO(cpu_clk); + if (ret) { /* put regulator */ if (!IS_ERR(cpu_reg)) regulator_put(cpu_reg); - ret = PTR_ERR(cpu_clk); - /* * If cpu's clk node is present, but clock is not yet * registered, we should try defering probe.