From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Kees Cook <keescook@chromium.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org,
linux-hardening@vger.kernel.org,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: Re: [PATCH] rtc: Move variable into switch case statement
Date: Mon, 13 Dec 2021 18:47:21 -0600 [thread overview]
Message-ID: <20211214004721.GA74477@embeddedor> (raw)
In-Reply-To: <20211209043915.1378393-1-keescook@chromium.org>
On Wed, Dec 08, 2021 at 08:39:15PM -0800, Kees Cook wrote:
> 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: 6a8af1b6568a ("rtc: add parameter ioctl")
> Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks
--
Gustavo
> ---
> drivers/rtc/dev.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/rtc/dev.c b/drivers/rtc/dev.c
> index e104972a28fd..69325aeede1a 100644
> --- a/drivers/rtc/dev.c
> +++ b/drivers/rtc/dev.c
> @@ -391,14 +391,14 @@ static long rtc_dev_ioctl(struct file *file,
> }
>
> switch(param.param) {
> - long offset;
> case RTC_PARAM_FEATURES:
> if (param.index != 0)
> err = -EINVAL;
> param.uvalue = rtc->features[0];
> break;
>
> - case RTC_PARAM_CORRECTION:
> + case RTC_PARAM_CORRECTION: {
> + long offset;
> mutex_unlock(&rtc->ops_lock);
> if (param.index != 0)
> return -EINVAL;
> @@ -407,7 +407,7 @@ static long rtc_dev_ioctl(struct file *file,
> if (err == 0)
> param.svalue = offset;
> break;
> -
> + }
> default:
> if (rtc->ops->param_get)
> err = rtc->ops->param_get(rtc->dev.parent, ¶m);
> --
> 2.30.2
>
>
>
>
next prev parent reply other threads:[~2021-12-14 0:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 4:39 [PATCH] rtc: Move variable into switch case statement Kees Cook
2021-12-14 0:47 ` Gustavo A. R. Silva [this message]
2022-01-05 0:05 ` Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211214004721.GA74477@embeddedor \
--to=gustavoars@kernel.org \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.