Commit da93b820 authored by Li Qiang's avatar Li Qiang Committed by Michael S. Tsirkin
Browse files

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
7e6478e7 for qemu_set_cloexec.

Signed-off-by: default avatarLi Qiang <liq3ea@163.com>
Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent b0aa77d3
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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)