Re: [PATCH] rtc: pcf8523: Fix GCC 12 warning

From: Kees Cook
Date: Thu Feb 10 2022 - 18:48:50 EST


On Wed, Feb 09, 2022 at 04:30:27PM -0800, Victor Erminpour wrote:
> When building with automatic stack variable initialization, GCC 12
> complains about variables defined outside of switch case statements.
> Move variables outside the switch, which silences warnings:
>
> ./drivers/rtc/rtc-pcf8523.c:284:20: error: statement will never be executed [-Werror=switch-unreachable]
> 284 | u8 mode;
> |
>
> ./drivers/rtc/rtc-pcf8523.c:245:21: error: statement will never be executed [-Werror=switch-unreachable]
> 245 | u32 value;
> | ^~~~~
>
> Signed-off-by: Victor Erminpour <victor.erminpour@xxxxxxxxxx>

Thanks for finding these! I haven't done any cross compiles with GCC 12
yet. :)

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

--
Kees Cook