Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PM / OPP: avoid maybe-uninitialized warning

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>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Arnd Bergmann and committed by
Rafael J. Wysocki
4df27c91 9395452b

+3 -7
+3 -7
drivers/base/power/opp/core.c
··· 584 584 struct clk *clk; 585 585 unsigned long freq, old_freq; 586 586 unsigned long u_volt, u_volt_min, u_volt_max; 587 - unsigned long ou_volt, ou_volt_min, ou_volt_max; 588 587 int ret; 589 588 590 589 if (unlikely(!target_freq)) { ··· 619 620 } 620 621 621 622 old_opp = _find_freq_ceil(opp_table, &old_freq); 622 - if (!IS_ERR(old_opp)) { 623 - ou_volt = old_opp->u_volt; 624 - ou_volt_min = old_opp->u_volt_min; 625 - ou_volt_max = old_opp->u_volt_max; 626 - } else { 623 + if (IS_ERR(old_opp)) { 627 624 dev_err(dev, "%s: failed to find current OPP for freq %lu (%ld)\n", 628 625 __func__, old_freq, PTR_ERR(old_opp)); 629 626 } ··· 678 683 restore_voltage: 679 684 /* This shouldn't harm even if the voltages weren't updated earlier */ 680 685 if (!IS_ERR(old_opp)) 681 - _set_opp_voltage(dev, reg, ou_volt, ou_volt_min, ou_volt_max); 686 + _set_opp_voltage(dev, reg, old_opp->u_volt, 687 + old_opp->u_volt_min, old_opp->u_volt_max); 682 688 683 689 return ret; 684 690 }