Patchwork [v2,12/23] vhost-user: check qemu_chr_fe_set_msgfds() return value

login
register
mail settings
Submitter marcandre.lureau@redhat.com
Date June 24, 2016, 1:50 p.m.
Message ID <20160624135110.17260-13-marcandre.lureau@redhat.com>
Download mbox | patch
Permalink /patch/39879/
State New
Headers show

Comments

marcandre.lureau@redhat.com - June 24, 2016, 1:50 p.m.
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Check return value, and drop the unnecessary 'if' check for fd_num.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/virtio/vhost-user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 495e09f..5dae496 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -187,8 +187,8 @@  static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
         return 0;
     }
 
-    if (fd_num) {
-        qemu_chr_fe_set_msgfds(chr, fds, fd_num);
+    if (qemu_chr_fe_set_msgfds(chr, fds, fd_num) < 0) {
+        return -1;
     }
 
     return qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size) == size ?