tools/power x86_energy_perf_policy: Fix "uninitialized variable" warnings at -O2
authorBen Hutchings <ben@decadent.org.uk>
Sun, 16 Sep 2018 15:05:53 +0000 (16:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Sep 2019 05:15:42 +0000 (07:15 +0200)
commitb2c9cc27fbfa9ee4ceaf6bb1637310b9026f40d1
tree833aa1afefdad7d2f0cc16e22b3b5017b61597b0
parentee8e82fdbed328fb3a6c9bc19ac36795770906a8
tools/power x86_energy_perf_policy: Fix "uninitialized variable" warnings at -O2

[ Upstream commit adb8049097a9ec4acd09fbd3aa8636199a78df8a ]

x86_energy_perf_policy first uses __get_cpuid() to check the maximum
CPUID level and exits if it is too low.  It then assumes that later
calls will succeed (which I think is architecturally guaranteed).  It
also assumes that CPUID works at all (which is not guaranteed on
x86_32).

If optimisations are enabled, gcc warns about potentially
uninitialized variables.  Fix this by adding an exit-on-error after
every call to __get_cpuid() instead of just checking the maximum
level.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c