Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1331784 > unrolled thread

[PATCH] regulator: qcom-saw: avoid uninitialized variable warning

Started byArnd Bergmann <arnd@arndb.de>
First post2016-02-11 10:40 +0100
Last post2016-02-20 18:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] regulator: qcom-saw: avoid uninitialized variable warning Arnd Bergmann <arnd@arndb.de> - 2016-02-11 10:40 +0100
    Re: [PATCH] regulator: qcom-saw: avoid uninitialized variable warning Mark Brown <broonie@kernel.org> - 2016-02-20 18:40 +0100

#1331784 — [PATCH] regulator: qcom-saw: avoid uninitialized variable warning

FromArnd Bergmann <arnd@arndb.de>
Date2016-02-11 10:40 +0100
Subject[PATCH] regulator: qcom-saw: avoid uninitialized variable warning
Message-ID<r0VTd-6SY-7@gated-at.bofh.it>
gcc cannot know that a for_each_possible_cpu() loop always executes
at least once, so it warns about the use of the "found" variable
in qcom_saw_regulator_probe:

drivers/regulator/qcom_saw-regulator.c: In function 'qcom_saw_regulator_probe':
drivers/regulator/qcom_saw-regulator.c:154:5: error: 'found' is used uninitialized in this function [-Werror=uninitialized]

This adds an explicit initialization to avoid the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 18bba3b50355 ("regulator: qcom-saw: Add support for SAW regulators")
---
 drivers/regulator/qcom_saw-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/qcom_saw-regulator.c b/drivers/regulator/qcom_saw-regulator.c
index c800f16adaf0..30af1d380f9f 100644
--- a/drivers/regulator/qcom_saw-regulator.c
+++ b/drivers/regulator/qcom_saw-regulator.c
@@ -137,7 +137,7 @@ static struct saw_vreg *saw_get_drv(struct platform_device *pdev,
 	struct saw_vreg *vreg = NULL;
 	struct device_node *cpu_node, *saw_node;
 	int cpu;
-	bool found;
+	bool found = 0;
 
 	for_each_possible_cpu(cpu) {
 		cpu_node = of_cpu_device_node_get(cpu);
-- 
2.7.0

[toc] | [next] | [standalone]


#1338752

FromMark Brown <broonie@kernel.org>
Date2016-02-20 18:40 +0100
Message-ID<r4jFD-JJ-1@gated-at.bofh.it>
In reply to#1331784

[Multipart message — attachments visible in raw view] — view raw

On Thu, Feb 11, 2016 at 10:38:08AM +0100, Arnd Bergmann wrote:
> gcc cannot know that a for_each_possible_cpu() loop always executes
> at least once, so it warns about the use of the "found" variable
> in qcom_saw_regulator_probe:

I'm going to drop this driver so this won't be needed.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web