diff mbox

[3/3] spapr: Fix compiler warning for some versions of gcc (spapr_io_read)

Message ID 1372096130-24994-4-git-send-email-sw@weilnetz.de
State Superseded
Headers show

Commit Message

Stefan Weil June 24, 2013, 5:48 p.m. UTC
i686-w64-mingw32-gcc (GCC) 4.6.3 from Debian wheezy reports this warning:

hw/ppc/spapr_pci.c:454:1: warning:
 control reaches end of non-void function [-Wreturn-type]

Adding a default case to the switch statement satisfies the compiler.
This modification requires moving the assert statement.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/ppc/spapr_pci.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Alexander Graf July 2, 2013, 12:45 p.m. UTC | #1
On 06/24/2013 07:48 PM, Stefan Weil wrote:
> i686-w64-mingw32-gcc (GCC) 4.6.3 from Debian wheezy reports this warning:
>
> hw/ppc/spapr_pci.c:454:1: warning:
>   control reaches end of non-void function [-Wreturn-type]
>
> Adding a default case to the switch statement satisfies the compiler.
> This modification requires moving the assert statement.
>
> Signed-off-by: Stefan Weil<sw@weilnetz.de>
> ---
>   hw/ppc/spapr_pci.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 04e8362..c04086c 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -448,9 +448,10 @@ static uint64_t spapr_io_read(void *opaque, hwaddr addr,
>       case 2:
>           return cpu_inw(addr);
>       case 4:
> +    default:
> +        assert(size == 4);
>           return cpu_inl(addr);

Please fix this one up with g_assert_not_reached() as well.


Alex
Stefan Weil July 2, 2013, 8:22 p.m. UTC | #2
Am 02.07.2013 14:45, schrieb Alexander Graf:
> On 06/24/2013 07:48 PM, Stefan Weil wrote:
>> i686-w64-mingw32-gcc (GCC) 4.6.3 from Debian wheezy reports this
>> warning:
>>
>> hw/ppc/spapr_pci.c:454:1: warning:
>>   control reaches end of non-void function [-Wreturn-type]
>>
>> Adding a default case to the switch statement satisfies the compiler.
>> This modification requires moving the assert statement.
>>
>> Signed-off-by: Stefan Weil<sw@weilnetz.de>
>> ---
>>   hw/ppc/spapr_pci.c |    3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
>> index 04e8362..c04086c 100644
>> --- a/hw/ppc/spapr_pci.c
>> +++ b/hw/ppc/spapr_pci.c
>> @@ -448,9 +448,10 @@ static uint64_t spapr_io_read(void *opaque,
>> hwaddr addr,
>>       case 2:
>>           return cpu_inw(addr);
>>       case 4:
>> +    default:
>> +        assert(size == 4);
>>           return cpu_inl(addr);
>
> Please fix this one up with g_assert_not_reached() as well.
>
> Alex

I did, and you applied it to ppc-next. :-)

See http://patchwork.ozlabs.org/patch/255738/.

Cheers
Stefan
Alexander Graf July 2, 2013, 8:25 p.m. UTC | #3
Am 02.07.2013 um 22:22 schrieb Stefan Weil <sw@weilnetz.de>:

> Am 02.07.2013 14:45, schrieb Alexander Graf:
>> On 06/24/2013 07:48 PM, Stefan Weil wrote:
>>> i686-w64-mingw32-gcc (GCC) 4.6.3 from Debian wheezy reports this
>>> warning:
>>> 
>>> hw/ppc/spapr_pci.c:454:1: warning:
>>>  control reaches end of non-void function [-Wreturn-type]
>>> 
>>> Adding a default case to the switch statement satisfies the compiler.
>>> This modification requires moving the assert statement.
>>> 
>>> Signed-off-by: Stefan Weil<sw@weilnetz.de>
>>> ---
>>>  hw/ppc/spapr_pci.c |    3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
>>> index 04e8362..c04086c 100644
>>> --- a/hw/ppc/spapr_pci.c
>>> +++ b/hw/ppc/spapr_pci.c
>>> @@ -448,9 +448,10 @@ static uint64_t spapr_io_read(void *opaque,
>>> hwaddr addr,
>>>      case 2:
>>>          return cpu_inw(addr);
>>>      case 4:
>>> +    default:
>>> +        assert(size == 4);
>>>          return cpu_inl(addr);
>> 
>> Please fix this one up with g_assert_not_reached() as well.
>> 
>> Alex
> 
> I did, and you applied it to ppc-next. :-)
> 
> See http://patchwork.ozlabs.org/patch/255738/.

Oops, just consider me stupid then :)


Alex

> 
> Cheers
> Stefan
>
diff mbox

Patch

diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 04e8362..c04086c 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -448,9 +448,10 @@  static uint64_t spapr_io_read(void *opaque, hwaddr addr,
     case 2:
         return cpu_inw(addr);
     case 4:
+    default:
+        assert(size == 4);
         return cpu_inl(addr);
     }
-    assert(0);
 }
 
 static void spapr_io_write(void *opaque, hwaddr addr,