|
From: | xinhua . Cao |
Subject: | Re: [Qemu-devel] [PATCH] qemu-char: reset errno before qemu char write or read action |
Date: | Wed, 4 Jul 2018 10:10:11 +0800 |
User-agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
在 2018/7/2 23:01, Stefan Hajnoczi 写道:
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.
yes, I know that errno must be used after a negative return value. But if you check the return value in tcp_chr_write,the logic is a bit more complicated. So I reset the errno in the outer layer.
I will check the return value at tcp_chr_write at v2 patch.
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
[Prev in Thread] | Current Thread | [Next in Thread] |