From 2d2312d98986d65af47d35a89e176b5cf9953533 Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Wed, 16 Dec 2015 22:53:19 +0100 Subject: Conform to the type signature of setsockopt(2) According to the POSIX standard the option value is a pointer to void and the option length a socklen_t. The Windows implementation makes the option value be a pointer to character and the option length an int. Casting the option value to a pointer to void conforms to the POSIX standard while the implicit cast to a pointer to character conforms to the Windows implementation. The casts of the option length to the socklen_t data type conforms to the POSIX standard. The socklen_t data type is actually an alias of an int so it also conforms to the Windows implementation. --- src/or/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/or/main.c') diff --git a/src/or/main.c b/src/or/main.c index 455cba4513..5c65d46263 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -225,11 +225,13 @@ set_buffer_lengths_to_zero(tor_socket_t s) { int zero = 0; int r = 0; - if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, (void*)&zero, sizeof(zero))) { + if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, (void*)&zero, + (socklen_t)sizeof(zero))) { log_warn(LD_NET, "Unable to clear SO_SNDBUF"); r = -1; } - if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, (void*)&zero, sizeof(zero))) { + if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, (void*)&zero, + (socklen_t)sizeof(zero))) { log_warn(LD_NET, "Unable to clear SO_RCVBUF"); r = -1; } -- cgit v1.2.3-54-g00ecf