qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Amos Kong <akong@redhat.com>
Cc: qemu-trivial@nongnu.org, aliguori@us.ibm.com,
	qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [Qemu-trivial] [RESEND PATCH 1/3] socket: remove redundant check
Date: Wed, 1 Aug 2012 11:50:11 +0100	[thread overview]
Message-ID: <20120801105011.GC17816@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <1343811543-12137-2-git-send-email-akong@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 <akong@redhat.com>
> ---
>  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

  reply	other threads:[~2012-08-01 10:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-17 15:45 [Qemu-devel] [PATCH 0/2] trivial fix of qemu-sockets.c Amos Kong
2012-07-17 15:45 ` [Qemu-devel] [PATCH 1/2] socket: remove redundant check Amos Kong
2012-07-17 15:45 ` [Qemu-devel] [PATCH 2/2] remove unused include of error.h Amos Kong
2012-08-01  8:59 ` [Qemu-devel] [RESEND PATCH 0/3] trivial fix of qemu-sockets.c Amos Kong
2012-08-01  8:59 ` [Qemu-devel] [RESEND PATCH 1/3] socket: remove redundant check Amos Kong
2012-08-01 10:50   ` Stefan Hajnoczi [this message]
2012-08-01 11:23     ` [Qemu-devel] [Qemu-trivial] " Peter Maydell
2012-08-01 11:50       ` Markus Armbruster
2012-08-01 11:48     ` Markus Armbruster
2012-08-03  2:59       ` Amos Kong
2012-08-01  8:59 ` [Qemu-devel] [RESEND PATCH 2/3] remove unused include of error.h Amos Kong
2012-08-01  8:59 ` [Qemu-devel] [RESEND PATCH 3/3] socket: clean up redundant assignment Amos Kong

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=20120801105011.GC17816@stefanha-thinkpad.localdomain \
    --to=stefanha@gmail.com \
    --cc=akong@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=quintela@redhat.com \
    /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).