All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-devel@nongnu.org,  Peter Maydell <peter.maydell@linaro.org>,
	qemu-trivial@nongnu.org,  qemu-arm@nongnu.org
Subject: Re: [PATCH v2] hw/rtc/twl92230: Silence warnings about missing fallthrough statements
Date: Wed, 21 Oct 2020 04:50:59 +0200	[thread overview]
Message-ID: <877drks358.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20201020105108.19733-1-thuth@redhat.com> (Thomas Huth's message of "Tue, 20 Oct 2020 12:51:08 +0200")

Thomas Huth <thuth@redhat.com> writes:

> When compiling with -Werror=implicit-fallthrough, gcc complains about
> missing fallthrough annotations in this file. Looking at the code,
> the fallthrough is indeed wanted here, but instead of adding the
> annotations, it can be done more efficiently by simply calculating
> the offset with a subtraction instead of increasing a local variable
> one by one.
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  v2: Fixed copy-n-paste bug
>
>  hw/rtc/twl92230.c | 50 +++++++++++++++++++++++------------------------
>  1 file changed, 24 insertions(+), 26 deletions(-)
>
> diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c
> index f838913b37..50b97a1fce 100644
> --- a/hw/rtc/twl92230.c
> +++ b/hw/rtc/twl92230.c
> @@ -271,37 +271,36 @@ static void menelaus_gpio_set(void *opaque, int line, int level)
>  static uint8_t menelaus_read(void *opaque, uint8_t addr)
>  {
>      MenelausState *s = (MenelausState *) opaque;
> -    int reg = 0;
>  
>      switch (addr) {
>      case MENELAUS_REV:
>          return 0x22;
>  
> -    case MENELAUS_VCORE_CTRL5: reg ++;
> -    case MENELAUS_VCORE_CTRL4: reg ++;
> -    case MENELAUS_VCORE_CTRL3: reg ++;
> -    case MENELAUS_VCORE_CTRL2: reg ++;
> +    case MENELAUS_VCORE_CTRL5:
> +    case MENELAUS_VCORE_CTRL4:
> +    case MENELAUS_VCORE_CTRL3:
> +    case MENELAUS_VCORE_CTRL2:
>      case MENELAUS_VCORE_CTRL1:
> -        return s->vcore[reg];
> +        return s->vcore[addr - MENELAUS_VCORE_CTRL1];

Suggest to count up instead of down:

       case MENELAUS_VCORE_CTRL1:
  +    case MENELAUS_VCORE_CTRL2:
  +    case MENELAUS_VCORE_CTRL3:
  +    case MENELAUS_VCORE_CTRL4:
  +    case MENELAUS_VCORE_CTRL5:
  -        return s->vcore[reg];
  +        return s->vcore[addr - MENELAUS_VCORE_CTRL1];

[...]



WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-trivial@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v2] hw/rtc/twl92230: Silence warnings about missing fallthrough statements
Date: Wed, 21 Oct 2020 04:50:59 +0200	[thread overview]
Message-ID: <877drks358.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20201020105108.19733-1-thuth@redhat.com> (Thomas Huth's message of "Tue, 20 Oct 2020 12:51:08 +0200")

Thomas Huth <thuth@redhat.com> writes:

> When compiling with -Werror=implicit-fallthrough, gcc complains about
> missing fallthrough annotations in this file. Looking at the code,
> the fallthrough is indeed wanted here, but instead of adding the
> annotations, it can be done more efficiently by simply calculating
> the offset with a subtraction instead of increasing a local variable
> one by one.
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  v2: Fixed copy-n-paste bug
>
>  hw/rtc/twl92230.c | 50 +++++++++++++++++++++++------------------------
>  1 file changed, 24 insertions(+), 26 deletions(-)
>
> diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c
> index f838913b37..50b97a1fce 100644
> --- a/hw/rtc/twl92230.c
> +++ b/hw/rtc/twl92230.c
> @@ -271,37 +271,36 @@ static void menelaus_gpio_set(void *opaque, int line, int level)
>  static uint8_t menelaus_read(void *opaque, uint8_t addr)
>  {
>      MenelausState *s = (MenelausState *) opaque;
> -    int reg = 0;
>  
>      switch (addr) {
>      case MENELAUS_REV:
>          return 0x22;
>  
> -    case MENELAUS_VCORE_CTRL5: reg ++;
> -    case MENELAUS_VCORE_CTRL4: reg ++;
> -    case MENELAUS_VCORE_CTRL3: reg ++;
> -    case MENELAUS_VCORE_CTRL2: reg ++;
> +    case MENELAUS_VCORE_CTRL5:
> +    case MENELAUS_VCORE_CTRL4:
> +    case MENELAUS_VCORE_CTRL3:
> +    case MENELAUS_VCORE_CTRL2:
>      case MENELAUS_VCORE_CTRL1:
> -        return s->vcore[reg];
> +        return s->vcore[addr - MENELAUS_VCORE_CTRL1];

Suggest to count up instead of down:

       case MENELAUS_VCORE_CTRL1:
  +    case MENELAUS_VCORE_CTRL2:
  +    case MENELAUS_VCORE_CTRL3:
  +    case MENELAUS_VCORE_CTRL4:
  +    case MENELAUS_VCORE_CTRL5:
  -        return s->vcore[reg];
  +        return s->vcore[addr - MENELAUS_VCORE_CTRL1];

[...]


  reply	other threads:[~2020-10-21  2:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-20 10:51 [PATCH v2] hw/rtc/twl92230: Silence warnings about missing fallthrough statements Thomas Huth
2020-10-20 10:51 ` Thomas Huth
2020-10-20 10:51 ` Thomas Huth
2020-10-21  2:50 ` Markus Armbruster [this message]
2020-10-21  2:50   ` Markus Armbruster

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=877drks358.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    /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.