qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vga: squash build error in vga_update_memory_access()
@ 2011-08-24 12:07 Avi Kivity
  2011-08-24 12:46 ` Jan Kiszka
  0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2011-08-24 12:07 UTC (permalink / raw)
  To: qemu-devel

Newer gcc complains that base and size may be used uninitialized, even though
it is clearly a false warning.  Silence the warning by indicating to gcc that
the code path triggering the warning cannot happen.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/vga.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/vga.c b/hw/vga.c
index 851fd68..b74e6e8 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -179,6 +179,8 @@ static void vga_update_memory_access(VGACommonState *s)
             base = 0xb8000;
             size = 0x8000;
             break;
+        default:
+            abort();
         }
         region = g_malloc(sizeof(*region));
         memory_region_init_alias(region, "vga.chain4", &s->vram, offset, size);
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] vga: squash build error in vga_update_memory_access()
  2011-08-24 12:07 [Qemu-devel] [PATCH] vga: squash build error in vga_update_memory_access() Avi Kivity
@ 2011-08-24 12:46 ` Jan Kiszka
  2011-08-24 12:58   ` Avi Kivity
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Kiszka @ 2011-08-24 12:46 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel

On 2011-08-24 14:07, Avi Kivity wrote:
> Newer gcc complains that base and size may be used uninitialized, even though
> it is clearly a false warning.

Mmh, gcc is getting dumber again.

>  Silence the warning by indicating to gcc that
> the code path triggering the warning cannot happen.
> 
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  hw/vga.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/vga.c b/hw/vga.c
> index 851fd68..b74e6e8 100644
> --- a/hw/vga.c
> +++ b/hw/vga.c
> @@ -179,6 +179,8 @@ static void vga_update_memory_access(VGACommonState *s)
>              base = 0xb8000;
>              size = 0x8000;
>              break;
> +        default:
> +            abort();
>          }
>          region = g_malloc(sizeof(*region));
>          memory_region_init_alias(region, "vga.chain4", &s->vram, offset, size);

...or just make the last case default?

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] vga: squash build error in vga_update_memory_access()
  2011-08-24 12:46 ` Jan Kiszka
@ 2011-08-24 12:58   ` Avi Kivity
  2011-08-24 13:00     ` Jan Kiszka
  0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2011-08-24 12:58 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel

On 08/24/2011 03:46 PM, Jan Kiszka wrote:
> >  +++ b/hw/vga.c
> >  @@ -179,6 +179,8 @@ static void vga_update_memory_access(VGACommonState *s)
> >               base = 0xb8000;
> >               size = 0x8000;
> >               break;
> >  +        default:
> >  +            abort();
> >           }
> >           region = g_malloc(sizeof(*region));
> >           memory_region_init_alias(region, "vga.chain4",&s->vram, offset, size);
>
> ...or just make the last case default?
>

No reason to make the code unobvious in this path, IMO.  Eventually gcc 
will be able to drop the 4/5 bytes this patch adds to the object code.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] vga: squash build error in vga_update_memory_access()
  2011-08-24 12:58   ` Avi Kivity
@ 2011-08-24 13:00     ` Jan Kiszka
  2011-08-24 13:07       ` Avi Kivity
  2011-08-24 21:00       ` Anthony Liguori
  0 siblings, 2 replies; 8+ messages in thread
From: Jan Kiszka @ 2011-08-24 13:00 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel@nongnu.org

On 2011-08-24 14:58, Avi Kivity wrote:
> On 08/24/2011 03:46 PM, Jan Kiszka wrote:
>>>  +++ b/hw/vga.c
>>>  @@ -179,6 +179,8 @@ static void vga_update_memory_access(VGACommonState *s)
>>>               base = 0xb8000;
>>>               size = 0x8000;
>>>               break;
>>>  +        default:
>>>  +            abort();
>>>           }
>>>           region = g_malloc(sizeof(*region));
>>>           memory_region_init_alias(region, "vga.chain4",&s->vram, offset, size);
>>
>> ...or just make the last case default?
>>
> 
> No reason to make the code unobvious in this path, IMO.  Eventually gcc 
> will be able to drop the 4/5 bytes this patch adds to the object code.

diff --git a/hw/vga.c b/hw/vga.c
index 851fd68..125fb29 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -176,6 +176,7 @@ static void vga_update_memory_access(VGACommonState *s)
             size = 0x8000;
             break;
         case 3:
+        default:
             base = 0xb8000;
             size = 0x8000;
             break;

...is fairly common and well readable IMHO.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] vga: squash build error in vga_update_memory_access()
  2011-08-24 13:00     ` Jan Kiszka
@ 2011-08-24 13:07       ` Avi Kivity
  2011-08-24 21:00       ` Anthony Liguori
  1 sibling, 0 replies; 8+ messages in thread
From: Avi Kivity @ 2011-08-24 13:07 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel@nongnu.org

On 08/24/2011 04:00 PM, Jan Kiszka wrote:
> On 2011-08-24 14:58, Avi Kivity wrote:
> >  On 08/24/2011 03:46 PM, Jan Kiszka wrote:
> >>>   +++ b/hw/vga.c
> >>>   @@ -179,6 +179,8 @@ static void vga_update_memory_access(VGACommonState *s)
> >>>                base = 0xb8000;
> >>>                size = 0x8000;
> >>>                break;
> >>>   +        default:
> >>>   +            abort();
> >>>            }
> >>>            region = g_malloc(sizeof(*region));
> >>>            memory_region_init_alias(region, "vga.chain4",&s->vram, offset, size);
> >>
> >>  ...or just make the last case default?
> >>
> >
> >  No reason to make the code unobvious in this path, IMO.  Eventually gcc
> >  will be able to drop the 4/5 bytes this patch adds to the object code.
>
> diff --git a/hw/vga.c b/hw/vga.c
> index 851fd68..125fb29 100644
> --- a/hw/vga.c
> +++ b/hw/vga.c
> @@ -176,6 +176,7 @@ static void vga_update_memory_access(VGACommonState *s)
>               size = 0x8000;
>               break;
>           case 3:
> +        default:
>               base = 0xb8000;
>               size = 0x8000;
>               break;
>
> ...is fairly common and well readable IMHO.
>
>

Let's let the maintainers pick the one they like.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] vga: squash build error in vga_update_memory_access()
  2011-08-24 13:00     ` Jan Kiszka
  2011-08-24 13:07       ` Avi Kivity
@ 2011-08-24 21:00       ` Anthony Liguori
  2011-08-25  9:10         ` [Qemu-devel] [PATCH] vga: Silence bogus gcc warning about uninitialized variables Jan Kiszka
  1 sibling, 1 reply; 8+ messages in thread
From: Anthony Liguori @ 2011-08-24 21:00 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, qemu-devel@nongnu.org

On 08/24/2011 08:00 AM, Jan Kiszka wrote:
> On 2011-08-24 14:58, Avi Kivity wrote:
>> On 08/24/2011 03:46 PM, Jan Kiszka wrote:
>>>>   +++ b/hw/vga.c
>>>>   @@ -179,6 +179,8 @@ static void vga_update_memory_access(VGACommonState *s)
>>>>                base = 0xb8000;
>>>>                size = 0x8000;
>>>>                break;
>>>>   +        default:
>>>>   +            abort();
>>>>            }
>>>>            region = g_malloc(sizeof(*region));
>>>>            memory_region_init_alias(region, "vga.chain4",&s->vram, offset, size);
>>>
>>> ...or just make the last case default?
>>>
>>
>> No reason to make the code unobvious in this path, IMO.  Eventually gcc
>> will be able to drop the 4/5 bytes this patch adds to the object code.
>
> diff --git a/hw/vga.c b/hw/vga.c
> index 851fd68..125fb29 100644
> --- a/hw/vga.c
> +++ b/hw/vga.c
> @@ -176,6 +176,7 @@ static void vga_update_memory_access(VGACommonState *s)
>               size = 0x8000;
>               break;
>           case 3:
> +        default:
>               base = 0xb8000;
>               size = 0x8000;
>               break;
>
> ...is fairly common and well readable IMHO.

And is less likely to be considered by someone to be a guest triggerable 
abort().

Can you send the patch as a top-level one with a Signed-off-by?

Regards,

Anthony Liguori

>
> Jan
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH] vga: Silence bogus gcc warning about uninitialized variables
  2011-08-24 21:00       ` Anthony Liguori
@ 2011-08-25  9:10         ` Jan Kiszka
  2011-08-25 22:41           ` Anthony Liguori
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Kiszka @ 2011-08-25  9:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Avi Kivity, qemu-devel@nongnu.org

Some gcc versions do not properly detect that all possible cases are
covered and base and size are always initialized. Please gcc by defining
a pseudo default case.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/vga.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/hw/vga.c b/hw/vga.c
index 851fd68..125fb29 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -176,6 +176,7 @@ static void vga_update_memory_access(VGACommonState *s)
             size = 0x8000;
             break;
         case 3:
+        default:
             base = 0xb8000;
             size = 0x8000;
             break;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] vga: Silence bogus gcc warning about uninitialized variables
  2011-08-25  9:10         ` [Qemu-devel] [PATCH] vga: Silence bogus gcc warning about uninitialized variables Jan Kiszka
@ 2011-08-25 22:41           ` Anthony Liguori
  0 siblings, 0 replies; 8+ messages in thread
From: Anthony Liguori @ 2011-08-25 22:41 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, qemu-devel@nongnu.org

On 08/25/2011 04:10 AM, Jan Kiszka wrote:
> Some gcc versions do not properly detect that all possible cases are
> covered and base and size are always initialized. Please gcc by defining
> a pseudo default case.
>
> Signed-off-by: Jan Kiszka<jan.kiszka@siemens.com>

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   hw/vga.c |    1 +
>   1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/hw/vga.c b/hw/vga.c
> index 851fd68..125fb29 100644
> --- a/hw/vga.c
> +++ b/hw/vga.c
> @@ -176,6 +176,7 @@ static void vga_update_memory_access(VGACommonState *s)
>               size = 0x8000;
>               break;
>           case 3:
> +        default:
>               base = 0xb8000;
>               size = 0x8000;
>               break;

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-08-25 22:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-24 12:07 [Qemu-devel] [PATCH] vga: squash build error in vga_update_memory_access() Avi Kivity
2011-08-24 12:46 ` Jan Kiszka
2011-08-24 12:58   ` Avi Kivity
2011-08-24 13:00     ` Jan Kiszka
2011-08-24 13:07       ` Avi Kivity
2011-08-24 21:00       ` Anthony Liguori
2011-08-25  9:10         ` [Qemu-devel] [PATCH] vga: Silence bogus gcc warning about uninitialized variables Jan Kiszka
2011-08-25 22:41           ` Anthony Liguori

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).