Commit ba52eac0 authored by Kees Cook's avatar Kees Cook Committed by Alexandre Belloni
Browse files

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: 6a8af1b6 ("rtc: add parameter ioctl")
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Reviewed-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211209043915.1378393-1-keescook@chromium.org
parent 7b69b54a
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -391,14 +391,14 @@ static long rtc_dev_ioctl(struct file *file,
		}
		}


		switch(param.param) {
		switch(param.param) {
			long offset;
		case RTC_PARAM_FEATURES:
		case RTC_PARAM_FEATURES:
			if (param.index != 0)
			if (param.index != 0)
				err = -EINVAL;
				err = -EINVAL;
			param.uvalue = rtc->features[0];
			param.uvalue = rtc->features[0];
			break;
			break;


		case RTC_PARAM_CORRECTION:
		case RTC_PARAM_CORRECTION: {
			long offset;
			mutex_unlock(&rtc->ops_lock);
			mutex_unlock(&rtc->ops_lock);
			if (param.index != 0)
			if (param.index != 0)
				return -EINVAL;
				return -EINVAL;
@@ -407,7 +407,7 @@ static long rtc_dev_ioctl(struct file *file,
			if (err == 0)
			if (err == 0)
				param.svalue = offset;
				param.svalue = offset;
			break;
			break;

		}
		default:
		default:
			if (rtc->ops->param_get)
			if (rtc->ops->param_get)
				err = rtc->ops->param_get(rtc->dev.parent, &param);
				err = rtc->ops->param_get(rtc->dev.parent, &param);