[Spice-devel] [PATCH v2 2/2] Quiet uninitialized variable warning.

Michal Suchánek msuchanek at suse.de
Mon Jan 9 13:11:02 UTC 2017


On Mon, 09 Jan 2017 10:51:34 +0100
Pavel Grunt <pgrunt at redhat.com> wrote:

Hello,

> Hi Michal,
> 
> On Fri, 2017-01-06 at 14:25 +0100, Michal Suchanek wrote:
> > Signed-off-by: Michal Suchanek <msuchanek at suse.de>
> > ---
> >  src/vdagentd/vdagentd.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c
> > index 991514e..60a866e 100644
> > --- a/src/vdagentd/vdagentd.c
> > +++ b/src/vdagentd/vdagentd.c
> > @@ -334,6 +334,7 @@ static void do_client_file_xfer(struct
> > vdagent_virtio_port *vport,
> >          id = d->id;
> >          break;
> >      }
> > +    default: return; /* quiet uninitialized variable warning */  
> I would go for 'g_return_if_reached' - it will log a warning, also it
> should be on a new line. I can do the changes and push if you agree.
> 

I use this locally to be able to build with gcc 6. gcc 4.8.5 does not
detect the issue and gcc 7 should be able to detect that the function
is called from a switch statement where only the values already tested
above are allowed. 

If you want to use another style for the fix that's fine. I can drop
this one then.

Thanks

Michal


More information about the Spice-devel mailing list