* [PATCH] rtc: pcf8523: Fix GCC 12 warning
@ 2022-02-10 0:30 Victor Erminpour
2022-02-10 23:48 ` Kees Cook
2022-02-15 22:20 ` Alexandre Belloni
0 siblings, 2 replies; 3+ messages in thread
From: Victor Erminpour @ 2022-02-10 0:30 UTC (permalink / raw)
To: a.zummo
Cc: alexandre.belloni, linux-rtc, linux-kernel, trivial, victor.erminpour
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@oracle.com>
---
drivers/rtc/rtc-pcf8523.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c
index c93acade7205..baa89f431ebd 100644
--- a/drivers/rtc/rtc-pcf8523.c
+++ b/drivers/rtc/rtc-pcf8523.c
@@ -240,9 +240,9 @@ static int pcf8523_param_get(struct device *dev, struct rtc_param *param)
{
struct pcf8523 *pcf8523 = dev_get_drvdata(dev);
int ret;
+ u32 value;
switch(param->param) {
- u32 value;
case RTC_PARAM_BACKUP_SWITCH_MODE:
ret = regmap_read(pcf8523->regmap, PCF8523_REG_CONTROL3, &value);
@@ -279,9 +279,9 @@ static int pcf8523_param_get(struct device *dev, struct rtc_param *param)
static int pcf8523_param_set(struct device *dev, struct rtc_param *param)
{
struct pcf8523 *pcf8523 = dev_get_drvdata(dev);
+ u8 mode;
switch(param->param) {
- u8 mode;
case RTC_PARAM_BACKUP_SWITCH_MODE:
switch (param->uvalue) {
case RTC_BSM_DISABLED:
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rtc: pcf8523: Fix GCC 12 warning
2022-02-10 0:30 [PATCH] rtc: pcf8523: Fix GCC 12 warning Victor Erminpour
@ 2022-02-10 23:48 ` Kees Cook
2022-02-15 22:20 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2022-02-10 23:48 UTC (permalink / raw)
To: Victor Erminpour
Cc: a.zummo, alexandre.belloni, linux-rtc, linux-kernel, trivial
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@oracle.com>
Thanks for finding these! I haven't done any cross compiles with GCC 12
yet. :)
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rtc: pcf8523: Fix GCC 12 warning
2022-02-10 0:30 [PATCH] rtc: pcf8523: Fix GCC 12 warning Victor Erminpour
2022-02-10 23:48 ` Kees Cook
@ 2022-02-15 22:20 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2022-02-15 22:20 UTC (permalink / raw)
To: Victor Erminpour, a.zummo
Cc: Alexandre Belloni, trivial, linux-rtc, linux-kernel
On Wed, 9 Feb 2022 16:30:27 -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;
> |
>
> [...]
Applied, thanks!
[1/1] rtc: pcf8523: Fix GCC 12 warning
commit: 85bcb01f145dc32e7f88e6eebb3b5f96d3b56eb6
Best regards,
--
Alexandre Belloni <alexandre.belloni@bootlin.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-15 22:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 0:30 [PATCH] rtc: pcf8523: Fix GCC 12 warning Victor Erminpour
2022-02-10 23:48 ` Kees Cook
2022-02-15 22:20 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).