qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] qemu-char: check errno together with ret < 0


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH] qemu-char: check errno together with ret < 0
Date: Wed, 04 Jul 2018 13:11:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

xinhua.Cao <address@hidden> writes:

> In the tcp_chr_write function, we checked errno,
> but errno was not reset before a read or write operation.
> Therefore, this check of errno's actions is often
> incorrect after EAGAIN has occurred.
> we need check errno together with ret < 0.
>
> Signed-off-by: xinhua.Cao <address@hidden>
> ---
>  chardev/char-socket.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index 17519ec..efbad6e 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -134,8 +134,11 @@ static int tcp_chr_write(Chardev *chr, const uint8_t 
> *buf, int len)
>                                          s->write_msgfds,
>                                          s->write_msgfds_num);
>  
> -        /* free the written msgfds in any cases other than errno==EAGAIN */
> -        if (EAGAIN != errno && s->write_msgfds_num) {
> +        /* free the written msgfds in any cases
> +         * other than ret < 0 && errno == EAGAIN
> +         */
> +        if (!(ret < 0 && EAGAIN == errno)
> +            && s->write_msgfds_num) {
>              g_free(s->write_msgfds);
>              s->write_msgfds = 0;
>              s->write_msgfds_num = 0;

The comment feels pretty worthless to me.



reply via email to

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