qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] slirp: Add explanation for hostfwd parsing fail


From: Dr. David Alan Gilbert
Subject: Re: [Qemu-devel] [PATCH] slirp: Add explanation for hostfwd parsing failure
Date: Fri, 8 Sep 2017 19:36:44 +0100
User-agent: Mutt/1.8.3 (2017-05-23)

* Philippe Mathieu-Daudé (address@hidden) wrote:
> On 09/08/2017 01:22 PM, Dr. David Alan Gilbert wrote:
> > * Philippe Mathieu-Daudé (address@hidden) wrote:
> > > Hi David,
> > > 
> > > On 09/08/2017 12:53 PM, Dr. David Alan Gilbert (git) wrote:
> > > > From: "Dr. David Alan Gilbert" <address@hidden>
> > > > 
> > > > e.g.
> > > > ./x86_64-softmmu/qemu-system-x86_64 -nographic -netdev 
> > > > 'user,id=vnet,hostfwd=:555.0.0.0:0-:22'
> > > > qemu-system-x86_64: -netdev user,id=vnet,hostfwd=:555.0.0.0:0-:22: 
> > > > Invalid host forwarding rule ':555.0.0.0:0-:22' (Bad host address)
> > > > 
> > > > Signed-off-by: Dr. David Alan Gilbert <address@hidden>
> > > > ---
> > > >    net/slirp.c | 13 ++++++++++++-
> > > >    1 file changed, 12 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/net/slirp.c b/net/slirp.c
> > > > index 01ed21c006..d87664d42e 100644
> > > > --- a/net/slirp.c
> > > > +++ b/net/slirp.c
> > > > @@ -496,9 +496,11 @@ static int slirp_hostfwd(SlirpState *s, const char 
> > > > *redir_str,
> > > >        char buf[256];
> > > >        int is_udp;
> > > >        char *end;
> > > > +    const char *fail_reason = "";
> > > 
> > > Isn't it better not initialize this? So if one add a new failed syntax 
> > > case
> > > the build with abort with -Werror=uninitialized
> > 
> > I never quite trust compilers to spot it or not-moan even though
> > every route to failure will have set it.
> 
> I see, what about:
> 
> const char *fail_reason = "Unknown reason";

I could, but you're right that I shouldn't miss any, and
'Unknown Reason' doesn't tell the user any more than no message.

Dave

> > 
> > > Anyway:
> > > Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK



reply via email to

[Prev in Thread] Current Thread [Next in Thread]