diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-04-25 11:56:42 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-05-03 15:47:38 +0400 |
commit | 22e135fca3f2512f43d39efab49067660e365e1b (patch) | |
tree | 11bdfaec65d018ab43269a916d8233f566262381 /util/oslib-posix.c | |
parent | d640b59eb3c7925568c5b101f439b0c0e65ea313 (diff) | |
download | qemu-22e135fca3f2512f43d39efab49067660e365e1b.zip qemu-22e135fca3f2512f43d39efab49067660e365e1b.tar.gz qemu-22e135fca3f2512f43d39efab49067660e365e1b.tar.bz2 |
Replace fcntl(O_NONBLOCK) with g_unix_set_fd_nonblocking()
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r-- | util/oslib-posix.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 2a6f624..72f25e5 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -226,24 +226,12 @@ void qemu_anon_ram_free(void *ptr, size_t size) void qemu_set_block(int fd) { - int f; - f = fcntl(fd, F_GETFL); - assert(f != -1); - f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK); - assert(f != -1); + g_unix_set_fd_nonblocking(fd, false, NULL); } int qemu_try_set_nonblock(int fd) { - int f; - f = fcntl(fd, F_GETFL); - if (f == -1) { - return -errno; - } - if (fcntl(fd, F_SETFL, f | O_NONBLOCK) == -1) { - return -errno; - } - return 0; + return g_unix_set_fd_nonblocking(fd, true, NULL) ? 0 : -errno; } void qemu_set_nonblock(int fd) |