Skip to content

Commit ba52eac

Browse files
keesalexandrebelloni
authored andcommitted
rtc: Move variable into switch case statement
When building with automatic stack variable initialization, GCC 12 complains about variables defined outside of switch case statements. Move the variable into the case that uses it, which silences the warning: drivers/rtc/dev.c: In function 'rtc_dev_ioctl': drivers/rtc/dev.c:394:30: warning: statement will never be executed [-Wswitch-unreachable] 394 | long offset; | ^~~~~~ Fixes: 6a8af1b ("rtc: add parameter ioctl") Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7b69b54 commit ba52eac

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/rtc/dev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,14 @@ static long rtc_dev_ioctl(struct file *file,
391391
}
392392

393393
switch(param.param) {
394-
long offset;
395394
case RTC_PARAM_FEATURES:
396395
if (param.index != 0)
397396
err = -EINVAL;
398397
param.uvalue = rtc->features[0];
399398
break;
400399

401-
case RTC_PARAM_CORRECTION:
400+
case RTC_PARAM_CORRECTION: {
401+
long offset;
402402
mutex_unlock(&rtc->ops_lock);
403403
if (param.index != 0)
404404
return -EINVAL;
@@ -407,7 +407,7 @@ static long rtc_dev_ioctl(struct file *file,
407407
if (err == 0)
408408
param.svalue = offset;
409409
break;
410-
410+
}
411411
default:
412412
if (rtc->ops->param_get)
413413
err = rtc->ops->param_get(rtc->dev.parent, &param);

0 commit comments

Comments
 (0)