From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwWVQ-00029I-72 for qemu-devel@nongnu.org; Wed, 01 Aug 2012 06:50:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwWVK-0002lT-AE for qemu-devel@nongnu.org; Wed, 01 Aug 2012 06:50:20 -0400 Date: Wed, 1 Aug 2012 11:50:11 +0100 From: Stefan Hajnoczi Message-ID: <20120801105011.GC17816@stefanha-thinkpad.localdomain> References: <1342539951-30915-1-git-send-email-akong@redhat.com> <1343811543-12137-2-git-send-email-akong@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1343811543-12137-2-git-send-email-akong@redhat.com> Subject: Re: [Qemu-devel] [Qemu-trivial] [RESEND PATCH 1/3] socket: remove redundant check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: qemu-trivial@nongnu.org, aliguori@us.ibm.com, qemu-devel@nongnu.org, quintela@redhat.com On Wed, Aug 01, 2012 at 04:59:01PM +0800, Amos Kong wrote: > It's aleady in the end of loop, error should be set. > > Signed-off-by: Amos Kong > --- > qemu-sockets.c | 4 +--- > 1 files changed, 1 insertions(+), 3 deletions(-) > > diff --git a/qemu-sockets.c b/qemu-sockets.c > index 668fa93..c636882 100644 > --- a/qemu-sockets.c > +++ b/qemu-sockets.c > @@ -181,9 +181,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp) > fprintf(stderr,"%s: bind(%s,%s,%d): %s\n", __FUNCTION__, > inet_strfamily(e->ai_family), uaddr, inet_getport(e), > strerror(errno)); > - if (!e->ai_next) { > - error_set(errp, QERR_SOCKET_BIND_FAILED); > - } > + error_set(errp, QERR_SOCKET_BIND_FAILED); > } > } > closesocket(slisten); This isn't obvious. It looks like the intent of the if (!e->ai_next) is to suppress the error so that the next iteration of the *outer* loop can succeed. Why is it okay to set QERR_SOCKET_BIND_FAILED? We may have more addrinfos left to try in the outer loop. They may succeed so we don't want an error in that case. Stefan