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


Groups > linux.kernel > #1484323 > unrolled thread

[PATCH] PM / OPP: avoid maybe-uninitialized warning

Started byArnd Bergmann <arnd@arndb.de>
First post2016-09-15 17:40 +0200
Last post2016-09-16 05:00 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] PM / OPP: avoid maybe-uninitialized warning Arnd Bergmann <arnd@arndb.de> - 2016-09-15 17:40 +0200
    Re: [PATCH] PM / OPP: avoid maybe-uninitialized warning Stephen Boyd <sboyd@codeaurora.org> - 2016-09-15 23:50 +0200
    Re: [PATCH] PM / OPP: avoid maybe-uninitialized warning Viresh Kumar <viresh.kumar@linaro.org> - 2016-09-16 05:00 +0200

#1484323 — [PATCH] PM / OPP: avoid maybe-uninitialized warning

FromArnd Bergmann <arnd@arndb.de>
Date2016-09-15 17:40 +0200
Subject[PATCH] PM / OPP: avoid maybe-uninitialized warning
Message-ID<shGVz-ku-3@gated-at.bofh.it>
When CONFIG_OPTIMIZE_INLINING is set and we are building with -Wmaybe-uninitialized
enabled, we can get a warning for the opp core driver:

drivers/base/power/opp/core.c: In function 'dev_pm_opp_set_rate':
drivers/base/power/opp/core.c:560:8: warning: 'ou_volt_min' may be used uninitialized in this function [-Wmaybe-uninitialized]

This has only now appeared as a result of commit 797da5598f3a ("PM / devfreq:
Add COMPILE_TEST for build coverage"), which makes the driver visible in
some configurations that didn't have it before.

The warning is a false positive that I got with gcc-6.1.1, but there is
a simple workaround in removing the local variables that we get warnings
for (all three are affected depending on the configuration). This also
makes the code easier to read.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/base/power/opp/core.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index df0c70963d9e..4c7c6da7a989 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -584,7 +584,6 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 	struct clk *clk;
 	unsigned long freq, old_freq;
 	unsigned long u_volt, u_volt_min, u_volt_max;
-	unsigned long ou_volt, ou_volt_min, ou_volt_max;
 	int ret;
 
 	if (unlikely(!target_freq)) {
@@ -620,11 +619,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 	}
 
 	old_opp = _find_freq_ceil(opp_table, &old_freq);
-	if (!IS_ERR(old_opp)) {
-		ou_volt = old_opp->u_volt;
-		ou_volt_min = old_opp->u_volt_min;
-		ou_volt_max = old_opp->u_volt_max;
-	} else {
+	if (IS_ERR(old_opp)) {
 		dev_err(dev, "%s: failed to find current OPP for freq %lu (%ld)\n",
 			__func__, old_freq, PTR_ERR(old_opp));
 	}
@@ -683,7 +678,8 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 restore_voltage:
 	/* This shouldn't harm even if the voltages weren't updated earlier */
 	if (!IS_ERR(old_opp))
-		_set_opp_voltage(dev, reg, ou_volt, ou_volt_min, ou_volt_max);
+		_set_opp_voltage(dev, reg, old_opp->u_volt,
+				 old_opp->u_volt_min, old_opp->u_volt_max);
 
 	return ret;
 }
-- 
2.9.0

[toc] | [next] | [standalone]


#1484557

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-09-15 23:50 +0200
Message-ID<shMHD-40l-5@gated-at.bofh.it>
In reply to#1484323
On 09/15/2016 08:38 AM, Arnd Bergmann wrote:
> When CONFIG_OPTIMIZE_INLINING is set and we are building with -Wmaybe-uninitialized
> enabled, we can get a warning for the opp core driver:
>
> drivers/base/power/opp/core.c: In function 'dev_pm_opp_set_rate':
> drivers/base/power/opp/core.c:560:8: warning: 'ou_volt_min' may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> This has only now appeared as a result of commit 797da5598f3a ("PM / devfreq:
> Add COMPILE_TEST for build coverage"), which makes the driver visible in
> some configurations that didn't have it before.
>
> The warning is a false positive that I got with gcc-6.1.1, but there is
> a simple workaround in removing the local variables that we get warnings
> for (all three are affected depending on the configuration). This also
> makes the code easier to read.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1484655

FromViresh Kumar <viresh.kumar@linaro.org>
Date2016-09-16 05:00 +0200
Message-ID<shRxD-74v-5@gated-at.bofh.it>
In reply to#1484323
On 15-09-16, 17:38, Arnd Bergmann wrote:
> When CONFIG_OPTIMIZE_INLINING is set and we are building with -Wmaybe-uninitialized
> enabled, we can get a warning for the opp core driver:
> 
> drivers/base/power/opp/core.c: In function 'dev_pm_opp_set_rate':
> drivers/base/power/opp/core.c:560:8: warning: 'ou_volt_min' may be used uninitialized in this function [-Wmaybe-uninitialized]
> 
> This has only now appeared as a result of commit 797da5598f3a ("PM / devfreq:
> Add COMPILE_TEST for build coverage"), which makes the driver visible in
> some configurations that didn't have it before.
> 
> The warning is a false positive that I got with gcc-6.1.1, but there is
> a simple workaround in removing the local variables that we get warnings
> for (all three are affected depending on the configuration). This also
> makes the code easier to read.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/base/power/opp/core.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
> index df0c70963d9e..4c7c6da7a989 100644
> --- a/drivers/base/power/opp/core.c
> +++ b/drivers/base/power/opp/core.c
> @@ -584,7 +584,6 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
>  	struct clk *clk;
>  	unsigned long freq, old_freq;
>  	unsigned long u_volt, u_volt_min, u_volt_max;
> -	unsigned long ou_volt, ou_volt_min, ou_volt_max;
>  	int ret;
>  
>  	if (unlikely(!target_freq)) {
> @@ -620,11 +619,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
>  	}
>  
>  	old_opp = _find_freq_ceil(opp_table, &old_freq);
> -	if (!IS_ERR(old_opp)) {
> -		ou_volt = old_opp->u_volt;
> -		ou_volt_min = old_opp->u_volt_min;
> -		ou_volt_max = old_opp->u_volt_max;
> -	} else {
> +	if (IS_ERR(old_opp)) {
>  		dev_err(dev, "%s: failed to find current OPP for freq %lu (%ld)\n",
>  			__func__, old_freq, PTR_ERR(old_opp));
>  	}
> @@ -683,7 +678,8 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
>  restore_voltage:
>  	/* This shouldn't harm even if the voltages weren't updated earlier */
>  	if (!IS_ERR(old_opp))
> -		_set_opp_voltage(dev, reg, ou_volt, ou_volt_min, ou_volt_max);
> +		_set_opp_voltage(dev, reg, old_opp->u_volt,
> +				 old_opp->u_volt_min, old_opp->u_volt_max);
>  
>  	return ret;
>  }

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web