From: Peter Maydell <peter.maydell@linaro.org>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-ppc@nongnu.org, Anthony Liguori <aliguori@us.ibm.com>,
	Mark Langsdorf <mark.langsdorf@calxeda.com>,
	Riku Voipio <riku.voipio@iki.fi>,
	qemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>,
	Peter Crosthwaite <peter.crosthwaite@petalogix.com>,
	Max Filippov <jcmvbkbc@gmail.com>,
	"Vassili Karpov (malc)" <av1474@comtv.ru>,
	Paul Brook <paul@codesourcery.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Guan Xuetao <gxt@mprc.pku.edu.cn>,
	Aurelien Jarno <aurelien@aurel32.net>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH] Annotate questionable fallthroughs
Date: Sun, 20 Jan 2013 16:56:25 +0000	[thread overview]
Message-ID: <CAFEAcA8o5pnr-VbEAR0WqFvNC5EFvuh1wyAAkyAKqqGYRxp15g@mail.gmail.com> (raw)
In-Reply-To: <19952e84d566d9309b15fe205db6b166f4234c33.1358697255.git.blauwirbel@gmail.com>
On 20 January 2013 15:54, Blue Swirl <blauwirbel@gmail.com> wrote:
This patch is a bit big to usefully review. A few comments on bits
I happened to notice:
> diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c
> index a196fcc..2066ef3 100644
> --- a/hw/arm_sysctl.c
> +++ b/hw/arm_sysctl.c
> @@ -199,6 +199,7 @@ static void arm_sysctl_write(void *opaque, hwaddr offset,
>      switch (offset) {
>      case 0x08: /* LED */
>          s->leds = val;
> +        /* XXX: questionable fallthrough */
Should have its own 'break' but it's safe currently as the following
case is just 'break' anyway.
>      case 0x0c: /* OSC0 */
>      case 0x10: /* OSC1 */
>      case 0x14: /* OSC2 */
> @@ -295,6 +296,7 @@ static void arm_sysctl_write(void *opaque, hwaddr offset,
>              /* On VExpress this register is unimplemented and will RAZ/WI */
>              break;
>          }
> +        /* XXX: questionable fallthrough */
Ditto.
>      case 0x54: /* CLCDSER */
>      case 0x64: /* DMAPSR0 */
>      case 0x68: /* DMAPSR1 */
> --- a/hw/es1370.c
> +++ b/hw/es1370.c
> @@ -537,8 +537,10 @@ IO_WRITE_PROTO (es1370_writew)
>
>      case ES1370_REG_ADC_SCOUNT:
>          d++;
> +        /* XXX: questionable fallthrough */
>      case ES1370_REG_DAC2_SCOUNT:
>          d++;
> +        /* XXX: questionable fallthrough */
>      case ES1370_REG_DAC1_SCOUNT:
>          d->scount = (d->scount & ~0xffff) | (val & 0xffff);
>          break;
These fallthroughs are clearly intentional (similar cases
elsewhere in your patch).
> --- a/hw/stellaris.c
> +++ b/hw/stellaris.c
> @@ -182,8 +182,10 @@ static uint64_t gptm_read(void *opaque, hwaddr offset,
>      case 0x48: /* TAR */
>          if (s->control == 1)
>              return s->rtc;
> +        /* XXX: questionable fallthrough */
>      case 0x4c: /* TBR */
>          hw_error("TODO: Timer value read\n");
> +        /* XXX: questionable fallthrough */
This isn't a fallthrough at all, hw_error() never returns.
>      default:
>          hw_error("gptm_read: Bad offset 0x%x\n", (int)offset);
>          return 0;
(...so this return 0 is unreachable, but hey.)
I don't think there's much point adding tons of "XXX" comments
when a bunch of these aren't actually wrong code. If you want to fix
this I think a better approach would be more focused patches aimed
at adding 'break;' or "/* fallthrough */" based on actual human
examination of the surrounding code.
-- PMM
next prev parent reply	other threads:[~2013-01-20 16:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-20 15:54 [Qemu-devel] [PATCH] Annotate questionable fallthroughs Blue Swirl
2013-01-20 16:56 ` Peter Maydell [this message]
2013-01-20 17:26   ` Blue Swirl
2013-01-20 17:38     ` Andreas Färber
2013-01-20 18:10       ` Peter Maydell
2013-01-20 18:32   ` Paul Brook
2013-01-21 10:36   ` Markus Armbruster
2013-01-21  8:58 ` Kevin Wolf
2013-01-21 13:11 ` 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=CAFEAcA8o5pnr-VbEAR0WqFvNC5EFvuh1wyAAkyAKqqGYRxp15g@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=agraf@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=aurelien@aurel32.net \
    --cc=av1474@comtv.ru \
    --cc=blauwirbel@gmail.com \
    --cc=gxt@mprc.pku.edu.cn \
    --cc=jcmvbkbc@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=mark.langsdorf@calxeda.com \
    --cc=paul@codesourcery.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@petalogix.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=rth@twiddle.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).