uv: upgrade to v0.11.13
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 4 Sep 2013 12:46:35 +0000 (14:46 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Wed, 4 Sep 2013 16:11:32 +0000 (18:11 +0200)
This commit changes src/tcp_wrap.cc and src/udp_wrap.cc just enough to
get by (i.e. to compile and function correctly.)

The new libuv API allows for more cleanup and deduplication but I'm
saving that for another day.

51 files changed:
deps/uv/AUTHORS
deps/uv/ChangeLog
deps/uv/Makefile.am
deps/uv/configure.ac
deps/uv/include/uv.h
deps/uv/src/uv-common.c
deps/uv/src/version.c
deps/uv/src/win/fs.c
deps/uv/test/benchmark-multi-accept.c
deps/uv/test/benchmark-ping-pongs.c
deps/uv/test/benchmark-pound.c
deps/uv/test/benchmark-pump.c
deps/uv/test/benchmark-tcp-write-batch.c
deps/uv/test/benchmark-udp-pummel.c
deps/uv/test/blackhole-server.c
deps/uv/test/dns-server.c
deps/uv/test/echo-server.c
deps/uv/test/test-callback-stack.c
deps/uv/test/test-connection-fail.c
deps/uv/test/test-delayed-accept.c
deps/uv/test/test-getsockname.c
deps/uv/test/test-ipc-send-recv.c
deps/uv/test/test-ipc.c
deps/uv/test/test-multiple-listen.c
deps/uv/test/test-ping-pong.c
deps/uv/test/test-ref.c
deps/uv/test/test-shutdown-close.c
deps/uv/test/test-shutdown-eof.c
deps/uv/test/test-tcp-bind-error.c
deps/uv/test/test-tcp-bind6-error.c
deps/uv/test/test-tcp-close-while-connecting.c
deps/uv/test/test-tcp-close.c
deps/uv/test/test-tcp-connect-error-after-write.c
deps/uv/test/test-tcp-connect-error.c
deps/uv/test/test-tcp-connect-timeout.c
deps/uv/test/test-tcp-connect6-error.c
deps/uv/test/test-tcp-open.c
deps/uv/test/test-tcp-read-stop.c
deps/uv/test/test-tcp-shutdown-after-write.c
deps/uv/test/test-tcp-unexpected-read.c
deps/uv/test/test-tcp-write-to-half-open-connection.c
deps/uv/test/test-tcp-writealot.c
deps/uv/test/test-udp-dgram-too-big.c
deps/uv/test/test-udp-ipv6.c
deps/uv/test/test-udp-multicast-join.c
deps/uv/test/test-udp-multicast-ttl.c
deps/uv/test/test-udp-open.c
deps/uv/test/test-udp-options.c
deps/uv/test/test-udp-send-and-recv.c
src/tcp_wrap.cc
src/udp_wrap.cc

index f002a88..1d99256 100644 (file)
@@ -91,3 +91,4 @@ Linus MÃ¥rtensson <linus.martensson@sonymobile.com>
 Andrei Sedoi <bsnote@gmail.com>
 Navaneeth Kedaram Nambiathan <navaneethkn@gmail.com>
 Alex Crichton <alex@alexcrichton.com>
+Brent Cook <brent@boundary.com>
index 93af51f..15105f4 100644 (file)
@@ -1,4 +1,23 @@
-2013.09.03, Version 0.11.12 (Unstable)
+2013.09.05, Version 0.11.13 (Unstable)
+
+Changes since version 0.11.12:
+
+* unix: define _GNU_SOURCE, exposes glibc-isms (Ben Noordhuis)
+
+* windows: check for nonconforming swprintf arguments (Brent Cook)
+
+* build: include internal headers in source list (Brent Cook)
+
+* include: merge uv_tcp_bind and uv_tcp_bind6 (Ben Noordhuis)
+
+* include: merge uv_tcp_connect and uv_tcp_connect6 (Ben Noordhuis)
+
+* include: merge uv_udp_bind and uv_udp_bind6 (Ben Noordhuis)
+
+* include: merge uv_udp_send and uv_udp_send6 (Ben Noordhuis)
+
+
+2013.09.03, Version 0.11.12 (Unstable), 82d01d5f6780d178f5176a01425ec297583c0811
 
 Changes since version 0.11.11:
 
index bde152e..bd54e45 100644 (file)
@@ -26,6 +26,7 @@ libuv_la_CFLAGS = @CFLAGS@
 libuv_la_LDFLAGS = -no-undefined -version-info 11:0:0
 libuv_la_SOURCES = src/fs-poll.c \
                    src/inet.c \
+                   src/queue.h \
                    src/uv-common.c \
                    src/uv-common.h \
                    src/version.c
@@ -38,6 +39,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/src/win \
                -D_WIN32_WINNT=0x0600
 LIBS += -lws2_32 -lpsapi -lphlpapi2
 libuv_la_SOURCES += src/win/async.c \
+                    src/win/atomicops-inl.h \
                     src/win/core.c \
                     src/win/dl.c \
                     src/win/error.c \
@@ -45,14 +47,18 @@ libuv_la_SOURCES += src/win/async.c \
                     src/win/fs.c \
                     src/win/getaddrinfo.c \
                     src/win/handle.c \
+                    src/win/handle-inl.h \
+                    src/win/internal.h \
                     src/win/loop-watcher.c \
                     src/win/pipe.c \
                     src/win/poll.c \
                     src/win/process-stdio.c \
                     src/win/process.c \
                     src/win/req.c \
+                    src/win/req-inl.h \
                     src/win/signal.c \
                     src/win/stream.c \
+                    src/win/stream-inl.h \
                     src/win/tcp.c \
                     src/win/thread.c \
                     src/win/threadpool.c \
@@ -61,7 +67,9 @@ libuv_la_SOURCES += src/win/async.c \
                     src/win/udp.c \
                     src/win/util.c \
                     src/win/winapi.c \
-                    src/win/winsock.c
+                    src/win/winapi.h \
+                    src/win/winsock.c \
+                    src/win/winsock.h
 
 else  # WINNT
 
index aede49b..0c97737 100644 (file)
@@ -13,7 +13,7 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 AC_PREREQ(2.57)
-AC_INIT([libuv], [0.11.5], [https://github.com/joyent/libuv/issues])
+AC_INIT([libuv], [0.11.13], [https://github.com/joyent/libuv/issues])
 AC_CONFIG_MACRO_DIR([m4])
 m4_include([m4/libuv-extra-automake-flags.m4])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects] UV_EXTRA_AUTOMAKE_FLAGS)
index fcef08b..134759f 100644 (file)
@@ -766,8 +766,11 @@ UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle,
  */
 UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable);
 
-UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr_in* addr);
-UV_EXTERN int uv_tcp_bind6(uv_tcp_t* handle, const struct sockaddr_in6* addr);
+/*
+ * Bind the handle to an address and port.  `addr` should point to an
+ * initialized struct sockaddr_in or struct sockaddr_in6.
+ */
+UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr* addr);
 
 UV_EXTERN int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name,
     int* namelen);
@@ -775,21 +778,18 @@ UV_EXTERN int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name,
     int* namelen);
 
 /*
- * uv_tcp_connect, uv_tcp_connect6
- * These functions establish IPv4 and IPv6 TCP connections. Provide an
- * initialized TCP handle and an uninitialized uv_connect_t*. The callback
- * will be made when the connection is established.
+ * Establish an IPv4 or IPv6 TCP connection.  Provide an initialized TCP handle
+ * and an uninitialized uv_connect_t*.  `addr` should point to an initialized
+ * struct sockaddr_in or struct sockaddr_in6.
+ *
+ * The callback is made when the connection has been established or when a
+ * connection error happened.
  */
 UV_EXTERN int uv_tcp_connect(uv_connect_t* req,
                              uv_tcp_t* handle,
-                             const struct sockaddr_in* addr,
+                             const struct sockaddr* addr,
                              uv_connect_cb cb);
 
-UV_EXTERN int uv_tcp_connect6(uv_connect_t* req,
-                              uv_tcp_t* handle,
-                              const struct sockaddr_in6* addr,
-                              uv_connect_cb cb);
-
 /* uv_connect_t is a subclass of uv_req_t */
 struct uv_connect_s {
   UV_REQ_FIELDS
@@ -804,7 +804,7 @@ struct uv_connect_s {
  */
 
 enum uv_udp_flags {
-  /* Disables dual stack mode. Used with uv_udp_bind6(). */
+  /* Disables dual stack mode. */
   UV_UDP_IPV6ONLY = 1,
   /*
    * Indicates message was truncated because read buffer was too small. The
@@ -883,7 +883,8 @@ UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock);
  *
  * Arguments:
  *  handle    UDP handle. Should have been initialized with `uv_udp_init`.
- *  addr      struct sockaddr_in with the address and port to bind to.
+ *  addr      struct sockaddr_in or struct sockaddr_in6 with the address and
+ *            port to bind to.
  *  flags     Unused.
  *
  * Returns:
@@ -898,23 +899,8 @@ UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock);
  * opt-in mechanism in future versions of libuv.
  */
 UV_EXTERN int uv_udp_bind(uv_udp_t* handle,
-                          const struct sockaddr_in* addr,
-                          unsigned flags);
-
-/*
- * Bind to a IPv6 address and port.
- *
- * Arguments:
- *  handle    UDP handle. Should have been initialized with `uv_udp_init`.
- *  addr      struct sockaddr_in with the address and port to bind to.
- *  flags     Should be 0 or UV_UDP_IPV6ONLY.
- *
- * Returns:
- *  0 on success, or an error code < 0 on failure.
- */
-UV_EXTERN int uv_udp_bind6(uv_udp_t* handle,
-                           const struct sockaddr_in6* addr,
-                           unsigned flags);
+                          const struct sockaddr* addr,
+                          unsigned int flags);
 
 UV_EXTERN int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name,
     int* namelen);
@@ -1009,32 +995,10 @@ UV_EXTERN int uv_udp_send(uv_udp_send_t* req,
                           uv_udp_t* handle,
                           const uv_buf_t bufs[],
                           unsigned int nbufs,
-                          const struct sockaddr_in* addr,
+                          const struct sockaddr* addr,
                           uv_udp_send_cb send_cb);
 
 /*
- * Send data. If the socket has not previously been bound with `uv_udp_bind6`,
- * it is bound to ::0 (the "all interfaces" address) and a random port number.
- *
- * Arguments:
- *  req       UDP request handle. Need not be initialized.
- *  handle    UDP handle. Should have been initialized with `uv_udp_init`.
- *  bufs      List of buffers to send.
- *  nbufs     Number of buffers in `bufs`.
- *  addr      Address of the remote peer. See `uv_ip6_addr`.
- *  send_cb   Callback to invoke when the data has been sent out.
- *
- * Returns:
- *  0 on success, or an error code < 0 on failure.
- */
-UV_EXTERN int uv_udp_send6(uv_udp_send_t* req,
-                           uv_udp_t* handle,
-                           const uv_buf_t bufs[],
-                           unsigned int nbufs,
-                           const struct sockaddr_in6* addr,
-                           uv_udp_send_cb send_cb);
-
-/*
  * Receive data. If the socket has not previously been bound with `uv_udp_bind`
  * or `uv_udp_bind6`, it is bound to 0.0.0.0 (the "all interfaces" address)
  * and a random port number.
index bc96029..6cfd108 100644 (file)
  * IN THE SOFTWARE.
  */
 
+/* Expose glibc-specific EAI_* error codes. Needs to be defined before we
+ * include any headers.
+ */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
 #include "uv.h"
 #include "uv-common.h"
 
@@ -184,75 +191,59 @@ int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size) {
 }
 
 
-int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr_in* addr) {
-  if (handle->type == UV_TCP && addr->sin_family == AF_INET)
-    return uv__tcp_bind(handle, (const struct sockaddr*) addr, sizeof(*addr));
-  else
-    return UV_EINVAL;
-}
+int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr* addr) {
+  unsigned int addrlen;
 
+  if (handle->type != UV_TCP)
+    return UV_EINVAL;
 
-int uv_tcp_bind6(uv_tcp_t* handle, const struct sockaddr_in6* addr) {
-  if (handle->type == UV_TCP && addr->sin6_family == AF_INET6)
-    return uv__tcp_bind(handle, (const struct sockaddr*) addr, sizeof(*addr));
+  if (addr->sa_family == AF_INET)
+    addrlen = sizeof(struct sockaddr_in);
+  else if (addr->sa_family == AF_INET6)
+    addrlen = sizeof(struct sockaddr_in6);
   else
     return UV_EINVAL;
+
+  return uv__tcp_bind(handle, addr, addrlen);
 }
 
 
 int uv_udp_bind(uv_udp_t* handle,
-                const struct sockaddr_in* addr,
+                const struct sockaddr* addr,
                 unsigned int flags) {
-  if (handle->type == UV_UDP && addr->sin_family == AF_INET) {
-    return uv__udp_bind(handle,
-                        (const struct sockaddr*) addr,
-                        sizeof(*addr),
-                        flags);
-  }
-  return UV_EINVAL;
-}
+  unsigned int addrlen;
+
+  if (handle->type != UV_UDP)
+    return UV_EINVAL;
 
+  if (addr->sa_family == AF_INET)
+    addrlen = sizeof(struct sockaddr_in);
+  else if (addr->sa_family == AF_INET6)
+    addrlen = sizeof(struct sockaddr_in6);
+  else
+    return UV_EINVAL;
 
-int uv_udp_bind6(uv_udp_t* handle,
-                 const struct sockaddr_in6* addr,
-                 unsigned int flags) {
-  if (handle->type == UV_UDP && addr->sin6_family == AF_INET6) {
-    return uv__udp_bind(handle,
-                        (const struct sockaddr*) addr,
-                        sizeof(*addr),
-                        flags);
-  }
-  return UV_EINVAL;
+  return uv__udp_bind(handle, addr, addrlen, flags);
 }
 
 
 int uv_tcp_connect(uv_connect_t* req,
                    uv_tcp_t* handle,
-                   const struct sockaddr_in* addr,
+                   const struct sockaddr* addr,
                    uv_connect_cb cb) {
-  if (handle->type == UV_TCP && addr->sin_family == AF_INET) {
-    return uv__tcp_connect(req,
-                           handle,
-                           (const struct sockaddr*) addr,
-                           sizeof(*addr),
-                           cb);
-  }
-  return UV_EINVAL;
-}
+  unsigned int addrlen;
 
+  if (handle->type != UV_TCP)
+    return UV_EINVAL;
 
-int uv_tcp_connect6(uv_connect_t* req,
-                    uv_tcp_t* handle,
-                    const struct sockaddr_in6* addr,
-                    uv_connect_cb cb) {
-  if (handle->type == UV_TCP && addr->sin6_family == AF_INET6) {
-    return uv__tcp_connect(req,
-                           handle,
-                           (const struct sockaddr*) addr,
-                           sizeof(*addr),
-                           cb);
-  }
-  return UV_EINVAL;
+  if (addr->sa_family == AF_INET)
+    addrlen = sizeof(struct sockaddr_in);
+  else if (addr->sa_family == AF_INET6)
+    addrlen = sizeof(struct sockaddr_in6);
+  else
+    return UV_EINVAL;
+
+  return uv__tcp_connect(req, handle, addr, addrlen, cb);
 }
 
 
@@ -260,37 +251,21 @@ int uv_udp_send(uv_udp_send_t* req,
                 uv_udp_t* handle,
                 const uv_buf_t bufs[],
                 unsigned int nbufs,
-                const struct sockaddr_in* addr,
+                const struct sockaddr* addr,
                 uv_udp_send_cb send_cb) {
-  if (handle->type == UV_UDP && addr->sin_family == AF_INET) {
-    return uv__udp_send(req,
-                        handle,
-                        bufs,
-                        nbufs,
-                        (const struct sockaddr*) addr,
-                        sizeof(*addr),
-                        send_cb);
-  }
-  return UV_EINVAL;
-}
+  unsigned int addrlen;
 
+  if (handle->type != UV_UDP)
+    return UV_EINVAL;
 
-int uv_udp_send6(uv_udp_send_t* req,
-                 uv_udp_t* handle,
-                 const uv_buf_t bufs[],
-                 unsigned int nbufs,
-                 const struct sockaddr_in6* addr,
-                 uv_udp_send_cb send_cb) {
-  if (handle->type == UV_UDP && addr->sin6_family == AF_INET6) {
-    return uv__udp_send(req,
-                        handle,
-                        bufs,
-                        nbufs,
-                        (const struct sockaddr*) addr,
-                        sizeof(*addr),
-                        send_cb);
-  }
-  return UV_EINVAL;
+  if (addr->sa_family == AF_INET)
+    addrlen = sizeof(struct sockaddr_in);
+  else if (addr->sa_family == AF_INET6)
+    addrlen = sizeof(struct sockaddr_in6);
+  else
+    return UV_EINVAL;
+
+  return uv__udp_send(req, handle, bufs, nbufs, addr, addrlen, send_cb);
 }
 
 
index 9c9575b..e7f56fc 100644 (file)
@@ -31,7 +31,7 @@
 
 #define UV_VERSION_MAJOR 0
 #define UV_VERSION_MINOR 11
-#define UV_VERSION_PATCH 12
+#define UV_VERSION_PATCH 13
 #define UV_VERSION_IS_RELEASE 1
 
 
index 879f1f1..0475f43 100644 (file)
@@ -715,10 +715,10 @@ void fs__readdir(uv_fs_t* req) {
     uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
   }
 
-#ifdef _MSC_VER
-  swprintf(path2, len + 3, fmt, pathw);
-#else
+#ifdef _CRT_NON_CONFORMING_SWPRINTFS
   swprintf(path2, fmt, pathw);
+#else
+  swprintf(path2, len + 3, fmt, pathw);
 #endif
   dir = FindFirstFileW(path2, &ent);
   free(path2);
index 81614bc..dbcba00 100644 (file)
@@ -209,7 +209,8 @@ static void send_listen_handles(uv_handle_type type,
 
   if (type == UV_TCP) {
     ASSERT(0 == uv_tcp_init(loop, (uv_tcp_t*) &ctx.server_handle));
-    ASSERT(0 == uv_tcp_bind((uv_tcp_t*) &ctx.server_handle, &listen_addr));
+    ASSERT(0 == uv_tcp_bind((uv_tcp_t*) &ctx.server_handle,
+                            (const struct sockaddr*) &listen_addr));
   }
   else
     ASSERT(0);
@@ -346,7 +347,7 @@ static void cl_close_cb(uv_handle_t* handle) {
   ASSERT(0 == uv_tcp_init(handle->loop, (uv_tcp_t*) &ctx->client_handle));
   ASSERT(0 == uv_tcp_connect(&ctx->connect_req,
                              (uv_tcp_t*) &ctx->client_handle,
-                             &listen_addr,
+                             (const struct sockaddr*) &listen_addr,
                              cl_connect_cb));
 }
 
@@ -387,7 +388,7 @@ static int test_tcp(unsigned int num_servers, unsigned int num_clients) {
     ASSERT(0 == uv_tcp_init(loop, handle));
     ASSERT(0 == uv_tcp_connect(&ctx->connect_req,
                                handle,
-                               &listen_addr,
+                               (const struct sockaddr*) &listen_addr,
                                cl_connect_cb));
     ASSERT(0 == uv_idle_init(loop, &ctx->idle_handle));
   }
index c5c11fe..a6306e3 100644 (file)
@@ -191,11 +191,11 @@ static void pinger_new(void) {
 
   pinger->tcp.data = pinger;
 
-  uv_tcp_bind(&pinger->tcp, &client_addr);
+  ASSERT(0 == uv_tcp_bind(&pinger->tcp, (const struct sockaddr*) &client_addr));
 
   r = uv_tcp_connect(&pinger->connect_req,
                      &pinger->tcp,
-                     &server_addr,
+                     (const struct sockaddr*) &server_addr,
                      pinger_connect_cb);
   ASSERT(!r);
 }
index 7531f55..e8d8705 100644 (file)
@@ -204,7 +204,10 @@ static void tcp_make_connect(conn_rec* p) {
 
   ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
 
-  r = uv_tcp_connect(&tp->conn_req, (uv_tcp_t*) &p->stream, &addr, connect_cb);
+  r = uv_tcp_connect(&tp->conn_req,
+                     (uv_tcp_t*) &p->stream,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   if (r) {
     fprintf(stderr, "uv_tcp_connect error %s\n", uv_err_name(r));
     ASSERT(0);
index ac132cb..eda3c14 100644 (file)
@@ -240,7 +240,10 @@ static void maybe_connect_some(void) {
       ASSERT(r == 0);
 
       req = (uv_connect_t*) req_alloc();
-      r = uv_tcp_connect(req, tcp, &connect_addr, connect_cb);
+      r = uv_tcp_connect(req,
+                         tcp,
+                         (const struct sockaddr*) &connect_addr,
+                         connect_cb);
       ASSERT(r == 0);
     } else {
       pipe = &pipe_write_handles[max_connect_socket++];
@@ -366,7 +369,7 @@ HELPER_IMPL(tcp_pump_server) {
   server = (uv_stream_t*)&tcpServer;
   r = uv_tcp_init(loop, &tcpServer);
   ASSERT(r == 0);
-  r = uv_tcp_bind(&tcpServer, &listen_addr);
+  r = uv_tcp_bind(&tcpServer, (const struct sockaddr*) &listen_addr);
   ASSERT(r == 0);
   r = uv_listen((uv_stream_t*)&tcpServer, MAX_WRITE_HANDLES, connection_cb);
   ASSERT(r == 0);
index 09b93c2..96921b7 100644 (file)
@@ -117,7 +117,10 @@ BENCHMARK_IMPL(tcp_write_batch) {
   r = uv_tcp_init(loop, &tcp_client);
   ASSERT(r == 0);
 
-  r = uv_tcp_connect(&connect_req, &tcp_client, &addr, connect_cb);
+  r = uv_tcp_connect(&connect_req,
+                     &tcp_client,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
 
   start = uv_hrtime();
index 3dec263..f8f702c 100644 (file)
@@ -100,7 +100,7 @@ send:
                           &s->udp_handle,
                           bufs,
                           ARRAY_SIZE(bufs),
-                          &s->addr,
+                          (const struct sockaddr*) &s->addr,
                           send_cb));
   send_cb_called++;
 }
@@ -174,7 +174,7 @@ static int pummel(unsigned int n_senders,
     struct sockaddr_in addr;
     ASSERT(0 == uv_ip4_addr("0.0.0.0", BASE_PORT + i, &addr));
     ASSERT(0 == uv_udp_init(loop, &s->udp_handle));
-    ASSERT(0 == uv_udp_bind(&s->udp_handle, &addr, 0));
+    ASSERT(0 == uv_udp_bind(&s->udp_handle, (const struct sockaddr*) &addr, 0));
     ASSERT(0 == uv_udp_recv_start(&s->udp_handle, alloc_cb, recv_cb));
     uv_unref((uv_handle_t*)&s->udp_handle);
   }
@@ -195,7 +195,7 @@ static int pummel(unsigned int n_senders,
                             &s->udp_handle,
                             bufs,
                             ARRAY_SIZE(bufs),
-                            &s->addr,
+                            (const struct sockaddr*) &s->addr,
                             send_cb));
   }
 
index 75f8456..cec35bd 100644 (file)
@@ -108,7 +108,7 @@ HELPER_IMPL(tcp4_blackhole_server) {
   r = uv_tcp_init(loop, &tcp_server);
   ASSERT(r == 0);
 
-  r = uv_tcp_bind(&tcp_server, &addr);
+  r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_listen((uv_stream_t*)&tcp_server, 128, connection_cb);
index aabded5..8ffe4e7 100644 (file)
@@ -305,7 +305,7 @@ static int dns_start(int port) {
     return 1;
   }
 
-  r = uv_tcp_bind(&server, &addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr);
   if (r) {
     /* TODO: Error codes */
     fprintf(stderr, "Bind error\n");
index 6974201..193a168 100644 (file)
@@ -195,7 +195,6 @@ static void on_recv(uv_udp_t* handle,
                     unsigned flags) {
   uv_udp_send_t* req;
   uv_buf_t sndbuf;
-  int r;
 
   ASSERT(nread > 0);
   ASSERT(addr->sa_family == AF_INET);
@@ -204,13 +203,7 @@ static void on_recv(uv_udp_t* handle,
   ASSERT(req != NULL);
 
   sndbuf = *rcvbuf;
-  r = uv_udp_send(req,
-                  handle,
-                  &sndbuf,
-                  1,
-                  (const struct sockaddr_in*) addr,
-                  on_send);
-  ASSERT(r == 0);
+  ASSERT(0 == uv_udp_send(req, handle, &sndbuf, 1, addr, on_send));
 }
 
 
@@ -236,7 +229,7 @@ static int tcp4_echo_start(int port) {
     return 1;
   }
 
-  r = uv_tcp_bind(&tcpServer, &addr);
+  r = uv_tcp_bind(&tcpServer, (const struct sockaddr*) &addr);
   if (r) {
     /* TODO: Error codes */
     fprintf(stderr, "Bind error\n");
@@ -271,7 +264,7 @@ static int tcp6_echo_start(int port) {
   }
 
   /* IPv6 is optional as not all platforms support it */
-  r = uv_tcp_bind6(&tcpServer, &addr6);
+  r = uv_tcp_bind(&tcpServer, (const struct sockaddr*) &addr6);
   if (r) {
     /* show message but return OK */
     fprintf(stderr, "IPv6 not supported\n");
index ff6e93c..accd549 100644 (file)
@@ -183,7 +183,10 @@ TEST_IMPL(callback_stack) {
 
   nested++;
 
-  if (uv_tcp_connect(&connect_req, &client, &addr, connect_cb)) {
+  if (uv_tcp_connect(&connect_req,
+                     &client,
+                     (const struct sockaddr*) &addr,
+                     connect_cb)) {
     FATAL("uv_tcp_connect failed");
   }
   nested--;
index 8009930..9b98c4d 100644 (file)
@@ -101,8 +101,12 @@ static void connection_fail(uv_connect_cb connect_cb) {
 
   /* We are never doing multiple reads/connects at a time anyway. */
   /* so these handles can be pre-initialized. */
-  uv_tcp_bind(&tcp, &client_addr);
-  r = uv_tcp_connect(&req, &tcp, &server_addr, connect_cb);
+  ASSERT(0 == uv_tcp_bind(&tcp, (const struct sockaddr*) &client_addr));
+
+  r = uv_tcp_connect(&req,
+                     &tcp,
+                     (const struct sockaddr*) &server_addr,
+                     connect_cb);
   ASSERT(!r);
 
   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
index a7d3188..f210d5f 100644 (file)
@@ -108,7 +108,7 @@ static void start_server(void) {
 
   r = uv_tcp_init(uv_default_loop(), server);
   ASSERT(r == 0);
-  r = uv_tcp_bind(server, &addr);
+  r = uv_tcp_bind(server, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_listen((uv_stream_t*)server, 128, connection_cb);
@@ -163,7 +163,10 @@ static void client_connect(void) {
   r = uv_tcp_init(uv_default_loop(), client);
   ASSERT(r == 0);
 
-  r = uv_tcp_connect(connect_req, client, &addr, connect_cb);
+  r = uv_tcp_connect(connect_req,
+                     client,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
 }
 
index 87bb616..dc6a949 100644 (file)
@@ -180,7 +180,7 @@ static int tcp_listener(void) {
     return 1;
   }
 
-  r = uv_tcp_bind(&tcpServer, &addr);
+  r = uv_tcp_bind(&tcpServer, (const struct sockaddr*) &addr);
   if (r) {
     fprintf(stderr, "Bind error\n");
     return 1;
@@ -219,7 +219,10 @@ static void tcp_connector(void) {
   tcp.data = &connect_req;
   ASSERT(!r);
 
-  r = uv_tcp_connect(&connect_req, &tcp, &server_addr, on_connect);
+  r = uv_tcp_connect(&connect_req,
+                     &tcp,
+                     (const struct sockaddr*) &server_addr,
+                     on_connect);
   ASSERT(!r);
 
   /* Fetch the actual port used by the connecting socket. */
@@ -279,7 +282,7 @@ static int udp_listener(void) {
     return 1;
   }
 
-  r = uv_udp_bind(&udpServer, &addr, 0);
+  r = uv_udp_bind(&udpServer, (const struct sockaddr*) &addr, 0);
   if (r) {
     fprintf(stderr, "Bind error\n");
     return 1;
@@ -310,7 +313,12 @@ static void udp_sender(void) {
   buf = uv_buf_init("PING", 4);
   ASSERT(0 == uv_ip4_addr("127.0.0.1", server_port, &server_addr));
 
-  r = uv_udp_send(&send_req, &udp, &buf, 1, &server_addr, udp_send);
+  r = uv_udp_send(&send_req,
+                  &udp,
+                  &buf,
+                  1,
+                  (const struct sockaddr*) &server_addr,
+                  udp_send);
   ASSERT(!r);
 }
 
index 5119b31..cbd6a95 100644 (file)
@@ -145,7 +145,7 @@ TEST_IMPL(ipc_send_recv_tcp) {
   r = uv_tcp_init(uv_default_loop(), &ctx.send.tcp);
   ASSERT(r == 0);
 
-  r = uv_tcp_bind(&ctx.send.tcp, &addr);
+  r = uv_tcp_bind(&ctx.send.tcp, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = run_test();
index 7085ea3..d19affa 100644 (file)
@@ -129,7 +129,7 @@ static void make_many_connections(void) {
 
     r = uv_tcp_connect(&conn->conn_req,
                        (uv_tcp_t*) &conn->conn,
-                       &addr,
+                       (const struct sockaddr*) &addr,
                        connect_cb);
     ASSERT(r == 0);
 
@@ -375,7 +375,7 @@ TEST_IMPL(listen_with_simultaneous_accepts) {
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
 
-  r = uv_tcp_bind(&server, &addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_tcp_simultaneous_accepts(&server, 1);
@@ -400,7 +400,7 @@ TEST_IMPL(listen_no_simultaneous_accepts) {
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
 
-  r = uv_tcp_bind(&server, &addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_tcp_simultaneous_accepts(&server, 0);
@@ -566,7 +566,7 @@ int ipc_helper(int listen_after_write) {
   r = uv_tcp_init(uv_default_loop(), &tcp_server);
   ASSERT(r == 0);
 
-  r = uv_tcp_bind(&tcp_server, &addr);
+  r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   if (!listen_after_write) {
@@ -618,7 +618,7 @@ int ipc_helper_tcp_connection(void) {
 
   ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr));
 
-  r = uv_tcp_bind(&tcp_server, &addr);
+  r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_listen((uv_stream_t*)&tcp_server, 12, ipc_on_connection_tcp_conn);
@@ -632,7 +632,7 @@ int ipc_helper_tcp_connection(void) {
 
   r = uv_tcp_connect(&conn.conn_req,
                      (uv_tcp_t*) &conn.conn,
-                     &addr,
+                     (const struct sockaddr*) &addr,
                      connect_child_process_cb);
   ASSERT(r == 0);
 
index c19ec71..3ce6233 100644 (file)
@@ -53,7 +53,7 @@ static void start_server(void) {
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
 
-  r = uv_tcp_bind(&server, &addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_listen((uv_stream_t*)&server, 128, connection_cb);
@@ -84,7 +84,10 @@ static void client_connect(void) {
   r = uv_tcp_init(uv_default_loop(), &client);
   ASSERT(r == 0);
 
-  r = uv_tcp_connect(connect_req, &client, &addr, connect_cb);
+  r = uv_tcp_connect(connect_req,
+                     &client,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
 }
 
index 0c880d7..fb8f566 100644 (file)
@@ -163,10 +163,10 @@ static void tcp_pinger_v6_new(void) {
 
   /* We are never doing multiple reads/connects at a time anyway. */
   /* so these handles can be pre-initialized. */
-  r = uv_tcp_connect6(&pinger->connect_req,
-                      &pinger->stream.tcp,
-                      &server_addr,
-                      pinger_on_connect);
+  r = uv_tcp_connect(&pinger->connect_req,
+                     &pinger->stream.tcp,
+                     (const struct sockaddr*) &server_addr,
+                     pinger_on_connect);
   ASSERT(!r);
 
   /* Synchronous connect callbacks are not allowed. */
@@ -193,7 +193,7 @@ static void tcp_pinger_new(void) {
   /* so these handles can be pre-initialized. */
   r = uv_tcp_connect(&pinger->connect_req,
                      &pinger->stream.tcp,
-                     &server_addr,
+                     (const struct sockaddr*) &server_addr,
                      pinger_on_connect);
   ASSERT(!r);
 
index 7bb4277..ca44ec4 100644 (file)
@@ -258,7 +258,10 @@ TEST_IMPL(tcp_ref3) {
   uv_tcp_t h;
   ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
   uv_tcp_init(uv_default_loop(), &h);
-  uv_tcp_connect(&connect_req, &h, &addr, connect_and_shutdown);
+  uv_tcp_connect(&connect_req,
+                 &h,
+                 (const struct sockaddr*) &addr,
+                 connect_and_shutdown);
   uv_unref((uv_handle_t*)&h);
   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
   ASSERT(connect_cb_called == 1);
@@ -274,7 +277,10 @@ TEST_IMPL(tcp_ref4) {
   uv_tcp_t h;
   ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
   uv_tcp_init(uv_default_loop(), &h);
-  uv_tcp_connect(&connect_req, &h, &addr, connect_and_write);
+  uv_tcp_connect(&connect_req,
+                 &h,
+                 (const struct sockaddr*) &addr,
+                 connect_and_write);
   uv_unref((uv_handle_t*)&h);
   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
   ASSERT(connect_cb_called == 1);
@@ -302,7 +308,7 @@ TEST_IMPL(udp_ref2) {
   uv_udp_t h;
   ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
   uv_udp_init(uv_default_loop(), &h);
-  uv_udp_bind(&h, &addr, 0);
+  uv_udp_bind(&h, (const struct sockaddr*) &addr, 0);
   uv_udp_recv_start(&h, (uv_alloc_cb)fail_cb, (uv_udp_recv_cb)fail_cb);
   uv_unref((uv_handle_t*)&h);
   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
@@ -320,7 +326,12 @@ TEST_IMPL(udp_ref3) {
 
   ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
   uv_udp_init(uv_default_loop(), &h);
-  uv_udp_send(&req, &h, &buf, 1, &addr, (uv_udp_send_cb)req_cb);
+  uv_udp_send(&req,
+              &h,
+              &buf,
+              1,
+              (const struct sockaddr*) &addr,
+              (uv_udp_send_cb) req_cb);
   uv_unref((uv_handle_t*)&h);
   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
   ASSERT(req_cb_called == 1);
index ca30857..fd2d4b8 100644 (file)
@@ -72,7 +72,10 @@ TEST_IMPL(shutdown_close_tcp) {
   ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
   r = uv_tcp_init(uv_default_loop(), &h);
   ASSERT(r == 0);
-  r = uv_tcp_connect(&connect_req, &h, &addr, connect_cb);
+  r = uv_tcp_connect(&connect_req,
+                     &h,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
   r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
   ASSERT(r == 0);
index 92e7312..5834636 100644 (file)
@@ -160,7 +160,10 @@ TEST_IMPL(shutdown_eof) {
   r = uv_tcp_init(uv_default_loop(), &tcp);
   ASSERT(!r);
 
-  r = uv_tcp_connect(&connect_req, &tcp, &server_addr, connect_cb);
+  r = uv_tcp_connect(&connect_req,
+                     &tcp,
+                     (const struct sockaddr*) &server_addr,
+                     connect_cb);
   ASSERT(!r);
 
   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
index 306372a..0cecede 100644 (file)
@@ -42,12 +42,12 @@ TEST_IMPL(tcp_bind_error_addrinuse) {
   ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr));
   r = uv_tcp_init(uv_default_loop(), &server1);
   ASSERT(r == 0);
-  r = uv_tcp_bind(&server1, &addr);
+  r = uv_tcp_bind(&server1, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_tcp_init(uv_default_loop(), &server2);
   ASSERT(r == 0);
-  r = uv_tcp_bind(&server2, &addr);
+  r = uv_tcp_bind(&server2, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_listen((uv_stream_t*)&server1, 128, NULL);
@@ -78,7 +78,7 @@ TEST_IMPL(tcp_bind_error_addrnotavail_1) {
   ASSERT(r == 0);
 
   /* It seems that Linux is broken here - bind succeeds. */
-  r = uv_tcp_bind(&server, &addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr);
   ASSERT(r == 0 || r == UV_EADDRNOTAVAIL);
 
   uv_close((uv_handle_t*)&server, close_cb);
@@ -101,7 +101,7 @@ TEST_IMPL(tcp_bind_error_addrnotavail_2) {
 
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
-  r = uv_tcp_bind(&server, &addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr);
   ASSERT(r == UV_EADDRNOTAVAIL);
 
   uv_close((uv_handle_t*)&server, close_cb);
@@ -125,7 +125,7 @@ TEST_IMPL(tcp_bind_error_fault) {
 
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
-  r = uv_tcp_bind(&server, garbage_addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) garbage_addr);
   ASSERT(r == UV_EINVAL);
 
   uv_close((uv_handle_t*)&server, close_cb);
@@ -151,9 +151,9 @@ TEST_IMPL(tcp_bind_error_inval) {
 
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
-  r = uv_tcp_bind(&server, &addr1);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr1);
   ASSERT(r == 0);
-  r = uv_tcp_bind(&server, &addr2);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr2);
   ASSERT(r == UV_EINVAL);
 
   uv_close((uv_handle_t*)&server, close_cb);
@@ -176,7 +176,7 @@ TEST_IMPL(tcp_bind_localhost_ok) {
 
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
-  r = uv_tcp_bind(&server, &addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   MAKE_VALGRIND_HAPPY();
index e92afef..7eb2f05 100644 (file)
@@ -43,12 +43,12 @@ TEST_IMPL(tcp_bind6_error_addrinuse) {
 
   r = uv_tcp_init(uv_default_loop(), &server1);
   ASSERT(r == 0);
-  r = uv_tcp_bind6(&server1, &addr);
+  r = uv_tcp_bind(&server1, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_tcp_init(uv_default_loop(), &server2);
   ASSERT(r == 0);
-  r = uv_tcp_bind6(&server2, &addr);
+  r = uv_tcp_bind(&server2, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_listen((uv_stream_t*)&server1, 128, NULL);
@@ -77,7 +77,7 @@ TEST_IMPL(tcp_bind6_error_addrnotavail) {
 
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
-  r = uv_tcp_bind6(&server, &addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr);
   ASSERT(r == UV_EADDRNOTAVAIL);
 
   uv_close((uv_handle_t*)&server, close_cb);
@@ -101,7 +101,7 @@ TEST_IMPL(tcp_bind6_error_fault) {
 
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
-  r = uv_tcp_bind6(&server, garbage_addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) garbage_addr);
   ASSERT(r == UV_EINVAL);
 
   uv_close((uv_handle_t*)&server, close_cb);
@@ -127,9 +127,9 @@ TEST_IMPL(tcp_bind6_error_inval) {
 
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
-  r = uv_tcp_bind6(&server, &addr1);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr1);
   ASSERT(r == 0);
-  r = uv_tcp_bind6(&server, &addr2);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr2);
   ASSERT(r == UV_EINVAL);
 
   uv_close((uv_handle_t*)&server, close_cb);
@@ -152,7 +152,7 @@ TEST_IMPL(tcp_bind6_localhost_ok) {
 
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
-  r = uv_tcp_bind6(&server, &addr);
+  r = uv_tcp_bind(&server, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   MAKE_VALGRIND_HAPPY();
index 9e83552..b9f7f96 100644 (file)
@@ -63,7 +63,10 @@ TEST_IMPL(tcp_close_while_connecting) {
   loop = uv_default_loop();
   ASSERT(0 == uv_ip4_addr("1.2.3.4", TEST_PORT, &addr));
   ASSERT(0 == uv_tcp_init(loop, &tcp_handle));
-  ASSERT(0 == uv_tcp_connect(&connect_req, &tcp_handle, &addr, connect_cb));
+  ASSERT(0 == uv_tcp_connect(&connect_req,
+                             &tcp_handle,
+                             (const struct sockaddr*) &addr,
+                             connect_cb));
   ASSERT(0 == uv_timer_init(loop, &timer1_handle));
   ASSERT(0 == uv_timer_start(&timer1_handle, timer1_cb, 50, 0));
   ASSERT(0 == uv_timer_init(loop, &timer2_handle));
index 183e9af..05af38c 100644 (file)
@@ -85,7 +85,7 @@ static void start_server(uv_loop_t* loop, uv_tcp_t* handle) {
   r = uv_tcp_init(loop, handle);
   ASSERT(r == 0);
 
-  r = uv_tcp_bind(handle, &addr);
+  r = uv_tcp_bind(handle, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_listen((uv_stream_t*)handle, 128, connection_cb);
@@ -114,7 +114,10 @@ TEST_IMPL(tcp_close) {
   r = uv_tcp_init(loop, &tcp_handle);
   ASSERT(r == 0);
 
-  r = uv_tcp_connect(&connect_req, &tcp_handle, &addr, connect_cb);
+  r = uv_tcp_connect(&connect_req,
+                     &tcp_handle,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
 
   ASSERT(write_cb_called == 0);
index b437bf3..3f2e357 100644 (file)
@@ -77,7 +77,10 @@ TEST_IMPL(tcp_connect_error_after_write) {
   r = uv_write(&write_req, (uv_stream_t*)&conn, &buf, 1, write_cb);
   ASSERT(r == UV_EBADF);
 
-  r = uv_tcp_connect(&connect_req, &conn, &addr, connect_cb);
+  r = uv_tcp_connect(&connect_req,
+                     &conn,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
 
   r = uv_write(&write_req, (uv_stream_t*)&conn, &buf, 1, write_cb);
index 278548a..eab1eeb 100644 (file)
@@ -55,7 +55,10 @@ TEST_IMPL(tcp_connect_error_fault) {
 
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
-  r = uv_tcp_connect(&req, &server, garbage_addr, connect_cb);
+  r = uv_tcp_connect(&req,
+                     &server,
+                     (const struct sockaddr*) garbage_addr,
+                     connect_cb);
   ASSERT(r == UV_EINVAL);
 
   uv_close((uv_handle_t*)&server, close_cb);
index a14a89d..cc583ca 100644 (file)
@@ -75,7 +75,10 @@ TEST_IMPL(tcp_connect_timeout) {
   r = uv_tcp_init(uv_default_loop(), &conn);
   ASSERT(r == 0);
 
-  r = uv_tcp_connect(&connect_req, &conn, &addr, connect_cb);
+  r = uv_tcp_connect(&connect_req,
+                     &conn,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
 
   r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
index c0e8262..91ac0a3 100644 (file)
@@ -53,7 +53,10 @@ TEST_IMPL(tcp_connect6_error_fault) {
 
   r = uv_tcp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
-  r = uv_tcp_connect6(&req, &server, garbage_addr, connect_cb);
+  r = uv_tcp_connect(&req,
+                     &server,
+                     (const struct sockaddr*) garbage_addr,
+                     connect_cb);
   ASSERT(r == UV_EINVAL);
 
   uv_close((uv_handle_t*)&server, close_cb);
index ddf8d50..edeacc7 100644 (file)
@@ -164,7 +164,10 @@ TEST_IMPL(tcp_open) {
   r = uv_tcp_open(&client, sock);
   ASSERT(r == 0);
 
-  r = uv_tcp_connect(&connect_req, &client, &addr, connect_cb);
+  r = uv_tcp_connect(&connect_req,
+                     &client,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
 
   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
index 3dc9d87..c8d9c04 100644 (file)
@@ -65,7 +65,10 @@ TEST_IMPL(tcp_read_stop) {
   ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
   ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle));
   ASSERT(0 == uv_tcp_init(uv_default_loop(), &tcp_handle));
-  ASSERT(0 == uv_tcp_connect(&connect_req, &tcp_handle, &addr, connect_cb));
+  ASSERT(0 == uv_tcp_connect(&connect_req,
+                             &tcp_handle,
+                             (const struct sockaddr*) &addr,
+                             connect_cb));
   ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
   MAKE_VALGRIND_HAPPY();
 
index de6f557..c59acc4 100644 (file)
@@ -118,7 +118,10 @@ TEST_IMPL(tcp_shutdown_after_write) {
   r = uv_tcp_init(loop, &conn);
   ASSERT(r == 0);
 
-  r = uv_tcp_connect(&connect_req, &conn, &addr, connect_cb);
+  r = uv_tcp_connect(&connect_req,
+                     &conn,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
 
   r = uv_run(loop, UV_RUN_DEFAULT);
index 14fd682..3410cf0 100644 (file)
@@ -98,9 +98,12 @@ TEST_IMPL(tcp_unexpected_read) {
   ASSERT(0 == uv_tcp_init(loop, &server_handle));
   ASSERT(0 == uv_tcp_init(loop, &client_handle));
   ASSERT(0 == uv_tcp_init(loop, &peer_handle));
-  ASSERT(0 == uv_tcp_bind(&server_handle, &addr));
+  ASSERT(0 == uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr));
   ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb));
-  ASSERT(0 == uv_tcp_connect(&connect_req, &client_handle, &addr, connect_cb));
+  ASSERT(0 == uv_tcp_connect(&connect_req,
+                             &client_handle,
+                             (const struct sockaddr*) &addr,
+                             connect_cb));
   ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
 
   /* This is somewhat inexact but the idea is that the event loop should not
index b33deee..92cc7d9 100644 (file)
@@ -115,7 +115,7 @@ TEST_IMPL(tcp_write_to_half_open_connection) {
   r = uv_tcp_init(loop, &tcp_server);
   ASSERT(r == 0);
 
-  r = uv_tcp_bind(&tcp_server, &addr);
+  r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr);
   ASSERT(r == 0);
 
   r = uv_listen((uv_stream_t*)&tcp_server, 1, connection_cb);
@@ -124,7 +124,10 @@ TEST_IMPL(tcp_write_to_half_open_connection) {
   r = uv_tcp_init(loop, &tcp_client);
   ASSERT(r == 0);
 
-  r = uv_tcp_connect(&connect_req, &tcp_client, &addr, connect_cb);
+  r = uv_tcp_connect(&connect_req,
+                     &tcp_client,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
 
   r = uv_run(loop, UV_RUN_DEFAULT);
index 88f499b..6cfe2eb 100644 (file)
@@ -153,7 +153,10 @@ TEST_IMPL(tcp_writealot) {
   r = uv_tcp_init(uv_default_loop(), &client);
   ASSERT(r == 0);
 
-  r = uv_tcp_connect(&connect_req, &client, &addr, connect_cb);
+  r = uv_tcp_connect(&connect_req,
+                     &client,
+                     (const struct sockaddr*) &addr,
+                     connect_cb);
   ASSERT(r == 0);
 
   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
index ecbafa9..bd44c42 100644 (file)
@@ -70,7 +70,12 @@ TEST_IMPL(udp_dgram_too_big) {
   buf = uv_buf_init(dgram, sizeof dgram);
   ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
 
-  r = uv_udp_send(&req_, &handle_, &buf, 1, &addr, send_cb);
+  r = uv_udp_send(&req_,
+                  &handle_,
+                  &buf,
+                  1,
+                  (const struct sockaddr*) &addr,
+                  send_cb);
   ASSERT(r == 0);
 
   ASSERT(close_cb_called == 0);
index f545f81..32cabf0 100644 (file)
@@ -108,7 +108,7 @@ static void do_test(uv_udp_recv_cb recv_cb, int bind_flags) {
   r = uv_udp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
 
-  r = uv_udp_bind6(&server, &addr6, bind_flags);
+  r = uv_udp_bind(&server, (const struct sockaddr*) &addr6, bind_flags);
   ASSERT(r == 0);
 
   r = uv_udp_recv_start(&server, alloc_cb, recv_cb);
@@ -120,7 +120,12 @@ static void do_test(uv_udp_recv_cb recv_cb, int bind_flags) {
   buf = uv_buf_init("PING", 4);
   ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
 
-  r = uv_udp_send(&req_, &client, &buf, 1, &addr, send_cb);
+  r = uv_udp_send(&req_,
+                  &client,
+                  &buf,
+                  1,
+                  (const struct sockaddr*) &addr,
+                  send_cb);
   ASSERT(r == 0);
 
   r = uv_timer_init(uv_default_loop(), &timeout);
index 0e750d8..686edf3 100644 (file)
@@ -111,7 +111,7 @@ TEST_IMPL(udp_multicast_join) {
   ASSERT(r == 0);
 
   /* bind to the desired port */
-  r = uv_udp_bind(&client, &addr, 0);
+  r = uv_udp_bind(&client, (const struct sockaddr*) &addr, 0);
   ASSERT(r == 0);
 
   /* join the multicast channel */
@@ -124,7 +124,12 @@ TEST_IMPL(udp_multicast_join) {
   buf = uv_buf_init("PING", 4);
 
   /* server sends "PING" */
-  r = uv_udp_send(&req, &server, &buf, 1, &addr, sv_send_cb);
+  r = uv_udp_send(&req,
+                  &server,
+                  &buf,
+                  1,
+                  (const struct sockaddr*) &addr,
+                  sv_send_cb);
   ASSERT(r == 0);
 
   ASSERT(close_cb_called == 0);
index 390ea57..bed0ea1 100644 (file)
@@ -63,7 +63,7 @@ TEST_IMPL(udp_multicast_ttl) {
   ASSERT(r == 0);
 
   ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &addr));
-  r = uv_udp_bind(&server, &addr, 0);
+  r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0);
   ASSERT(r == 0);
 
   r = uv_udp_set_multicast_ttl(&server, 32);
@@ -72,7 +72,12 @@ TEST_IMPL(udp_multicast_ttl) {
   /* server sends "PING" */
   buf = uv_buf_init("PING", 4);
   ASSERT(0 == uv_ip4_addr("239.255.0.1", TEST_PORT, &addr));
-  r = uv_udp_send(&req, &server, &buf, 1, &addr, sv_send_cb);
+  r = uv_udp_send(&req,
+                  &server,
+                  &buf,
+                  1,
+                  (const struct sockaddr*) &addr,
+                  sv_send_cb);
   ASSERT(r == 0);
 
   ASSERT(close_cb_called == 0);
index 3d64b00..9a97303 100644 (file)
@@ -140,13 +140,18 @@ TEST_IMPL(udp_open) {
   r = uv_udp_open(&client, sock);
   ASSERT(r == 0);
 
-  r = uv_udp_bind(&client, &addr, 0);
+  r = uv_udp_bind(&client, (const struct sockaddr*) &addr, 0);
   ASSERT(r == 0);
 
   r = uv_udp_recv_start(&client, alloc_cb, recv_cb);
   ASSERT(r == 0);
 
-  r = uv_udp_send(&send_req, &client, &buf, 1, &addr, send_cb);
+  r = uv_udp_send(&send_req,
+                  &client,
+                  &buf,
+                  1,
+                  (const struct sockaddr*) &addr,
+                  send_cb);
   ASSERT(r == 0);
 
   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
index af90a57..5cc3698 100644 (file)
@@ -43,7 +43,7 @@ TEST_IMPL(udp_options) {
 
   uv_unref((uv_handle_t*)&h); /* don't keep the loop alive */
 
-  r = uv_udp_bind(&h, &addr, 0);
+  r = uv_udp_bind(&h, (const struct sockaddr*) &addr, 0);
   ASSERT(r == 0);
 
   r = uv_udp_set_broadcast(&h, 1);
index d8da37b..aa9a31c 100644 (file)
@@ -152,12 +152,7 @@ static void sv_recv_cb(uv_udp_t* handle,
   ASSERT(req != NULL);
 
   sndbuf = uv_buf_init("PONG", 4);
-  r = uv_udp_send(req,
-                  handle,
-                  &sndbuf,
-                  1,
-                  (const struct sockaddr_in*) addr,
-                  sv_send_cb);
+  r = uv_udp_send(req, handle, &sndbuf, 1, addr, sv_send_cb);
   ASSERT(r == 0);
 
   sv_recv_cb_called++;
@@ -175,7 +170,7 @@ TEST_IMPL(udp_send_and_recv) {
   r = uv_udp_init(uv_default_loop(), &server);
   ASSERT(r == 0);
 
-  r = uv_udp_bind(&server, &addr, 0);
+  r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0);
   ASSERT(r == 0);
 
   r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb);
@@ -189,7 +184,12 @@ TEST_IMPL(udp_send_and_recv) {
   /* client sends "PING", expects "PONG" */
   buf = uv_buf_init("PING", 4);
 
-  r = uv_udp_send(&req, &client, &buf, 1, &addr, cl_send_cb);
+  r = uv_udp_send(&req,
+                  &client,
+                  &buf,
+                  1,
+                  (const struct sockaddr*) &addr,
+                  cl_send_cb);
   ASSERT(r == 0);
 
   ASSERT(close_cb_called == 0);
index 43a6f90..e007056 100644 (file)
@@ -272,7 +272,7 @@ void TCPWrap::Bind(const FunctionCallbackInfo<Value>& args) {
   sockaddr_in addr;
   int err = uv_ip4_addr(*ip_address, port, &addr);
   if (err == 0)
-    err = uv_tcp_bind(&wrap->handle_, &addr);
+    err = uv_tcp_bind(&wrap->handle_, reinterpret_cast<const sockaddr*>(&addr));
 
   args.GetReturnValue().Set(err);
 }
@@ -290,7 +290,7 @@ void TCPWrap::Bind6(const FunctionCallbackInfo<Value>& args) {
   sockaddr_in6 addr;
   int err = uv_ip6_addr(*ip6_address, port, &addr);
   if (err == 0)
-    err = uv_tcp_bind6(&wrap->handle_, &addr);
+    err = uv_tcp_bind(&wrap->handle_, reinterpret_cast<const sockaddr*>(&addr));
 
   args.GetReturnValue().Set(err);
 }
@@ -387,7 +387,10 @@ void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
 
   if (err == 0) {
     ConnectWrap* req_wrap = new ConnectWrap(req_wrap_obj);
-    err = uv_tcp_connect(&req_wrap->req_, &wrap->handle_, &addr, AfterConnect);
+    err = uv_tcp_connect(&req_wrap->req_,
+                         &wrap->handle_,
+                         reinterpret_cast<const sockaddr*>(&addr),
+                         AfterConnect);
     req_wrap->Dispatched();
     if (err) delete req_wrap;
   }
@@ -415,7 +418,10 @@ void TCPWrap::Connect6(const FunctionCallbackInfo<Value>& args) {
 
   if (err == 0) {
     ConnectWrap* req_wrap = new ConnectWrap(req_wrap_obj);
-    err = uv_tcp_connect6(&req_wrap->req_, &wrap->handle_, &addr, AfterConnect);
+    err = uv_tcp_connect(&req_wrap->req_,
+                         &wrap->handle_,
+                         reinterpret_cast<const sockaddr*>(&addr),
+                         AfterConnect);
     req_wrap->Dispatched();
     if (err) delete req_wrap;
   }
index 8ea9345..1e5d322 100644 (file)
@@ -145,7 +145,6 @@ void UDPWrap::GetFD(Local<String>, const PropertyCallbackInfo<Value>& args) {
 
 void UDPWrap::DoBind(const FunctionCallbackInfo<Value>& args, int family) {
   HandleScope scope(node_isolate);
-  int err;
 
   UDPWrap* wrap;
   NODE_UNWRAP(args.This(), UDPWrap, wrap);
@@ -156,29 +155,27 @@ void UDPWrap::DoBind(const FunctionCallbackInfo<Value>& args, int family) {
   String::Utf8Value address(args[0]);
   const int port = args[1]->Uint32Value();
   const int flags = args[2]->Uint32Value();
+  char addr[sizeof(sockaddr_in6)];
+  int err;
 
   switch (family) {
   case AF_INET:
-    {
-      sockaddr_in addr;
-      err = uv_ip4_addr(*address, port, &addr);
-      if (err == 0)
-        err = uv_udp_bind(&wrap->handle_, &addr, flags);
-      break;
-    }
+    err = uv_ip4_addr(*address, port, reinterpret_cast<sockaddr_in*>(&addr));
+    break;
   case AF_INET6:
-    {
-      sockaddr_in6 addr;
-      err = uv_ip6_addr(*address, port, &addr);
-      if (err == 0)
-        err = uv_udp_bind6(&wrap->handle_, &addr, flags);
-      break;
-    }
+    err = uv_ip6_addr(*address, port, reinterpret_cast<sockaddr_in6*>(&addr));
+    break;
   default:
     assert(0 && "unexpected address family");
     abort();
   }
 
+  if (err == 0) {
+    err = uv_udp_bind(&wrap->handle_,
+                      reinterpret_cast<const sockaddr*>(&addr),
+                      flags);
+  }
+
   args.GetReturnValue().Set(err);
 }
 
@@ -248,7 +245,6 @@ void UDPWrap::DropMembership(const FunctionCallbackInfo<Value>& args) {
 
 void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
   HandleScope scope(node_isolate);
-  int err;
 
   UDPWrap* wrap;
   NODE_UNWRAP(args.This(), UDPWrap, wrap);
@@ -277,41 +273,30 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
 
   uv_buf_t buf = uv_buf_init(Buffer::Data(buffer_obj) + offset,
                              length);
+  char addr[sizeof(sockaddr_in6)];
+  int err;
 
   switch (family) {
   case AF_INET:
-    {
-      sockaddr_in addr;
-      err = uv_ip4_addr(*address, port, &addr);
-      if (err == 0) {
-        err = uv_udp_send(&req_wrap->req_,
-                          &wrap->handle_,
-                          &buf,
-                          1,
-                          &addr,
-                          OnSend);
-      }
-      break;
-    }
+    err = uv_ip4_addr(*address, port, reinterpret_cast<sockaddr_in*>(&addr));
+    break;
   case AF_INET6:
-    {
-      sockaddr_in6 addr;
-      err = uv_ip6_addr(*address, port, &addr);
-      if (err == 0) {
-        err = uv_udp_send6(&req_wrap->req_,
-                           &wrap->handle_,
-                           &buf,
-                           1,
-                           &addr,
-                           OnSend);
-      }
-      break;
-    }
+    err = uv_ip6_addr(*address, port, reinterpret_cast<sockaddr_in6*>(&addr));
+    break;
   default:
     assert(0 && "unexpected address family");
     abort();
   }
 
+  if (err == 0) {
+    err = uv_udp_send(&req_wrap->req_,
+                      &wrap->handle_,
+                      &buf,
+                      1,
+                      reinterpret_cast<const sockaddr*>(&addr),
+                      OnSend);
+  }
+
   req_wrap->Dispatched();
   if (err) delete req_wrap;