qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	qemu-ppc@nongnu.org, qemu-devel <qemu-devel@nongnu.org>,
	Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 7/9] openpic: avoid a warning from clang analyzer
Date: Mon, 12 Sep 2011 12:12:30 -0500	[thread overview]
Message-ID: <4E6E3D7E.5070608@freescale.com> (raw)
In-Reply-To: <CAAu8pHtJefidoG2-rFFOVScKgztMdy=-tD2HF-MvEhRmWxZuwQ@mail.gmail.com>

On 09/04/2011 10:52 AM, Blue Swirl wrote:
> Avoid this warning by clang analyzer by defining a default case:
> /src/qemu/hw/openpic.c:477:5: warning: Undefined or garbage value
> returned to caller
>     return retval;
> 
> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
> ---
>  hw/openpic.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/openpic.c b/hw/openpic.c
> index 26c96e2..4b883ac 100644
> --- a/hw/openpic.c
> +++ b/hw/openpic.c
> @@ -469,6 +469,7 @@ static inline uint32_t read_IRQreg (openpic_t
> *opp, int n_IRQ, uint32_t reg)
>      case IRQ_IPVP:
>          retval = opp->src[n_IRQ].ipvp;
>          break;
> +    default:
>      case IRQ_IDE:
>          retval = opp->src[n_IRQ].ide;
>          break;

What's special about IDE?  Shouldn't it return 0xffffffff as some other
functions (e.g. openpic_gbl_read) do with unrecognized registers?  Then
there's openpic_src_read() which has still different behavior for the
same registers. :-P

Note that this function is only ever called with a constant in "reg".
Since it's a static function and all call sites could have been
verified, this could be considered a flaw in clang's analyzer.  This
workaround will prevent GCC from issuing a warning if a new caller is
added that passes a different constant value.

The best answer is probably to just get rid of this function and have
the caller refer to opp->src[n_irq].whatever directly.  write_IRQreg()
could be split into something like set_src_ipvp() and set_src_ide().

-Scott

  parent reply	other threads:[~2011-09-12 17:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-04 15:52 [Qemu-devel] [PATCH 7/9] openpic: avoid a warning from clang analyzer Blue Swirl
2011-09-05  6:48 ` Paolo Bonzini
2011-09-05 18:41   ` Blue Swirl
2011-09-07 11:38     ` Alexander Graf
2011-09-12 17:12 ` Scott Wood [this message]
2011-09-12 20:24   ` [Qemu-devel] [Qemu-ppc] " Blue Swirl

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=4E6E3D7E.5070608@freescale.com \
    --to=scottwood@freescale.com \
    --cc=agraf@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.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 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).