aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-10-15 11:36:16 -0400
committerNick Mathewson <nickm@torproject.org>2010-10-15 11:36:16 -0400
commit59cba1767c450f591e542d661c4eddbf01fbb658 (patch)
treebacc2378b766fdc565ba58d2c41e5dfb33b68d70
parent247ce5876a56cdbbd6a7b3f501476ff10f4bce5e (diff)
downloadtor-59cba1767c450f591e542d661c4eddbf01fbb658.tar.gz
tor-59cba1767c450f591e542d661c4eddbf01fbb658.zip
Make the return value of tor_addr_sockaddr always be signed
-rw-r--r--src/common/address.c4
-rw-r--r--src/common/address.h2
-rw-r--r--src/or/connection.c4
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 *<b>sa_out</b> of object size <b>len</b>. 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. */