[PATCH] clocksource/arm_arch_timer: Fix bogus -Wsometimes-uninitialized warning
Oliver Upton
oupton at google.com
Sun Nov 7 01:11:01 PST 2021
On Sun, Nov 7, 2021 at 1:02 AM Oliver Upton <oupton at google.com> wrote:
>
> Since commit 4775bc63f880 ("clocksource/arm_arch_timer: Add build-time
> guards for unhandled register accesses"), clang builds emit the
> following warning:
>
> >> drivers/clocksource/arm_arch_timer.c:156:3: warning: variable 'val' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
> default:
> ^~~~~~~
> drivers/clocksource/arm_arch_timer.c:163:9: note: uninitialized use occurs here
> return val;
> ^~~
>
> which is of course meaningless, as we break the build if the default
> case is ever taken in the switch statement. Clang does static analysis
> before deciding if the branch is ever taken, leading to the warning.
>
> Fix the bogus warning by initializing val on the default branch.
>
> Reported-by: kernel test robot <lkp at intel.com>
> Fixes: 4775bc63f880 ("clocksource/arm_arch_timer: Add build-time guards for unhandled register accesses")
> Signed-off-by: Oliver Upton <oupton at google.com>
My inbox searching was poor, there is another thread on this issue
where Miguel proposed tweaking the assertion such that clang no longer
emits the warning. No longer having issues with the patch applied [1]
[1] http://lore.kernel.org/r/20211014132331.GA4811@kernel.org/
--
Oliver
More information about the linux-arm-kernel
mailing list