From: Li Qiang Date: Sat, 15 Dec 2018 12:03:53 +0000 (-0800) Subject: util: check the return value of fcntl in qemu_set_{block, nonblock} X-Git-Tag: v4.0.0-rc0~161^2~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da93b82079dcb43885a84bc25b746fd15ae29dfb;p=thirdparty%2Fqemu.git util: check the return value of fcntl in qemu_set_{block, nonblock} Assert that the return value is not an error. This is like commit 7e6478e7d4f for qemu_set_cloexec. Signed-off-by: Li Qiang Reviewed-by: Thomas Huth Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- diff --git a/util/oslib-posix.c b/util/oslib-posix.c index c1bee2a5814..4ce1ba9ca42 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -233,14 +233,18 @@ void qemu_set_block(int fd) { int f; f = fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, f & ~O_NONBLOCK); + assert(f != -1); + f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK); + assert(f != -1); } void qemu_set_nonblock(int fd) { int f; f = fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, f | O_NONBLOCK); + assert(f != -1); + f = fcntl(fd, F_SETFL, f | O_NONBLOCK); + assert(f != -1); } int socket_set_fast_reuse(int fd)