[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 1/3] sockets: helper functions for qemu.
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] Re: [PATCH 1/3] sockets: helper functions for qemu. |
Date: |
Tue, 04 Nov 2008 13:42:25 +0100 |
User-agent: |
Thunderbird 2.0.0.16 (X11/20080723) |
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
>From 63d0d91d213ae3c84f1d3f82dd6879b43ec35bbc Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <address@hidden>
Date: Tue, 4 Nov 2008 13:35:07 +0100
Subject: [PATCH] sockets: fix bind return value check.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
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