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

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

 



> 
> "return early" before write too
> 
> Signed-off-by: Uri Lublin <uril@xxxxxxxxxx>
> ---
> 
> Alternatively, change the read part such that:
> 
>     if (*vportp && FD_ISSET((*vportp)->fd, readfds))
>         vdagent_virtio_port_do_read
>     if (*vportp && FD_ISSET((*vportp)->fd, writefds))
>         vdagent_virtio_port_do_write
> 
> 
> ---
>  src/vdagentd/virtio-port.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/vdagentd/virtio-port.c b/src/vdagentd/virtio-port.c
> index 3ae7f22..af5bd58 100644
> --- a/src/vdagentd/virtio-port.c
> +++ b/src/vdagentd/virtio-port.c
> @@ -172,7 +172,10 @@ void vdagent_virtio_port_handle_fds(struct
> vdagent_virtio_port **vportp,
>      if (FD_ISSET((*vportp)->fd, readfds))
>          vdagent_virtio_port_do_read(vportp);
>  
> -    if (*vportp && FD_ISSET((*vportp)->fd, writefds))
> +    if (!*vportp) /* may have been destroyed in do_read */
> +        return;
> +
> +    if (FD_ISSET((*vportp)->fd, writefds))
>          vdagent_virtio_port_do_write(vportp);
>  }
>  

They are equivalent (beside the comment which can be added on top of
the if).
I like the alternative version if it's really important.
Style: always brackets.

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]