Skip to content

Commit

Permalink
rtc: pcf8523: Fix GCC 12 warning
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/1644453027-886-1-git-send-email-victor.erminpour@oracle.com
  • Loading branch information
Victor Erminpour authored and Alexandre Belloni committed Feb 15, 2022
1 parent 2ca03e2 commit 85bcb01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/rtc/rtc-pcf8523.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 85bcb01

Please sign in to comment.