qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] qemu-char: reset errno before qemu char write o


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] qemu-char: reset errno before qemu char write or read action
Date: Mon, 2 Jul 2018 16:01:11 +0100
User-agent: Mutt/1.10.0 (2018-05-17)

On Mon, Jul 02, 2018 at 08:49:10AM +0800, xinhua.Cao wrote:
> 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 reset errno before reading and writing to
> ensure the correctness of errno's judgment
> 
> Signed-off-by: xinhua.Cao <address@hidden>
> ---
>  chardev/char-fe.c | 1 +
>  chardev/char.c    | 2 ++
>  2 files changed, 3 insertions(+)

The C11x standard "7.4 Errors <errno.h>" says that errno "is never set
to zero by any library function".  Please follow the errno usage
convention described in the C standard.

Instead of making functions called by tcp_chr_write() clear errno,
please fix tcp_chr_write() so that errno is only accessed when ret < 0.

Thanks,
Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

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