aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLi Qiang <liq3ea@163.com>2018-12-15 04:03:53 -0800
committerMichael S. Tsirkin <mst@redhat.com>2019-01-14 19:31:04 -0500
commitda93b82079dcb43885a84bc25b746fd15ae29dfb (patch)
treee6a7c6f32713f584ba0116b3300707961d44f502 /util
parentb0aa77d36d9150aaa7acd8b86e4e65162939d0bf (diff)
downloadqemu-da93b82079dcb43885a84bc25b746fd15ae29dfb.zip
qemu-da93b82079dcb43885a84bc25b746fd15ae29dfb.tar.gz
qemu-da93b82079dcb43885a84bc25b746fd15ae29dfb.tar.bz2
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 <liq3ea@163.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/oslib-posix.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index c1bee2a..4ce1ba9 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)