qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Stefan Weil <sw@weilnetz.de>
Cc: Blue Swirl <blauwirbel@gmail.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] slirp: Remove unused variable and unused code
Date: Sun, 15 Jan 2012 12:15:07 +0100	[thread overview]
Message-ID: <4F12B53B.4020007@web.de> (raw)
In-Reply-To: <4F109F46.4020309@weilnetz.de>

[-- Attachment #1: Type: text/plain, Size: 5052 bytes --]

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 == 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>
>> ---
>>   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 = sizeof(addr);
>>       int opt;
>> -        int master = -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 == 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);
>> @@ -210,26 +200,21 @@ 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 */
>>    
> 
> 
> Ping. Please commit this patch.

Thanks, picked up for my slirp queue.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

      reply	other threads:[~2012-01-15 11:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-05 13:18 [Qemu-devel] [PATCH] slirp: Remove unused variable and unused code Stefan Weil
2012-01-13 21:16 ` Stefan Weil
2012-01-15 11:15   ` Jan Kiszka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F12B53B.4020007@web.de \
    --to=jan.kiszka@web.de \
    --cc=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).