All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] util: check the return value of fcntl in qemu_set_{block, noblock}
@ 2018-12-13  2:09 Li Qiang
  2018-12-13  6:57 ` no-reply
  2018-12-13 10:19 ` Daniel P. Berrangé
  0 siblings, 2 replies; 13+ messages in thread
From: Li Qiang @ 2018-12-13  2:09 UTC (permalink / raw)
  To: peter.maydell, marcandre.lureau, pbonzini; +Cc: qemu-devel, Li Qiang

Assert that the return value is not an error. This is like commit
7e6478e7d4f for qemu_set_cloexec.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
 util/oslib-posix.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index c1bee2a581..4ce1ba9ca4 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)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-12-13 14:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13  2:09 [Qemu-devel] [PATCH] util: check the return value of fcntl in qemu_set_{block, noblock} Li Qiang
2018-12-13  6:57 ` no-reply
2018-12-13  9:31   ` Peter Maydell
2018-12-13  9:56     ` Li Qiang
2018-12-13 10:17       ` Daniel P. Berrangé
2018-12-13 10:38         ` Li Qiang
2018-12-13 10:19 ` Daniel P. Berrangé
2018-12-13 11:27   ` Peter Maydell
2018-12-13 12:28     ` Markus Armbruster
2018-12-13 12:39       ` Daniel P. Berrangé
2018-12-13 12:54         ` Peter Maydell
2018-12-13 14:40           ` Markus Armbruster
2018-12-13 14:43         ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.