aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2012-01-05 14:18:45 +0100
committerJan Kiszka <jan.kiszka@siemens.com>2012-02-08 10:07:54 +0100
commita1681170afed8f8bbe16ce670f9fc07411b781b9 (patch)
treefc212a24575aa67bb2b815861d68eab7500e5986
parentd57f1f6e85c3efcd0f871d4c9b4864070169d34b (diff)
downloadslirp-a1681170afed8f8bbe16ce670f9fc07411b781b9.zip
slirp-a1681170afed8f8bbe16ce670f9fc07411b781b9.tar.gz
slirp-a1681170afed8f8bbe16ce670f9fc07411b781b9.tar.bz2
slirp: Remove unused variable and unused code
9634d9031c140b24c7ca0d8872632207f6ce7275 disabled unused code. This patch removes what was left. If do_pty is 2, the function returns immediately, so any later checks for do_pty == 2 will always fail and can be removed together with the code which is never executed. Then variable master is unused and can be removed, too. This issue was detected by coverity. Cc: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
-rw-r--r--misc.c69
1 files changed, 26 insertions, 43 deletions
diff --git a/misc.c b/misc.c
index 15e118c..e66b1fa 100644
--- a/misc.c
+++ b/misc.c
@@ -106,7 +106,6 @@ int fork_exec(struct socket *so, const char *ex, int do_pty)
struct sockaddr_in addr;
socklen_t addrlen = sizeof(addr);
int opt;
- int master = -1;
const char *argv[256];
/* don't want to clobber the original */
char *bptr;
@@ -141,32 +140,23 @@ int fork_exec(struct socket *so, const char *ex, int do_pty)
case -1:
lprint("Error: fork failed: %s\n", strerror(errno));
close(s);
- if (do_pty == 2)
- close(master);
return 0;
case 0:
setsid();
/* Set the DISPLAY */
- if (do_pty == 2) {
- (void)close(master);
-#ifdef TIOCSCTTY /* XXXXX */
- ioctl(s, TIOCSCTTY, (char *)NULL);
-#endif
- } else {
- getsockname(s, (struct sockaddr *)&addr, &addrlen);
- close(s);
- /*
- * Connect to the socket
- * XXX If any of these fail, we're in trouble!
- */
- s = qemu_socket(AF_INET, SOCK_STREAM, 0);
- addr.sin_addr = loopback_addr;
- do {
- ret = connect(s, (struct sockaddr *)&addr, addrlen);
- } while (ret < 0 && errno == EINTR);
- }
+ getsockname(s, (struct sockaddr *)&addr, &addrlen);
+ close(s);
+ /*
+ * Connect to the socket
+ * XXX If any of these fail, we're in trouble!
+ */
+ s = qemu_socket(AF_INET, SOCK_STREAM, 0);
+ addr.sin_addr = loopback_addr;
+ do {
+ ret = connect(s, (struct sockaddr *)&addr, addrlen);
+ } while (ret < 0 && errno == EINTR);
dup2(s, 0);
dup2(s, 1);
@@ -205,28 +195,21 @@ int fork_exec(struct socket *so, const char *ex, int do_pty)
default:
qemu_add_child_watch(pid);
- if (do_pty == 2) {
- close(s);
- so->s = master;
- } else {
- /*
- * XXX this could block us...
- * XXX Should set a timer here, and if accept() doesn't
- * return after X seconds, declare it a failure
- * The only reason this will block forever is if socket()
- * of connect() fail in the child process
- */
- do {
- so->s = accept(s, (struct sockaddr *)&addr, &addrlen);
- } while (so->s < 0 && errno == EINTR);
- closesocket(s);
- opt = 1;
- setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt,
- sizeof(int));
- opt = 1;
- setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt,
- sizeof(int));
- }
+ /*
+ * XXX this could block us...
+ * XXX Should set a timer here, and if accept() doesn't
+ * return after X seconds, declare it a failure
+ * The only reason this will block forever is if socket()
+ * of connect() fail in the child process
+ */
+ do {
+ so->s = accept(s, (struct sockaddr *)&addr, &addrlen);
+ } while (so->s < 0 && errno == EINTR);
+ closesocket(s);
+ opt = 1;
+ setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
+ opt = 1;
+ setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
fd_nonblock(so->s);
/* Append the telnet options now */