]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
gdbstub: Use qemu_set_cloexec()
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 14 May 2018 17:30:43 +0000 (18:30 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Sun, 20 May 2018 05:55:54 +0000 (08:55 +0300)
Use the utility routine qemu_set_cloexec() rather than
manually calling fcntl(). This lets us drop the #ifndef _WIN32
guards and also means Coverity doesn't complain that we're
ignoring the fcntl error return (CID 1005665, CID 1005667).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
gdbstub.c

index 9682e16ef7831da7826305d61cb88fe0e6bba11f..b99980d2e25e36212ad9a12aee05082d5ddcea3f 100644 (file)
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1828,9 +1828,7 @@ static void gdb_accept(void)
             perror("accept");
             return;
         } else if (fd >= 0) {
-#ifndef _WIN32
-            fcntl(fd, F_SETFD, FD_CLOEXEC);
-#endif
+            qemu_set_cloexec(fd);
             break;
         }
     }
@@ -1857,9 +1855,7 @@ static int gdbserver_open(int port)
         perror("socket");
         return -1;
     }
-#ifndef _WIN32
-    fcntl(fd, F_SETFD, FD_CLOEXEC);
-#endif
+    qemu_set_cloexec(fd);
 
     socket_set_fast_reuse(fd);