diff mbox

[v3,17/28] get_vhost_net() should be != null after vhost_user_init

Message ID 20160706184721.2007-18-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 6, 2016, 6:47 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/net/vhost_net.c | 1 +
 net/vhost-user.c   | 2 ++
 2 files changed, 3 insertions(+)

Comments

Michael S. Tsirkin July 20, 2016, 1:36 p.m. UTC | #1
On Wed, Jul 06, 2016 at 08:47:10PM +0200, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/net/vhost_net.c | 1 +
>  net/vhost-user.c   | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index f1dd367..22ea653 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -417,6 +417,7 @@ VHostNetState *get_vhost_net(NetClientState *nc)
>          break;
>      case NET_CLIENT_OPTIONS_KIND_VHOST_USER:
>          vhost_net = vhost_user_get_vhost_net(nc);
> +        assert(vhost_net != NULL);
>          break;
>      default:
>          break;
> diff --git a/net/vhost-user.c b/net/vhost-user.c
> index 9ad7bcc..c9a5ed7 100644
> --- a/net/vhost-user.c
> +++ b/net/vhost-user.c
> @@ -255,6 +255,8 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
>  
>      qemu_chr_add_handlers(chr, NULL, NULL, net_vhost_user_event, nc[0].name);
>  
> +    assert(s->vhost_net != NULL);
> +
>      return 0;
>  }
> 

I prefer just assert(s->vhost_net) please without != NULL.

 
> -- 
> 2.9.0
Marc-Andre Lureau July 21, 2016, 7:55 a.m. UTC | #2
Hi

----- Original Message -----
> On Wed, Jul 06, 2016 at 08:47:10PM +0200, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  hw/net/vhost_net.c | 1 +
> >  net/vhost-user.c   | 2 ++
> >  2 files changed, 3 insertions(+)
> > 
> > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> > index f1dd367..22ea653 100644
> > --- a/hw/net/vhost_net.c
> > +++ b/hw/net/vhost_net.c
> > @@ -417,6 +417,7 @@ VHostNetState *get_vhost_net(NetClientState *nc)
> >          break;
> >      case NET_CLIENT_OPTIONS_KIND_VHOST_USER:
> >          vhost_net = vhost_user_get_vhost_net(nc);
> > +        assert(vhost_net != NULL);
> >          break;
> >      default:
> >          break;
> > diff --git a/net/vhost-user.c b/net/vhost-user.c
> > index 9ad7bcc..c9a5ed7 100644
> > --- a/net/vhost-user.c
> > +++ b/net/vhost-user.c
> > @@ -255,6 +255,8 @@ static int net_vhost_user_init(NetClientState *peer,
> > const char *device,
> >  
> >      qemu_chr_add_handlers(chr, NULL, NULL, net_vhost_user_event,
> >      nc[0].name);
> >  
> > +    assert(s->vhost_net != NULL);
> > +
> >      return 0;
> >  }
> > 
> 
> I prefer just assert(s->vhost_net) please without != NULL.

ok (hopefully I didn't forget any)

> 
>  
> > --
> > 2.9.0
>
diff mbox

Patch

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index f1dd367..22ea653 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -417,6 +417,7 @@  VHostNetState *get_vhost_net(NetClientState *nc)
         break;
     case NET_CLIENT_OPTIONS_KIND_VHOST_USER:
         vhost_net = vhost_user_get_vhost_net(nc);
+        assert(vhost_net != NULL);
         break;
     default:
         break;
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 9ad7bcc..c9a5ed7 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -255,6 +255,8 @@  static int net_vhost_user_init(NetClientState *peer, const char *device,
 
     qemu_chr_add_handlers(chr, NULL, NULL, net_vhost_user_event, nc[0].name);
 
+    assert(s->vhost_net != NULL);
+
     return 0;
 }