From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmO3R-00046T-HX for qemu-devel@nongnu.org; Sun, 15 Jan 2012 06:15:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RmO3Q-0006pa-38 for qemu-devel@nongnu.org; Sun, 15 Jan 2012 06:15:17 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:48929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmO3P-0006pS-O3 for qemu-devel@nongnu.org; Sun, 15 Jan 2012 06:15:16 -0500 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate03.web.de (Postfix) with ESMTP id D77D51AFC9239 for ; Sun, 15 Jan 2012 12:15:09 +0100 (CET) Message-ID: <4F12B53B.4020007@web.de> Date: Sun, 15 Jan 2012 12:15:07 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <1325769525-19274-1-git-send-email-sw@weilnetz.de> <4F109F46.4020309@weilnetz.de> In-Reply-To: <4F109F46.4020309@weilnetz.de> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig35997B2B29D5E926E7C8A5F3" Subject: Re: [Qemu-devel] [PATCH] slirp: Remove unused variable and unused code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: Blue Swirl , Anthony Liguori , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig35997B2B29D5E926E7C8A5F3 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable On 2012-01-13 22:16, Stefan Weil wrote: > Am 05.01.2012 14:18, schrieb Stefan Weil: >> 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 =3D=3D 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 >> Signed-off-by: Stefan Weil >> --- >> slirp/misc.c | 67 >> ++++++++++++++++++++++----------------------------------- >> 1 files changed, 26 insertions(+), 41 deletions(-) >> >> diff --git a/slirp/misc.c b/slirp/misc.c >> index 6c80e69..3432fbf 100644 >> --- a/slirp/misc.c >> +++ b/slirp/misc.c >> @@ -113,7 +113,6 @@ fork_exec(struct socket *so, const char *ex, int >> do_pty) >> struct sockaddr_in addr; >> socklen_t addrlen =3D sizeof(addr); >> int opt; >> - int master =3D -1; >> const char *argv[256]; >> /* don't want to clobber the original */ >> char *bptr; >> @@ -148,32 +147,23 @@ 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 =3D=3D 2) >> - close(master); >> return 0; >> >> case 0: >> setsid(); >> >> /* Set the DISPLAY */ >> - if (do_pty =3D=3D 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 =3D qemu_socket(AF_INET, SOCK_STREAM, 0); >> - addr.sin_addr =3D loopback_addr; >> - do { >> - ret =3D connect(s, (struct sockaddr >> *)&addr, addrlen); >> - } while (ret< 0&& errno =3D=3D EINTR); >> - } >> + getsockname(s, (struct sockaddr *)&addr,&addrlen); >> + close(s); >> + /* >> + * Connect to the socket >> + * XXX If any of these fail, we're in trouble! >> + */ >> + s =3D qemu_socket(AF_INET, SOCK_STREAM, 0); >> + addr.sin_addr =3D loopback_addr; >> + do { >> + ret =3D connect(s, (struct sockaddr *)&addr, addr= len); >> + } while (ret< 0&& errno =3D=3D EINTR); >> >> dup2(s, 0); >> dup2(s, 1); >> @@ -210,26 +200,21 @@ fork_exec(struct socket *so, const char *ex, int= >> do_pty) >> >> default: >> qemu_add_child_watch(pid); >> - if (do_pty =3D=3D 2) { >> - close(s); >> - so->s =3D 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 =3D accept(s, (struct sockaddr >> *)&addr,&addrlen); >> - } while (so->s< 0&& errno =3D=3D EINTR); >> - closesocket(s); >> - opt =3D 1; >> - setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char >> *)&opt,sizeof(int)); >> - opt =3D 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 =3D accept(s, (struct sockaddr >> *)&addr,&addrlen); >> + } while (so->s< 0&& errno =3D=3D EINTR); >> + closesocket(s); >> + opt =3D 1; >> + setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, (char >> *)&opt, sizeof(int)); >> + opt =3D 1; >> + setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, (char >> *)&opt, sizeof(int)); >> fd_nonblock(so->s); >> >> /* Append the telnet options now */ >> =20 >=20 >=20 > Ping. Please commit this patch. Thanks, picked up for my slirp queue. Jan --------------enig35997B2B29D5E926E7C8A5F3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8StTsACgkQitSsb3rl5xTjxACfZXtQlOjI7oA0uIHmIdA9ZBAT lwkAn3RphCB2+SstqowM8QjPSL9Luqjw =nfv0 -----END PGP SIGNATURE----- --------------enig35997B2B29D5E926E7C8A5F3--