From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: David Gibson <david@gibson.dropbear.id.au>,
qemu-devel <qemu-devel@nongnu.org>,
Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH 2/3] spapr: Fix compiler warning for some versions of gcc (h_remove)
Date: Mon, 24 Jun 2013 23:07:47 +0200 [thread overview]
Message-ID: <51C8B523.6030204@redhat.com> (raw)
In-Reply-To: <51C8AD7C.9000500@weilnetz.de>
Il 24/06/2013 22:35, Stefan Weil ha scritto:
> Am 24.06.2013 22:27, schrieb Paolo Bonzini:
>> Il 24/06/2013 19:48, Stefan Weil ha scritto:
>>> i686-w64-mingw32-gcc (GCC) 4.6.3 from Debian wheezy reports this warning:
>>>
>>> hw/ppc/spapr_hcall.c:188:1: warning:
>>> control reaches end of non-void function [-Wreturn-type]
>>>
>>> Replacing the 4th case REMOVE_HW (which is currently unused) by the default
>>> case fixes this warning.
>>>
>>> The assertion is dead code because all possible cases are handled in the
>>> switch statements, so remove it. This avoids future warnings from static
>>> code analyzers.
>>>
>>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>>> ---
>>> hw/ppc/spapr_hcall.c | 4 +---
>>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
>>> index 00f21f5..d49ce53 100644
>>> --- a/hw/ppc/spapr_hcall.c
>>> +++ b/hw/ppc/spapr_hcall.c
>>> @@ -180,11 +180,9 @@ static target_ulong h_remove(PowerPCCPU *cpu, sPAPREnvironment *spapr,
>>> case REMOVE_PARM:
>>> return H_PARAMETER;
>>>
>>> - case REMOVE_HW:
>>> + default: /* REMOVE_HW */
>>> return H_HARDWARE;
>>> }
>>> -
>>> - assert(0);
>>> }
>>>
>>> #define H_BULK_REMOVE_TYPE 0xc000000000000000ULL
>>>
>> Does s/assert(0)/abort()/ fix the warning too? That's clearer.
>
> Yes, that also fixes this warning. A better compiler or a static
> code checker might then complain about dead code because all
> possible cases are handled in the switch statement.
We'll get there when we see it... and such a compiler can well learn to
ignore a dead abort().
Paolo
next prev parent reply other threads:[~2013-06-24 21:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-24 17:48 [Qemu-devel] [PATCH 0/3] spapr: Fix remaining compiler warnings Stefan Weil
2013-06-24 17:48 ` [Qemu-devel] [PATCH 1/3] spapr: Use named enum for function remove_hpte Stefan Weil
2013-07-02 12:45 ` Alexander Graf
2013-06-24 17:48 ` [Qemu-devel] [PATCH 2/3] spapr: Fix compiler warning for some versions of gcc (h_remove) Stefan Weil
2013-06-24 20:27 ` Paolo Bonzini
2013-06-24 20:35 ` Stefan Weil
2013-06-24 21:07 ` Paolo Bonzini [this message]
2013-06-24 17:48 ` [Qemu-devel] [PATCH 3/3] spapr: Fix compiler warning for some versions of gcc (spapr_io_read) Stefan Weil
2013-07-02 12:45 ` Alexander Graf
2013-07-02 20:22 ` Stefan Weil
2013-07-02 20:25 ` Alexander Graf
2013-06-26 8:14 ` [Qemu-devel] [PATCH 0/3] spapr: Fix remaining compiler warnings Paolo Bonzini
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=51C8B523.6030204@redhat.com \
--to=pbonzini@redhat.com \
--cc=agraf@suse.de \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/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.