OSDN Git Service

power: avs: qcom-cpr: Avoid clang -Wsometimes-uninitialized in cpr_scale
authorNathan Chancellor <natechancellor@gmail.com>
Thu, 30 Jan 2020 01:41:30 +0000 (18:41 -0700)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 31 Jan 2020 10:07:43 +0000 (11:07 +0100)
commite093e53f4f70b126ff63bc422e5135e934e35a1b
tree67274f24d3cf56957496967411df7096bc0f35d0
parentdb5a10c172ed0d41aa4139ef9f1abd8128568267
power: avs: qcom-cpr: Avoid clang -Wsometimes-uninitialized in cpr_scale

Clang warns (trimmed for brevity):

../drivers/power/avs/qcom-cpr.c:570:13: warning: variable 'reg_mask' is
used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]

../drivers/power/avs/qcom-cpr.c:520:13: warning: variable 'new_uV' is
used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]

Due to the fact that Clang's static analysis happens before any
optimization passes are taken into account, it cannot see that both
branches in the if statement must be taken because dir cannot be
something other than UP or DOWN due to the check at the top of this
function. Change the else if condition to else to fix this false
positive.

Fixes: bf6910abf548 ("power: avs: Add support for CPR (Core Power Reduction)")
Link: https://github.com/ClangBuiltLinux/linux/issues/840
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/power/avs/qcom-cpr.c