From 22e135fca3f2512f43d39efab49067660e365e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 25 Apr 2022 11:56:42 +0400 Subject: Replace fcntl(O_NONBLOCK) with g_unix_set_fd_nonblocking() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested-by: Daniel P. Berrangé Signed-off-by: Marc-André Lureau Reviewed-by: Richard Henderson --- util/oslib-posix.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'util') 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) -- cgit v1.1