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
7e6478e7d4 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>
This commit is contained in:
Li Qiang 2018-12-15 04:03:53 -08:00 committed by Michael S. Tsirkin
parent b0aa77d36d
commit da93b82079
1 changed files with 6 additions and 2 deletions

View File

@ -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)