From 59cba1767c450f591e542d661c4eddbf01fbb658 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Oct 2010 11:36:16 -0400 Subject: Make the return value of tor_addr_sockaddr always be signed --- src/common/address.c | 4 +--- src/common/address.h | 2 +- src/or/connection.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/common/address.c b/src/common/address.c index dcc32f1aed..c7e8109fa5 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -53,9 +53,7 @@ * socklen object in *sa_out of object size len. If not enough * room is free, or on error, return -1. Else return the length of the * sockaddr. */ -/* XXXX021 This returns socklen_t. socklen_t is sometimes unsigned. This - * function claims to return -1 sometimes. Problematic! */ -socklen_t +int tor_addr_to_sockaddr(const tor_addr_t *a, uint16_t port, struct sockaddr *sa_out, diff --git a/src/common/address.h b/src/common/address.h index 457532d0df..c7a08698f5 100644 --- a/src/common/address.h +++ b/src/common/address.h @@ -39,7 +39,7 @@ static INLINE sa_family_t tor_addr_family(const tor_addr_t *a); static INLINE const struct in_addr *tor_addr_to_in(const tor_addr_t *a); static INLINE int tor_addr_eq_ipv4h(const tor_addr_t *a, uint32_t u); -socklen_t tor_addr_to_sockaddr(const tor_addr_t *a, uint16_t port, +int tor_addr_to_sockaddr(const tor_addr_t *a, uint16_t port, struct sockaddr *sa_out, socklen_t len); int tor_addr_from_sockaddr(tor_addr_t *a, const struct sockaddr *sa, uint16_t *port_out); diff --git a/src/or/connection.c b/src/or/connection.c index d1b079a97e..52996e8ea4 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -1281,7 +1281,7 @@ connection_connect(connection_t *conn, const char *address, int s, inprogress = 0; char addrbuf[256]; struct sockaddr *dest_addr = (struct sockaddr*) addrbuf; - socklen_t dest_addr_len; + int dest_addr_len; or_options_t *options = get_options(); int protocol_family; @@ -1337,7 +1337,7 @@ connection_connect(connection_t *conn, const char *address, log_debug(LD_NET, "Connecting to %s:%u.", escaped_safe_str_client(address), port); - if (connect(s, dest_addr, dest_addr_len) < 0) { + if (connect(s, dest_addr, (socklen_t)dest_addr_len) < 0) { int e = tor_socket_errno(s); if (!ERRNO_IS_CONN_EINPROGRESS(e)) { /* yuck. kill it. */ -- cgit v1.2.3-54-g00ecf