[Spice-devel] [spice-vdagent PATCH v2 2/2] virtio-port: handle_fds: make read and write code consistent

Uri Lublin uril at redhat.com
Thu Aug 29 16:35:24 UTC 2019


A comment and curly brackets for style were added.

Signed-off-by: Uri Lublin <uril at redhat.com>
---

v1->v2: use shorter version (alternative of v1)
        add curly brackets to if blocks

---
 src/vdagentd/virtio-port.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/vdagentd/virtio-port.c b/src/vdagentd/virtio-port.c
index 3ae7f22..06f3a32 100644
--- a/src/vdagentd/virtio-port.c
+++ b/src/vdagentd/virtio-port.c
@@ -166,14 +166,14 @@ int vdagent_virtio_port_fill_fds(struct vdagent_virtio_port *vport,
 void vdagent_virtio_port_handle_fds(struct vdagent_virtio_port **vportp,
         fd_set *readfds, fd_set *writefds)
 {
-    if (!*vportp)
-        return;
-
-    if (FD_ISSET((*vportp)->fd, readfds))
+    if (*vportp && FD_ISSET((*vportp)->fd, readfds)) {
         vdagent_virtio_port_do_read(vportp);
+    }
 
-    if (*vportp && FD_ISSET((*vportp)->fd, writefds))
+    /* *vportp may have been destroyed in do_read */
+    if (*vportp && FD_ISSET((*vportp)->fd, writefds)) {
         vdagent_virtio_port_do_write(vportp);
+    }
 }
 
 static struct vdagent_virtio_port_buf* vdagent_virtio_port_get_last_wbuf(
-- 
2.21.0



More information about the Spice-devel mailing list