summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2013-01-06 14:56:17 (GMT)
committerRemko Tronçon <git@el-tramo.be>2013-01-13 10:06:37 (GMT)
commit188fc285c6555eadd3c9d50ab8a94adcade78d89 (patch)
treef02f5e249f8b511300d55a826d3b727f9d8d844f /Swiften/Network
parentd5cab0388f6a40db6156a993e5f00acf9e63b577 (diff)
downloadswift-188fc285c6555eadd3c9d50ab8a94adcade78d89.zip
swift-188fc285c6555eadd3c9d50ab8a94adcade78d89.tar.bz2
Fix more warnings.
Fix sign conversion warnings. Removing heavy unnecessary includes. Change-Id: I992f43065498823098a875badb020c7c84fc4797
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/DomainNameServiceQuery.cpp12
-rw-r--r--Swiften/Network/HostAddress.cpp8
-rw-r--r--Swiften/Network/HostAddress.h4
-rw-r--r--Swiften/Network/MacOSXProxyProvider.cpp3
-rw-r--r--Swiften/Network/NATPMPInterface.cpp6
-rw-r--r--Swiften/Network/PlatformDomainNameServiceQuery.cpp7
-rw-r--r--Swiften/Network/PlatformDomainNameServiceQuery.h2
-rw-r--r--Swiften/Network/PlatformNATTraversalWorker.cpp3
-rw-r--r--Swiften/Network/ProxyProvider.h1
-rw-r--r--Swiften/Network/SOCKS5ProxiedConnection.cpp2
-rw-r--r--Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp4
11 files changed, 29 insertions, 23 deletions
diff --git a/Swiften/Network/DomainNameServiceQuery.cpp b/Swiften/Network/DomainNameServiceQuery.cpp
index cc75440..6ce1d97 100644
--- a/Swiften/Network/DomainNameServiceQuery.cpp
+++ b/Swiften/Network/DomainNameServiceQuery.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -15,6 +15,7 @@
#include <boost/numeric/conversion/cast.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
+#include <boost/typeof/typeof.hpp>
using namespace Swift;
namespace lambda = boost::lambda;
@@ -44,11 +45,14 @@ void DomainNameServiceQuery::sortResults(std::vector<DomainNameServiceQuery::Res
std::transform(i, next, std::back_inserter(weights),
/* easy hack to account for '0' weights getting at least some weight */
lambda::bind(&Result::weight, lambda::_1) + 1);
- for (size_t j = 0; j < weights.size() - 1; ++j) {
+ for (int j = 0; j < boost::numeric_cast<int>(weights.size() - 1); ++j) {
std::vector<int> cumulativeWeights;
- std::partial_sum(weights.begin() + j, weights.end(), std::back_inserter(cumulativeWeights));
+ std::partial_sum(
+ weights.begin() + j,
+ weights.end(),
+ std::back_inserter(cumulativeWeights));
int randomNumber = generator.generateRandomInteger(cumulativeWeights.back());
- size_t selectedIndex = std::lower_bound(cumulativeWeights.begin(), cumulativeWeights.end(), randomNumber) - cumulativeWeights.begin();
+ BOOST_AUTO(selectedIndex, std::lower_bound(cumulativeWeights.begin(), cumulativeWeights.end(), randomNumber) - cumulativeWeights.begin());
std::swap(i[j], i[j + selectedIndex]);
std::swap(weights.begin()[j], weights.begin()[j + selectedIndex]);
}
diff --git a/Swiften/Network/HostAddress.cpp b/Swiften/Network/HostAddress.cpp
index f00581f..9443b53 100644
--- a/Swiften/Network/HostAddress.cpp
+++ b/Swiften/Network/HostAddress.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -28,18 +28,18 @@ HostAddress::HostAddress(const std::string& address) {
}
}
-HostAddress::HostAddress(const unsigned char* address, int length) {
+HostAddress::HostAddress(const unsigned char* address, size_t length) {
assert(length == 4 || length == 16);
if (length == 4) {
boost::asio::ip::address_v4::bytes_type data;
- for (int i = 0; i < length; ++i) {
+ for (size_t i = 0; i < length; ++i) {
data[i] = address[i];
}
address_ = boost::asio::ip::address(boost::asio::ip::address_v4(data));
}
else {
boost::asio::ip::address_v6::bytes_type data;
- for (int i = 0; i < length; ++i) {
+ for (size_t i = 0; i < length; ++i) {
data[i] = address[i];
}
address_ = boost::asio::ip::address(boost::asio::ip::address_v6(data));
diff --git a/Swiften/Network/HostAddress.h b/Swiften/Network/HostAddress.h
index 621aa5d..b8e3462 100644
--- a/Swiften/Network/HostAddress.h
+++ b/Swiften/Network/HostAddress.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -15,7 +15,7 @@ namespace Swift {
public:
HostAddress();
HostAddress(const std::string&);
- HostAddress(const unsigned char* address, int length);
+ HostAddress(const unsigned char* address, size_t length);
HostAddress(const boost::asio::ip::address& address);
std::string toString() const;
diff --git a/Swiften/Network/MacOSXProxyProvider.cpp b/Swiften/Network/MacOSXProxyProvider.cpp
index 8032a42..918e18c 100644
--- a/Swiften/Network/MacOSXProxyProvider.cpp
+++ b/Swiften/Network/MacOSXProxyProvider.cpp
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
+#include <boost/numeric/conversion/cast.hpp>
#include <utility>
#ifndef SWIFTEN_PLATFORM_IPHONE
@@ -55,7 +56,7 @@ static HostAddressPort getFromDictionary(CFDictionaryRef dict, CFStringRef enabl
// length must be +1 for the ending zero; and the Docu of CFStringGetCString tells it like
// if the string is toby the length must be at least 5.
CFIndex length = CFStringGetLength(stringValue) + 1;
- buffer.resize(length);
+ buffer.resize(boost::numeric_cast<size_t>(length));
if(CFStringGetCString(stringValue, &buffer[0], length, kCFStringEncodingMacRoman)) {
for(std::vector<char>::iterator iter = buffer.begin(); iter != buffer.end(); ++iter) {
host += *iter;
diff --git a/Swiften/Network/NATPMPInterface.cpp b/Swiften/Network/NATPMPInterface.cpp
index 15508b5..c7a41ff 100644
--- a/Swiften/Network/NATPMPInterface.cpp
+++ b/Swiften/Network/NATPMPInterface.cpp
@@ -69,7 +69,7 @@ boost::optional<NATPortMapping> NATPMPInterface::addPortForward(int localPort, i
mapping.getProtocol() == NATPortMapping::TCP ? NATPMP_PROTOCOL_TCP : NATPMP_PROTOCOL_UDP,
boost::numeric_cast<uint16_t>(mapping.getLocalPort()),
boost::numeric_cast<uint16_t>(mapping.getPublicPort()),
- mapping.getLeaseInSeconds()) < 0) {
+ boost::numeric_cast<uint32_t>(mapping.getLeaseInSeconds())) < 0) {
SWIFT_LOG(debug) << "Failed to send NAT-PMP port forwarding request!" << std::endl;
return boost::optional<NATPortMapping>();
}
@@ -87,7 +87,7 @@ boost::optional<NATPortMapping> NATPMPInterface::addPortForward(int localPort, i
} while(r == NATPMP_TRYAGAIN);
if (r == 0) {
- NATPortMapping result(response.pnu.newportmapping.privateport, response.pnu.newportmapping.mappedpublicport, NATPortMapping::TCP, response.pnu.newportmapping.lifetime);
+ NATPortMapping result(response.pnu.newportmapping.privateport, response.pnu.newportmapping.mappedpublicport, NATPortMapping::TCP, boost::numeric_cast<int>(response.pnu.newportmapping.lifetime));
return result;
}
else {
@@ -97,7 +97,7 @@ boost::optional<NATPortMapping> NATPMPInterface::addPortForward(int localPort, i
}
bool NATPMPInterface::removePortForward(const NATPortMapping& mapping) {
- if (sendnewportmappingrequest(&p->natpmp, mapping.getProtocol() == NATPortMapping::TCP ? NATPMP_PROTOCOL_TCP : NATPMP_PROTOCOL_UDP, 0, 0, mapping.getLocalPort()) < 0) {
+ if (sendnewportmappingrequest(&p->natpmp, mapping.getProtocol() == NATPortMapping::TCP ? NATPMP_PROTOCOL_TCP : NATPMP_PROTOCOL_UDP, 0, 0, boost::numeric_cast<uint32_t>(mapping.getLocalPort())) < 0) {
SWIFT_LOG(debug) << "Failed to send NAT-PMP remove forwarding request!" << std::endl;
return false;
}
diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.cpp b/Swiften/Network/PlatformDomainNameServiceQuery.cpp
index b0579a7..5788d2f 100644
--- a/Swiften/Network/PlatformDomainNameServiceQuery.cpp
+++ b/Swiften/Network/PlatformDomainNameServiceQuery.cpp
@@ -12,6 +12,7 @@
#include <Swiften/Base/Platform.h>
#include <stdlib.h>
+#include <boost/numeric/conversion/cast.hpp>
#ifdef SWIFTEN_PLATFORM_WINDOWS
#undef UNICODE
#include <windows.h>
@@ -121,7 +122,7 @@ void PlatformDomainNameServiceQuery::runBlocking() {
emitError();
return;
}
- record.priority = ns_get16(currentEntry);
+ record.priority = boost::numeric_cast<int>(ns_get16(currentEntry));
currentEntry += 2;
// Weight
@@ -129,7 +130,7 @@ void PlatformDomainNameServiceQuery::runBlocking() {
emitError();
return;
}
- record.weight = ns_get16(currentEntry);
+ record.weight = boost::numeric_cast<int>(ns_get16(currentEntry));
currentEntry += 2;
// Port
@@ -137,7 +138,7 @@ void PlatformDomainNameServiceQuery::runBlocking() {
emitError();
return;
}
- record.port = ns_get16(currentEntry);
+ record.port = boost::numeric_cast<int>(ns_get16(currentEntry));
currentEntry += 2;
// Hostname
diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.h b/Swiften/Network/PlatformDomainNameServiceQuery.h
index 3372517..310e639 100644
--- a/Swiften/Network/PlatformDomainNameServiceQuery.h
+++ b/Swiften/Network/PlatformDomainNameServiceQuery.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
diff --git a/Swiften/Network/PlatformNATTraversalWorker.cpp b/Swiften/Network/PlatformNATTraversalWorker.cpp
index c962b3b..eeecb38 100644
--- a/Swiften/Network/PlatformNATTraversalWorker.cpp
+++ b/Swiften/Network/PlatformNATTraversalWorker.cpp
@@ -8,6 +8,7 @@
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/enable_shared_from_this.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Base/Log.h>
#include <Swiften/Network/NATTraversalGetPublicIPRequest.h>
@@ -68,7 +69,7 @@ class PlatformNATTraversalForwardPortRequest : public NATTraversalForwardPortReq
}
virtual void runBlocking() {
- onResult(getNATTraversalInterface()->addPortForward(localIP, publicIP));
+ onResult(getNATTraversalInterface()->addPortForward(boost::numeric_cast<int>(localIP), boost::numeric_cast<int>(publicIP)));
}
private:
diff --git a/Swiften/Network/ProxyProvider.h b/Swiften/Network/ProxyProvider.h
index 0b63d51..9a1ccee 100644
--- a/Swiften/Network/ProxyProvider.h
+++ b/Swiften/Network/ProxyProvider.h
@@ -7,7 +7,6 @@
#pragma once
#include <map>
-#include <Swiften/Base/Log.h>
#include <Swiften/Network/HostAddressPort.h>
#include <Swiften/Base/String.h>
diff --git a/Swiften/Network/SOCKS5ProxiedConnection.cpp b/Swiften/Network/SOCKS5ProxiedConnection.cpp
index bf7a056..a9243d6 100644
--- a/Swiften/Network/SOCKS5ProxiedConnection.cpp
+++ b/Swiften/Network/SOCKS5ProxiedConnection.cpp
@@ -65,7 +65,7 @@ void SOCKS5ProxiedConnection::handleProxyInitializeData(boost::shared_ptr<SafeBy
else {
uc = rawAddress.to_v6().to_bytes()[s]; // the address.
}
- socksConnect.push_back(static_cast<char>(uc));
+ socksConnect.push_back(uc);
}
socksConnect.push_back(static_cast<unsigned char> ((getServer().getPort() >> 8) & 0xFF)); // highbyte of the port.
diff --git a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp
index 23f1a3c..8a63fcb 100644
--- a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp
+++ b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp
@@ -170,7 +170,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture {
void testConnectionCount_ThreeWritesTwoReads() {
boost::shared_ptr<MockConnection> c0;
boost::shared_ptr<MockConnection> c1;
- long rid = initialRID;
+ unsigned long long rid = initialRID;
PoolRef testling = createTestling();
CPPUNIT_ASSERT_EQUAL(st(1), connectionFactory->connections.size());
@@ -461,7 +461,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture {
std::string port;
std::string sid;
std::string initial;
- long initialRID;
+ unsigned long long initialRID;
int sessionStarted;
int sessionTerminated;