From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 1/3] sockets: helper functions for qemu.
Date: Tue, 04 Nov 2008 13:42:25 +0100 [thread overview]
Message-ID: <49104331.1060203@redhat.com> (raw)
In-Reply-To: <1225730550-31941-2-git-send-email-kraxel@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 618 bytes --]
Hi,
> +
> + for (;;) {
> + if (bind(slisten, e->ai_addr, e->ai_addrlen) != 0) {
> + if (sockets_debug)
> + fprintf(stderr,"%s: bind(%s,%s,%d): OK\n", __FUNCTION__,
> + inet_strfamily(e->ai_family), uaddr, inet_getport(e));
> + goto listen;
> + }
Oops. Fixing up if() coding style with not enough care added a bug
here. Unlike in most other cases where we catch errors this way this
if() actually tests for bind() *success* to hop out of the "find free
port" loop. Incremental fix attached.
cheers,
Gerd
[-- Attachment #2: 0042-sockets-fix-bind-return-value-check.patch --]
[-- Type: text/plain, Size: 901 bytes --]
>From 63d0d91d213ae3c84f1d3f82dd6879b43ec35bbc Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Tue, 4 Nov 2008 13:35:07 +0100
Subject: [PATCH] sockets: fix bind return value check.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
qemu-sockets.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/qemu-sockets.c b/qemu-sockets.c
index a5499a6..77d9921 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -165,7 +165,7 @@ int inet_listen(const char *str, char *ostr, int olen,
#endif
for (;;) {
- if (bind(slisten, e->ai_addr, e->ai_addrlen) != 0) {
+ if (bind(slisten, e->ai_addr, e->ai_addrlen) == 0) {
if (sockets_debug)
fprintf(stderr,"%s: bind(%s,%s,%d): OK\n", __FUNCTION__,
inet_strfamily(e->ai_family), uaddr, inet_getport(e));
--
1.5.6.5
next prev parent reply other threads:[~2008-11-04 12:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-03 16:42 [Qemu-devel] [PATCH v3 0/3] ipv6 and autoport patches Gerd Hoffmann
2008-11-03 16:42 ` [Qemu-devel] [PATCH 1/3] sockets: helper functions for qemu Gerd Hoffmann
2008-11-04 12:42 ` Gerd Hoffmann [this message]
2008-11-11 20:41 ` Anthony Liguori
2008-11-11 21:14 ` Gerd Hoffmann
2008-11-11 20:47 ` Anthony Liguori
2008-11-03 16:42 ` [Qemu-devel] [PATCH 2/3] sockets: switch vnc to new code, support vnc port auto-allocation Gerd Hoffmann
2008-11-11 20:52 ` Anthony Liguori
2008-11-26 23:25 ` Ryan Harper
2008-11-27 9:11 ` Gerd Hoffmann
2008-11-03 16:42 ` [Qemu-devel] [PATCH 3/3] sockets: switch over tcp/telnet/unix serial line to new helper functions Gerd Hoffmann
2008-11-11 20:54 ` Anthony Liguori
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=49104331.1060203@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).