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
parentd5cab0388f6a40db6156a993e5f00acf9e63b577 (diff)
downloadswift-188fc285c6555eadd3c9d50ab8a94adcade78d89.zip
swift-188fc285c6555eadd3c9d50ab8a94adcade78d89.tar.bz2
Fix more warnings.
Fix sign conversion warnings. Removing heavy unnecessary includes. Change-Id: I992f43065498823098a875badb020c7c84fc4797
-rwxr-xr-xBuildTools/CheckHeaders.py43
-rwxr-xr-xBuildTools/Git/Hooks/pre-commit4
-rw-r--r--BuildTools/SCons/SConscript.boot5
-rw-r--r--Slimber/UnitTest/MenuletControllerTest.cpp12
-rw-r--r--Sluift/sluift.cpp2
-rw-r--r--Swift/Controllers/FileTransfer/FileTransferController.cpp1
-rw-r--r--Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp4
-rw-r--r--Swift/Controllers/HighlightManager.cpp8
-rw-r--r--Swift/Controllers/HighlightRule.cpp2
-rw-r--r--Swift/Controllers/Roster/LeastCommonSubsequence.h25
-rw-r--r--Swift/Controllers/Roster/TableRoster.cpp7
-rw-r--r--Swift/Controllers/Storages/CertificateFileStorage.cpp5
-rw-r--r--Swiften/Base/ByteArray.cpp5
-rw-r--r--Swiften/Base/ByteArray.h4
-rw-r--r--Swiften/Base/SafeByteArray.h4
-rw-r--r--Swiften/Compress/ZLibCodecompressor.cpp7
-rw-r--r--Swiften/Elements/JingleIBBTransportPayload.h8
-rw-r--r--Swiften/Elements/JinglePayload.h2
-rw-r--r--Swiften/Elements/StanzaAck.cpp19
-rw-r--r--Swiften/Elements/StanzaAck.h11
-rw-r--r--Swiften/Elements/StreamInitiationFileInfo.h16
-rw-r--r--Swiften/Examples/SendFile/ReceiveFile.cpp3
-rw-r--r--Swiften/Examples/SendFile/SendFile.cpp3
-rw-r--r--Swiften/FileTransfer/ByteArrayReadBytestream.cpp33
-rw-r--r--Swiften/FileTransfer/ByteArrayReadBytestream.h21
-rw-r--r--Swiften/FileTransfer/FileReadBytestream.cpp7
-rw-r--r--Swiften/FileTransfer/FileTransferManager.h2
-rw-r--r--Swiften/FileTransfer/FileTransferManagerImpl.cpp2
-rw-r--r--Swiften/FileTransfer/FileTransferManagerImpl.h2
-rw-r--r--Swiften/FileTransfer/FileWriteBytestream.cpp5
-rw-r--r--Swiften/FileTransfer/IBBSendSession.cpp5
-rw-r--r--Swiften/FileTransfer/IBBSendSession.h6
-rw-r--r--Swiften/FileTransfer/OutgoingSIFileTransfer.cpp4
-rw-r--r--Swiften/FileTransfer/OutgoingSIFileTransfer.h6
-rw-r--r--Swiften/FileTransfer/SConscript1
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp2
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp6
-rw-r--r--Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h2
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp2
-rw-r--r--Swiften/JID/JID.cpp12
-rw-r--r--Swiften/JID/JID.h14
-rw-r--r--Swiften/Jingle/JingleSessionManager.cpp3
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h5
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h5
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h4
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceInfo.cpp6
-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
-rw-r--r--Swiften/Parser/BOSHBodyExtractor.cpp13
-rw-r--r--Swiften/Parser/ExpatParser.cpp3
-rw-r--r--Swiften/Parser/LibXMLParser.cpp12
-rw-r--r--Swiften/Parser/PayloadParsers/JingleIBBTransportMethodPayloadParser.cpp2
-rw-r--r--Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp4
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/JingleParserTest.cpp8
-rw-r--r--Swiften/SASL/DIGESTMD5Properties.cpp8
-rw-r--r--Swiften/SASL/PLAINMessage.cpp6
-rw-r--r--Swiften/SConscript1
-rw-r--r--Swiften/Serializer/PayloadSerializers/BlockSerializer.h10
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp3
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContext.cpp3
69 files changed, 293 insertions, 187 deletions
diff --git a/BuildTools/CheckHeaders.py b/BuildTools/CheckHeaders.py
index 73f49db..ce907c5 100755
--- a/BuildTools/CheckHeaders.py
+++ b/BuildTools/CheckHeaders.py
@@ -2,20 +2,41 @@
import os, sys
+FORBIDDEN_INCLUDES = [
+ ("iostream", ["Swiften/Base/format.h"]),
+ ("Base/Log.h", []),
+ ("Base/format.h", []),
+ ("algorithm", ["Swiften/Base/Algorithm.h", "Swiften/Base/SafeAllocator.h"]),
+ ("boost/bind.hpp", []),
+ ("boost/filesystem.hpp", []),
+ ("Base/foreach.h", []),
+ ("boost/date_time/date_time.hpp", []),
+ ("boost/filesystem/filesystem.hpp", []),
+
+ # To avoid
+ ("Base/Algorithm.h", ["Swiften/StringCodecs/HMAC.h"]),
+]
+
foundBadHeaders = False
-for (path, dirs, files) in os.walk(".") :
- if "3rdParty" in path or ".sconf" in path or ".framework" in path :
+filename = sys.argv[1]
+
+if "3rdParty" in filename or ".sconf" in filename or ".framework" in filename or not filename.endswith(".h") :
+ sys.exit(0)
+if not "Swiften" in filename :
+ sys.exit(0)
+if filename.endswith("Swiften.h") :
+ sys.exit(0)
+
+file = open(filename, "r")
+for line in file.readlines() :
+ if not "#include" in line :
continue
- if not "Swiften" in path :
+ if "Base/Log.h" in filename :
continue
-
- for filename in [os.path.join(path, file) for file in files if file.endswith(".h")] :
- file = open(filename, "r")
- for line in file.readlines() :
- for include in ["iostream", "algorithm", "cassert", "boost/bind.hpp", "boost/filesystem.hpp", "Base/foreach.h", "Base/Log.h", "boost/date_time/date_time.hpp", "boost/filesystem/filesystem.hpp"] :
- if "#include" in line and include in line and not "Base/Log" in filename :
- print "Found " + include + " include in " + filename
- foundBadHeaders = True
+ for forbiddenInclude, ignores in FORBIDDEN_INCLUDES :
+ if forbiddenInclude in line and len([x for x in ignores if x in filename]) == 0 :
+ print "Found " + forbiddenInclude + " include in " + filename
+ foundBadHeaders = True
sys.exit(foundBadHeaders)
diff --git a/BuildTools/Git/Hooks/pre-commit b/BuildTools/Git/Hooks/pre-commit
index 11f0c2d..ad0945e 100755
--- a/BuildTools/Git/Hooks/pre-commit
+++ b/BuildTools/Git/Hooks/pre-commit
@@ -16,4 +16,8 @@ for file in $(git diff --cached --name-only); do
echo "ERROR: '$file' has a copyright error. Aborting commit."
exit -1
fi
+ if ! BuildTools/CheckHeaders.py $file; then
+ echo "ERROR: '$file' failed header sanity test. Aborting commit."
+ exit -1
+ fi
done
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot
index e6e1661..8e8aecf 100644
--- a/BuildTools/SCons/SConscript.boot
+++ b/BuildTools/SCons/SConscript.boot
@@ -227,12 +227,11 @@ else :
env.Append(CXXFLAGS = [
"-Weverything",
"-Wno-unknown-warning-option", # To stay compatible between CLang versions
- "-Wno-sign-conversion", # We have this a lot. Not sure if we should allow this or not.
- "-Wno-weak-vtables", # Virtually none of our elements have outlined methods
+ "-Wno-weak-vtables", # Virtually none of our elements have outlined methods. This also seems to affect classes in .cpp files, which in turn affects all our tests, which may need fixing in CLang
"-Wno-shadow", # Also warns for shadowing on constructor arguments, which we do a lot
"-Wno-exit-time-destructors", # Used a lot in e.g. CPPUnit
"-Wno-c++98-compat-pedantic", # We do different things that violate this, but they could be fixed
- "-Wno-global-constructors",
+ "-Wno-global-constructors", # We depend on this for e.g. string constants
"-Wno-padded",
])
else :
diff --git a/Slimber/UnitTest/MenuletControllerTest.cpp b/Slimber/UnitTest/MenuletControllerTest.cpp
index 092a886..b18a37f 100644
--- a/Slimber/UnitTest/MenuletControllerTest.cpp
+++ b/Slimber/UnitTest/MenuletControllerTest.cpp
@@ -33,7 +33,7 @@ class MenuletControllerTest : public CppUnit::TestFixture {
MenuletController testling(menulet);
CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(menulet->items.size()));
- int i = 0;
+ size_t i = 0;
CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string("[Offline] "), menulet->items[i++]);
@@ -50,7 +50,7 @@ class MenuletControllerTest : public CppUnit::TestFixture {
testling.setXMPPStatus("You are connected", MenuletController::Online);
CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(menulet->items.size()));
- int i = 0;
+ size_t i = 0;
CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string("[Online] You are connected"), menulet->items[i++]);
@@ -66,7 +66,7 @@ class MenuletControllerTest : public CppUnit::TestFixture {
testling.setXMPPStatus("You are connected", MenuletController::Online);
- int i = 0;
+ size_t i = 0;
CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string("[Online] You are connected"), menulet->items[i++]);
@@ -78,7 +78,7 @@ class MenuletControllerTest : public CppUnit::TestFixture {
testling.setXMPPStatus("You are not connected", MenuletController::Offline);
- int i = 0;
+ size_t i = 0;
CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string("[Offline] You are not connected"), menulet->items[i++]);
@@ -92,7 +92,7 @@ class MenuletControllerTest : public CppUnit::TestFixture {
users.push_back("The Mad Hatter");
testling.setUserNames(users);
- int i = 0;
+ size_t i = 0;
CPPUNIT_ASSERT_EQUAL(std::string("Online users:"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string(" Alice In Wonderland"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string(" The Mad Hatter"), menulet->items[i++]);
@@ -105,7 +105,7 @@ class MenuletControllerTest : public CppUnit::TestFixture {
std::vector<std::string> users;
testling.setUserNames(users);
- int i = 0;
+ size_t i = 0;
CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]);
CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]);
}
diff --git a/Sluift/sluift.cpp b/Sluift/sluift.cpp
index 51ba48d..0a653bb 100644
--- a/Sluift/sluift.cpp
+++ b/Sluift/sluift.cpp
@@ -758,7 +758,7 @@ static int sluift_sleep(lua_State *L) {
int timeout = boost::numeric_cast<int>(luaL_checknumber(L, 1));
Watchdog watchdog(timeout, networkFactories.getTimerFactory());
while (!watchdog.getTimedOut()) {
- Swift::sleep(std::min(100, timeout));
+ Swift::sleep(boost::numeric_cast<unsigned int>(std::min(100, timeout)));
eventLoop.runOnce();
}
return 0;
diff --git a/Swift/Controllers/FileTransfer/FileTransferController.cpp b/Swift/Controllers/FileTransfer/FileTransferController.cpp
index d4a082a..69b5c89 100644
--- a/Swift/Controllers/FileTransfer/FileTransferController.cpp
+++ b/Swift/Controllers/FileTransfer/FileTransferController.cpp
@@ -10,6 +10,7 @@
#include <Swiften/FileTransfer/FileReadBytestream.h>
#include <Swiften/Base/boost_bsignals.h>
#include <boost/bind.hpp>
+#include <boost/filesystem.hpp>
#include "Swift/Controllers/UIInterfaces/ChatWindow.h"
#include <Swiften/Base/Log.h>
#include <Swift/Controllers/Intl.h>
diff --git a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp
index 6d19fa1..3081f71 100644
--- a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp
+++ b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp
@@ -6,6 +6,8 @@
#include "FileTransferProgressInfo.h"
+#include <boost/numeric/conversion/cast.hpp>
+
#include <Swiften/Base/Log.h>
namespace Swift {
@@ -16,7 +18,7 @@ FileTransferProgressInfo::FileTransferProgressInfo(boost::uintmax_t completeByte
void FileTransferProgressInfo::setBytesProcessed(int processedBytes) {
int oldPercentage = int(double(completedBytes) / double(completeBytes) * 100.0);
- completedBytes += processedBytes;
+ completedBytes += boost::numeric_cast<boost::uintmax_t>(processedBytes);
int newPercentage = int(double(completedBytes) / double(completeBytes) * 100.0);
if (oldPercentage != newPercentage) {
onProgressPercentage(newPercentage);
diff --git a/Swift/Controllers/HighlightManager.cpp b/Swift/Controllers/HighlightManager.cpp
index 74a07c0..7ab578e 100644
--- a/Swift/Controllers/HighlightManager.cpp
+++ b/Swift/Controllers/HighlightManager.cpp
@@ -106,14 +106,14 @@ void HighlightManager::storeSettings()
HighlightRule HighlightManager::getRule(int index) const
{
- assert(index >= 0 && boost::numeric_cast<std::vector<std::string>::size_type>(index) < rules_.size());
- return rules_[index];
+ assert(index >= 0 && static_cast<size_t>(index) < rules_.size());
+ return rules_[static_cast<size_t>(index)];
}
void HighlightManager::setRule(int index, const HighlightRule& rule)
{
- assert(index >= 0 && boost::numeric_cast<std::vector<std::string>::size_type>(index) < rules_.size());
- rules_[index] = rule;
+ assert(index >= 0 && static_cast<size_t>(index) < rules_.size());
+ rules_[static_cast<size_t>(index)] = rule;
storeSettings();
}
diff --git a/Swift/Controllers/HighlightRule.cpp b/Swift/Controllers/HighlightRule.cpp
index 01d1228..28f26cf 100644
--- a/Swift/Controllers/HighlightRule.cpp
+++ b/Swift/Controllers/HighlightRule.cpp
@@ -88,7 +88,7 @@ HighlightRule HighlightRule::fromString(const std::string& s)
boost::split(v, s, boost::is_any_of("\n"));
HighlightRule r;
- int i = 0;
+ size_t i = 0;
try {
boost::split(r.senders_, v.at(i++), boost::is_any_of("\t"));
r.senders_.erase(std::remove_if(r.senders_.begin(), r.senders_.end(), boost::lambda::_1 == ""), r.senders_.end());
diff --git a/Swift/Controllers/Roster/LeastCommonSubsequence.h b/Swift/Controllers/Roster/LeastCommonSubsequence.h
index dd3c95a..9d45679 100644
--- a/Swift/Controllers/Roster/LeastCommonSubsequence.h
+++ b/Swift/Controllers/Roster/LeastCommonSubsequence.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Remko Tronçon
+ * Copyright (c) 2011-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -7,6 +7,7 @@
#pragma once
#include <vector>
+#include <boost/numeric/conversion/cast.hpp>
namespace Swift {
using std::equal_to;
@@ -14,8 +15,8 @@ namespace Swift {
namespace Detail {
template<typename XIt, typename YIt, typename Length, typename Predicate>
void computeLeastCommonSubsequenceMatrix(XIt xBegin, XIt xEnd, YIt yBegin, YIt yEnd, std::vector<Length>& result) {
- size_t width = std::distance(xBegin, xEnd) + 1;
- size_t height = std::distance(yBegin, yEnd) + 1;
+ size_t width = static_cast<size_t>(std::distance(xBegin, xEnd) + 1);
+ size_t height = static_cast<size_t>(std::distance(yBegin, yEnd) + 1);
result.resize(width * height);
// Initialize first row & column
@@ -30,7 +31,7 @@ namespace Swift {
Predicate predicate;
for (size_t i = 1; i < width; ++i) {
for (size_t j = 1; j < height; ++j) {
- result[i + j*width] = (predicate(*(xBegin + i-1), *(yBegin + j-1)) ? result[(i-1) + (j-1)*width] + 1 : std::max(result[i + (j-1)*width], result[i-1 + (j*width)]));
+ result[i + j*width] = predicate(*(xBegin + boost::numeric_cast<long long>(i)-1), *(yBegin + boost::numeric_cast<long long >(j)-1)) ? result[(i-1) + (j-1)*width] + 1 : std::max(result[i + (j-1)*width], result[i-1 + (j*width)]);
}
}
}
@@ -46,29 +47,29 @@ namespace Swift {
typename std::vector<X>::const_iterator yBegin = y.begin();
while (xBegin < x.end() && yBegin < y.end() && insertRemovePredicate(*xBegin, *yBegin)) {
if (updatePredicate(*xBegin, *yBegin)) {
- updates.push_back(std::distance(x.begin(), xBegin));
- postUpdates.push_back(std::distance(y.begin(), yBegin));
+ updates.push_back(static_cast<size_t>(std::distance(x.begin(), xBegin)));
+ postUpdates.push_back(static_cast<size_t>(std::distance(y.begin(), yBegin)));
}
++xBegin;
++yBegin;
}
- size_t prefixLength = std::distance(x.begin(), xBegin);
+ size_t prefixLength = static_cast<size_t>(std::distance(x.begin(), xBegin));
// Find & handle common suffix (Optimization to reduce LCS matrix size)
typename std::vector<X>::const_reverse_iterator xEnd = x.rbegin();
typename std::vector<X>::const_reverse_iterator yEnd = y.rbegin();
while (xEnd.base() > xBegin && yEnd.base() > yBegin && insertRemovePredicate(*xEnd, *yEnd)) {
if (updatePredicate(*xEnd, *yEnd)) {
- updates.push_back(std::distance(x.begin(), xEnd.base()) - 1);
- postUpdates.push_back(std::distance(y.begin(), yEnd.base()) - 1);
+ updates.push_back(static_cast<size_t>(std::distance(x.begin(), xEnd.base()) - 1));
+ postUpdates.push_back(static_cast<size_t>(std::distance(y.begin(), yEnd.base()) - 1));
}
++xEnd;
++yEnd;
}
// Compute lengths
- size_t xLength = std::distance(xBegin, xEnd.base());
- size_t yLength = std::distance(yBegin, yEnd.base());
+ size_t xLength = static_cast<size_t>(std::distance(xBegin, xEnd.base()));
+ size_t yLength = static_cast<size_t>(std::distance(yBegin, yEnd.base()));
// Compute LCS matrix
std::vector<unsigned int> lcs;
@@ -77,7 +78,7 @@ namespace Swift {
// Process LCS matrix
size_t i = xLength;
size_t j = yLength;
- const size_t width = xLength + 1;
+ size_t width = xLength + 1;
while (true) {
if (i > 0 && j > 0 && insertRemovePredicate(x[prefixLength + i-1], y[prefixLength + j-1])) {
// x[i-1] same
diff --git a/Swift/Controllers/Roster/TableRoster.cpp b/Swift/Controllers/Roster/TableRoster.cpp
index c00bf4f..eb036db 100644
--- a/Swift/Controllers/Roster/TableRoster.cpp
+++ b/Swift/Controllers/Roster/TableRoster.cpp
@@ -9,6 +9,7 @@
#include <boost/cast.hpp>
#include <cassert>
#include <algorithm>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Network/TimerFactory.h>
@@ -132,13 +133,13 @@ void TableRoster::handleUpdateTimerTick() {
computeIndexDiff<Item, ItemEquals, ItemNeedsUpdate >(sections[sectionUpdates[i]].items, newSections[sectionPostUpdates[i]].items, itemUpdates, itemPostUpdates, itemRemoves, itemInserts);
size_t end = update.insertedRows.size();
update.insertedRows.resize(update.insertedRows.size() + itemInserts.size());
- std::transform(itemInserts.begin(), itemInserts.end(), update.insertedRows.begin() + end, CreateIndexForSection(sectionPostUpdates[i]));
+ std::transform(itemInserts.begin(), itemInserts.end(), update.insertedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i]));
end = update.deletedRows.size();
update.deletedRows.resize(update.deletedRows.size() + itemRemoves.size());
- std::transform(itemRemoves.begin(), itemRemoves.end(), update.deletedRows.begin() + end, CreateIndexForSection(sectionUpdates[i]));
+ std::transform(itemRemoves.begin(), itemRemoves.end(), update.deletedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionUpdates[i]));
end = update.updatedRows.size();
update.updatedRows.resize(update.updatedRows.size() + itemUpdates.size());
- std::transform(itemUpdates.begin(), itemUpdates.end(), update.updatedRows.begin() + end, CreateIndexForSection(sectionPostUpdates[i]));
+ std::transform(itemUpdates.begin(), itemUpdates.end(), update.updatedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i]));
}
// Switch the old model with the new
diff --git a/Swift/Controllers/Storages/CertificateFileStorage.cpp b/Swift/Controllers/Storages/CertificateFileStorage.cpp
index a4a95c7..55016d5 100644
--- a/Swift/Controllers/Storages/CertificateFileStorage.cpp
+++ b/Swift/Controllers/Storages/CertificateFileStorage.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.
*/
@@ -8,6 +8,7 @@
#include <iostream>
#include <boost/filesystem/fstream.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/StringCodecs/SHA1.h>
#include <Swiften/StringCodecs/Hexify.h>
@@ -50,7 +51,7 @@ void CertificateFileStorage::addCertificate(Certificate::ref certificate) {
}
boost::filesystem::ofstream file(certificatePath, boost::filesystem::ofstream::binary|boost::filesystem::ofstream::out);
ByteArray data = certificate->toDER();
- file.write(reinterpret_cast<const char*>(vecptr(data)), data.size());
+ file.write(reinterpret_cast<const char*>(vecptr(data)), boost::numeric_cast<std::streamsize>(data.size()));
file.close();
}
diff --git a/Swiften/Base/ByteArray.cpp b/Swiften/Base/ByteArray.cpp
index 6be96aa..d6b5c97 100644
--- a/Swiften/Base/ByteArray.cpp
+++ b/Swiften/Base/ByteArray.cpp
@@ -1,11 +1,12 @@
/*
- * 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.
*/
#include <Swiften/Base/ByteArray.h>
+#include <boost/numeric/conversion/cast.hpp>
#include <fstream>
namespace Swift {
@@ -18,7 +19,7 @@ void readByteArrayFromFile(ByteArray& data, const std::string& file) {
size_t oldSize = data.size();
data.resize(oldSize + BUFFER_SIZE);
input.read(reinterpret_cast<char*>(&data[oldSize]), BUFFER_SIZE);
- data.resize(oldSize + input.gcount());
+ data.resize(oldSize + boost::numeric_cast<size_t>(input.gcount()));
}
input.close();
}
diff --git a/Swiften/Base/ByteArray.h b/Swiften/Base/ByteArray.h
index 34b89d3..8688aab 100644
--- a/Swiften/Base/ByteArray.h
+++ b/Swiften/Base/ByteArray.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.
*/
@@ -26,7 +26,7 @@ namespace Swift {
}
inline ByteArray createByteArray(char c) {
- return std::vector<unsigned char>(1, c);
+ return std::vector<unsigned char>(1, static_cast<unsigned char>(c));
}
template<typename T, typename A>
diff --git a/Swiften/Base/SafeByteArray.h b/Swiften/Base/SafeByteArray.h
index dda51fe..b85373c 100644
--- a/Swiften/Base/SafeByteArray.h
+++ b/Swiften/Base/SafeByteArray.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Remko Tronçon
+ * Copyright (c) 2011-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -31,7 +31,7 @@ namespace Swift {
}
inline SafeByteArray createSafeByteArray(char c) {
- return SafeByteArray(1, c);
+ return SafeByteArray(1, static_cast<unsigned char>(c));
}
inline SafeByteArray createSafeByteArray(const char* c, size_t n) {
diff --git a/Swiften/Compress/ZLibCodecompressor.cpp b/Swiften/Compress/ZLibCodecompressor.cpp
index 01f1451..85d0174 100644
--- a/Swiften/Compress/ZLibCodecompressor.cpp
+++ b/Swiften/Compress/ZLibCodecompressor.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.
*/
@@ -9,13 +9,14 @@
#include <cassert>
#include <string.h>
#include <zlib.h>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Compress/ZLibException.h>
#include <Swiften/Compress/ZLibCodecompressor_Private.h>
namespace Swift {
-static const int CHUNK_SIZE = 1024; // If you change this, also change the unittest
+static const size_t CHUNK_SIZE = 1024; // If you change this, also change the unittest
ZLibCodecompressor::ZLibCodecompressor() : p(boost::make_shared<Private>()) {
@@ -32,7 +33,7 @@ SafeByteArray ZLibCodecompressor::process(const SafeByteArray& input) {
SafeByteArray output;
p->stream.avail_in = static_cast<unsigned int>(input.size());
p->stream.next_in = reinterpret_cast<Bytef*>(const_cast<unsigned char*>(vecptr(input)));
- int outputPosition = 0;
+ size_t outputPosition = 0;
do {
output.resize(outputPosition + CHUNK_SIZE);
p->stream.avail_out = CHUNK_SIZE;
diff --git a/Swiften/Elements/JingleIBBTransportPayload.h b/Swiften/Elements/JingleIBBTransportPayload.h
index 8c174f0..7633f6b 100644
--- a/Swiften/Elements/JingleIBBTransportPayload.h
+++ b/Swiften/Elements/JingleIBBTransportPayload.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Remko Tronçon
+ * Copyright (c) 2011-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -29,16 +29,16 @@ namespace Swift {
return stanzaType;
}
- int getBlockSize() const {
+ unsigned int getBlockSize() const {
return blockSize;
}
- void setBlockSize(int blockSize) {
+ void setBlockSize(unsigned int blockSize) {
this->blockSize = blockSize;
}
private:
- int blockSize;
+ unsigned int blockSize;
StanzaType stanzaType;
};
}
diff --git a/Swiften/Elements/JinglePayload.h b/Swiften/Elements/JinglePayload.h
index 31d4448..5f12e90 100644
--- a/Swiften/Elements/JinglePayload.h
+++ b/Swiften/Elements/JinglePayload.h
@@ -15,8 +15,6 @@
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/JingleContentPayload.h>
-#include <Swiften/Base/Log.h>
-
namespace Swift {
class JinglePayload : public Payload {
public:
diff --git a/Swiften/Elements/StanzaAck.cpp b/Swiften/Elements/StanzaAck.cpp
new file mode 100644
index 0000000..5bcab73
--- /dev/null
+++ b/Swiften/Elements/StanzaAck.cpp
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Elements/StanzaAck.h>
+
+#include <boost/numeric/conversion/cast.hpp>
+
+using namespace Swift;
+
+StanzaAck::~StanzaAck() {
+}
+
+void StanzaAck::setHandledStanzasCount(int i) {
+ handledStanzasCount = boost::numeric_cast<unsigned int>(i);
+ valid = true;
+}
diff --git a/Swiften/Elements/StanzaAck.h b/Swiften/Elements/StanzaAck.h
index 3aa2dfd..8fe64e0 100644
--- a/Swiften/Elements/StanzaAck.h
+++ b/Swiften/Elements/StanzaAck.h
@@ -1,13 +1,14 @@
/*
- * 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.
*/
#pragma once
-#include <Swiften/Elements/Element.h>
+#include <boost/shared_ptr.hpp>
+#include <Swiften/Elements/Element.h>
namespace Swift {
class StanzaAck : public Element {
@@ -16,15 +17,13 @@ namespace Swift {
StanzaAck() : valid(false), handledStanzasCount(0) {}
StanzaAck(unsigned int handledStanzasCount) : valid(true), handledStanzasCount(handledStanzasCount) {}
+ virtual ~StanzaAck();
unsigned int getHandledStanzasCount() const {
return handledStanzasCount;
}
- void setHandledStanzasCount(int i) {
- handledStanzasCount = i;
- valid = true;
- }
+ void setHandledStanzasCount(int i);
bool isValid() const {
return valid;
diff --git a/Swiften/Elements/StreamInitiationFileInfo.h b/Swiften/Elements/StreamInitiationFileInfo.h
index 4265a19..d7907b9 100644
--- a/Swiften/Elements/StreamInitiationFileInfo.h
+++ b/Swiften/Elements/StreamInitiationFileInfo.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Remko Tronçon
+ * Copyright (c) 2011-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -19,7 +19,7 @@ public:
typedef boost::shared_ptr<StreamInitiationFileInfo> ref;
public:
- StreamInitiationFileInfo(const std::string& name = "", const std::string& description = "", int size = 0,
+ StreamInitiationFileInfo(const std::string& name = "", const std::string& description = "", unsigned long long size = 0,
const std::string& hash = "", const boost::posix_time::ptime &date = boost::posix_time::ptime(), const std::string& algo="md5") :
name(name), description(description), size(size), hash(hash), date(date), algo(algo), supportsRangeRequests(false), rangeOffset(0) {}
@@ -39,11 +39,11 @@ public:
return this->description;
}
- void setSize(const boost::uintmax_t size) {
+ void setSize(const unsigned long long size) {
this->size = size;
}
- boost::uintmax_t getSize() const {
+ unsigned long long getSize() const {
return this->size;
}
@@ -79,24 +79,24 @@ public:
return supportsRangeRequests;
}
- void setRangeOffset(boost::uintmax_t offset) {
+ void setRangeOffset(unsigned long long offset) {
supportsRangeRequests = true;
rangeOffset = offset;
}
- boost::uintmax_t getRangeOffset() const {
+ unsigned long long getRangeOffset() const {
return rangeOffset;
}
private:
std::string name;
std::string description;
- boost::uintmax_t size;
+ unsigned long long size;
std::string hash;
boost::posix_time::ptime date;
std::string algo;
bool supportsRangeRequests;
- boost::uintmax_t rangeOffset;
+ unsigned long long rangeOffset;
};
}
diff --git a/Swiften/Examples/SendFile/ReceiveFile.cpp b/Swiften/Examples/SendFile/ReceiveFile.cpp
index bc40a5b..8b0af37 100644
--- a/Swiften/Examples/SendFile/ReceiveFile.cpp
+++ b/Swiften/Examples/SendFile/ReceiveFile.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.
*/
@@ -10,6 +10,7 @@
#include <iostream>
#include <Swiften/Elements/Presence.h>
+#include <Swiften/Base/Log.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Client/Client.h>
#include <Swiften/Elements/DiscoInfo.h>
diff --git a/Swiften/Examples/SendFile/SendFile.cpp b/Swiften/Examples/SendFile/SendFile.cpp
index 17489de..657949b 100644
--- a/Swiften/Examples/SendFile/SendFile.cpp
+++ b/Swiften/Examples/SendFile/SendFile.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.
*/
@@ -11,6 +11,7 @@
#include <Swiften/Client/Client.h>
#include <Swiften/Elements/Presence.h>
+#include <Swiften/Base/Log.h>
#include <Swiften/Network/BoostTimer.h>
#include <Swiften/Network/TimerFactory.h>
#include <Swiften/Network/BoostNetworkFactories.h>
diff --git a/Swiften/FileTransfer/ByteArrayReadBytestream.cpp b/Swiften/FileTransfer/ByteArrayReadBytestream.cpp
new file mode 100644
index 0000000..4ba791f
--- /dev/null
+++ b/Swiften/FileTransfer/ByteArrayReadBytestream.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010-2013 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/FileTransfer/ByteArrayReadBytestream.h>
+
+#include <boost/smart_ptr/make_shared.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <Swiften/Base/Algorithm.h>
+
+using namespace Swift;
+
+boost::shared_ptr<ByteArray> ByteArrayReadBytestream::read(size_t size) {
+ size_t readSize = size;
+ if (position + readSize > data.size()) {
+ readSize = data.size() - position;
+ }
+ boost::shared_ptr<ByteArray> result = boost::make_shared<ByteArray>(
+ data.begin() + boost::numeric_cast<long long>(position),
+ data.begin() + boost::numeric_cast<long long>(position) + boost::numeric_cast<long long>(readSize));
+
+ onRead(*result);
+ position += readSize;
+ return result;
+}
+
+void ByteArrayReadBytestream::addData(const std::vector<unsigned char>& moreData) {
+ append(data, moreData);
+ onDataAvailable();
+}
diff --git a/Swiften/FileTransfer/ByteArrayReadBytestream.h b/Swiften/FileTransfer/ByteArrayReadBytestream.h
index 9311099..664698a 100644
--- a/Swiften/FileTransfer/ByteArrayReadBytestream.h
+++ b/Swiften/FileTransfer/ByteArrayReadBytestream.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.
*/
@@ -7,9 +7,7 @@
#pragma once
#include <vector>
-#include <boost/smart_ptr/make_shared.hpp>
-#include <Swiften/Base/Algorithm.h>
#include <Swiften/FileTransfer/ReadBytestream.h>
#include <Swiften/Base/ByteArray.h>
@@ -19,17 +17,7 @@ namespace Swift {
ByteArrayReadBytestream(const std::vector<unsigned char>& data) : data(data), position(0), dataComplete(true) {
}
- virtual boost::shared_ptr<ByteArray> read(size_t size) {
- size_t readSize = size;
- if (position + readSize > data.size()) {
- readSize = data.size() - position;
- }
- boost::shared_ptr<ByteArray> result = boost::make_shared<ByteArray>(data.begin() + position, data.begin() + position + readSize);
-
- onRead(*result);
- position += readSize;
- return result;
- }
+ virtual boost::shared_ptr<ByteArray> read(size_t size);
virtual bool isFinished() const {
return position >= data.size() && dataComplete;
@@ -39,10 +27,7 @@ namespace Swift {
dataComplete = b;
}
- void addData(const std::vector<unsigned char>& moreData) {
- append(data, moreData);
- onDataAvailable();
- }
+ void addData(const std::vector<unsigned char>& moreData);
private:
std::vector<unsigned char> data;
diff --git a/Swiften/FileTransfer/FileReadBytestream.cpp b/Swiften/FileTransfer/FileReadBytestream.cpp
index a8946a0..4257f8b 100644
--- a/Swiften/FileTransfer/FileReadBytestream.cpp
+++ b/Swiften/FileTransfer/FileReadBytestream.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.
*/
@@ -7,6 +7,7 @@
#include <boost/filesystem/fstream.hpp>
#include <cassert>
#include <boost/smart_ptr/make_shared.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/FileTransfer/FileReadBytestream.h>
#include <Swiften/Base/ByteArray.h>
@@ -30,8 +31,8 @@ boost::shared_ptr<ByteArray> FileReadBytestream::read(size_t size) {
boost::shared_ptr<ByteArray> result = boost::make_shared<ByteArray>();
result->resize(size);
assert(stream->good());
- stream->read(reinterpret_cast<char*>(vecptr(*result)), size);
- result->resize(stream->gcount());
+ stream->read(reinterpret_cast<char*>(vecptr(*result)), boost::numeric_cast<std::streamsize>(size));
+ result->resize(boost::numeric_cast<size_t>(stream->gcount()));
onRead(*result);
return result;
}
diff --git a/Swiften/FileTransfer/FileTransferManager.h b/Swiften/FileTransfer/FileTransferManager.h
index 30d9faf..68f3d0d 100644
--- a/Swiften/FileTransfer/FileTransferManager.h
+++ b/Swiften/FileTransfer/FileTransferManager.h
@@ -7,7 +7,7 @@
#pragma once
#include <string>
-#include <boost/filesystem.hpp>
+#include <boost/filesystem/path.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <Swiften/Base/API.h>
diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.cpp b/Swiften/FileTransfer/FileTransferManagerImpl.cpp
index 84b2061..d5d4aaf 100644
--- a/Swiften/FileTransfer/FileTransferManagerImpl.cpp
+++ b/Swiften/FileTransfer/FileTransferManagerImpl.cpp
@@ -7,9 +7,11 @@
#include <Swiften/FileTransfer/FileTransferManagerImpl.h>
#include <boost/bind.hpp>
+#include <boost/filesystem.hpp>
#include <boost/cstdint.hpp>
#include <Swiften/Base/foreach.h>
+#include <Swiften/Base/Log.h>
#include "Swiften/Disco/EntityCapsProvider.h"
#include <Swiften/JID/JID.h>
#include <Swiften/Elements/StreamInitiationFileInfo.h>
diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.h b/Swiften/FileTransfer/FileTransferManagerImpl.h
index ecc692d..0bbbf31 100644
--- a/Swiften/FileTransfer/FileTransferManagerImpl.h
+++ b/Swiften/FileTransfer/FileTransferManagerImpl.h
@@ -9,7 +9,7 @@
#include <vector>
#include <string>
-#include <boost/filesystem.hpp>
+#include <boost/filesystem/path.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/optional.hpp>
diff --git a/Swiften/FileTransfer/FileWriteBytestream.cpp b/Swiften/FileTransfer/FileWriteBytestream.cpp
index 6a22c6a..5725e18 100644
--- a/Swiften/FileTransfer/FileWriteBytestream.cpp
+++ b/Swiften/FileTransfer/FileWriteBytestream.cpp
@@ -1,11 +1,12 @@
/*
- * 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.
*/
#include <boost/filesystem/fstream.hpp>
#include <cassert>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/FileTransfer/FileWriteBytestream.h>
@@ -26,7 +27,7 @@ void FileWriteBytestream::write(const std::vector<unsigned char>& data) {
stream = new boost::filesystem::ofstream(file, std::ios_base::out|std::ios_base::binary);
}
assert(stream->good());
- stream->write(reinterpret_cast<const char*>(&data[0]), data.size());
+ stream->write(reinterpret_cast<const char*>(&data[0]), boost::numeric_cast<std::streamsize>(data.size()));
onWrite(data);
}
diff --git a/Swiften/FileTransfer/IBBSendSession.cpp b/Swiften/FileTransfer/IBBSendSession.cpp
index c24cc0a..4d7477f 100644
--- a/Swiften/FileTransfer/IBBSendSession.cpp
+++ b/Swiften/FileTransfer/IBBSendSession.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.
*/
@@ -7,6 +7,7 @@
#include <Swiften/FileTransfer/IBBSendSession.h>
#include <boost/bind.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Queries/IQRouter.h>
@@ -24,7 +25,7 @@ IBBSendSession::~IBBSendSession() {
}
void IBBSendSession::start() {
- IBBRequest::ref request = IBBRequest::create(from, to, IBB::createIBBOpen(id, blockSize), router);
+ IBBRequest::ref request = IBBRequest::create(from, to, IBB::createIBBOpen(id, boost::numeric_cast<int>(blockSize)), router);
request->onResponse.connect(boost::bind(&IBBSendSession::handleIBBResponse, this, _1, _2));
active = true;
request->send();
diff --git a/Swiften/FileTransfer/IBBSendSession.h b/Swiften/FileTransfer/IBBSendSession.h
index 8584d38..dcda11f 100644
--- a/Swiften/FileTransfer/IBBSendSession.h
+++ b/Swiften/FileTransfer/IBBSendSession.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.
*/
@@ -36,7 +36,7 @@ namespace Swift {
return to;
}
- void setBlockSize(int blockSize) {
+ void setBlockSize(unsigned int blockSize) {
this->blockSize = blockSize;
}
@@ -55,7 +55,7 @@ namespace Swift {
JID to;
boost::shared_ptr<ReadBytestream> bytestream;
IQRouter* router;
- int blockSize;
+ unsigned int blockSize;
int sequenceNumber;
bool active;
bool waitingForData;
diff --git a/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp b/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
index fc0a551..5e93343 100644
--- a/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
+++ b/Swiften/FileTransfer/OutgoingSIFileTransfer.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.
*/
@@ -16,7 +16,7 @@
namespace Swift {
-OutgoingSIFileTransfer::OutgoingSIFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, int size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer) : id(id), from(from), to(to), name(name), size(size), description(description), bytestream(bytestream), iqRouter(iqRouter), socksServer(socksServer) {
+OutgoingSIFileTransfer::OutgoingSIFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, unsigned long long size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer) : id(id), from(from), to(to), name(name), size(size), description(description), bytestream(bytestream), iqRouter(iqRouter), socksServer(socksServer) {
}
void OutgoingSIFileTransfer::start() {
diff --git a/Swiften/FileTransfer/OutgoingSIFileTransfer.h b/Swiften/FileTransfer/OutgoingSIFileTransfer.h
index 584eb60..79da339 100644
--- a/Swiften/FileTransfer/OutgoingSIFileTransfer.h
+++ b/Swiften/FileTransfer/OutgoingSIFileTransfer.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.
*/
@@ -25,7 +25,7 @@ namespace Swift {
class OutgoingSIFileTransfer : public OutgoingFileTransfer {
public:
- OutgoingSIFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, int size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer);
+ OutgoingSIFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, unsigned long long size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer);
virtual void start();
virtual void stop();
@@ -43,7 +43,7 @@ namespace Swift {
JID from;
JID to;
std::string name;
- int size;
+ unsigned long long size;
std::string description;
boost::shared_ptr<ReadBytestream> bytestream;
IQRouter* iqRouter;
diff --git a/Swiften/FileTransfer/SConscript b/Swiften/FileTransfer/SConscript
index 4e79992..8d98477 100644
--- a/Swiften/FileTransfer/SConscript
+++ b/Swiften/FileTransfer/SConscript
@@ -1,6 +1,7 @@
Import("swiften_env", "env")
sources = [
+ "ByteArrayReadBytestream.cpp",
"OutgoingFileTransfer.cpp",
"OutgoingSIFileTransfer.cpp",
"OutgoingJingleFileTransfer.cpp",
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
index b167663..1b3399f 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
@@ -166,7 +166,7 @@ HostAddressPort SOCKS5BytestreamClientSession::getAddressPort() const {
void SOCKS5BytestreamClientSession::sendData() {
if (!readBytestream->isFinished()) {
try {
- boost::shared_ptr<ByteArray> dataToSend = readBytestream->read(chunkSize);
+ boost::shared_ptr<ByteArray> dataToSend = readBytestream->read(boost::numeric_cast<size_t>(chunkSize));
connection->write(createSafeByteArray(*dataToSend));
onBytesSent(dataToSend->size());
}
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
index e0e6044..7521822 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.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.
*/
@@ -134,7 +134,7 @@ void SOCKS5BytestreamServerSession::process() {
SafeByteArray result = createSafeByteArray("\x05", 1);
result.push_back((readBytestream || writeBytestream) ? 0x0 : 0x4);
append(result, createByteArray("\x00\x03", 2));
- result.push_back(static_cast<char>(requestID.size()));
+ result.push_back(boost::numeric_cast<unsigned char>(requestID.size()));
append(result, concat(requestID, createByteArray("\x00\x00", 2)));
if (!readBytestream && !writeBytestream) {
SWIFT_LOG(debug) << "Readstream or Wrtiestream with ID " << streamID << " not found!" << std::endl;
@@ -160,7 +160,7 @@ void SOCKS5BytestreamServerSession::process() {
void SOCKS5BytestreamServerSession::sendData() {
if (!readBytestream->isFinished()) {
try {
- SafeByteArray dataToSend = createSafeByteArray(*readBytestream->read(chunkSize));
+ SafeByteArray dataToSend = createSafeByteArray(*readBytestream->read(boost::numeric_cast<size_t>(chunkSize)));
if (!dataToSend.empty()) {
connection->write(dataToSend);
onBytesSent(dataToSend.size());
diff --git a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h
index ae06cd3..9975a67 100644
--- a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h
+++ b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h
@@ -7,7 +7,7 @@
#pragma once
#include <string>
-#include <boost/filesystem.hpp>
+#include <boost/filesystem/path.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <Swiften/FileTransfer/FileTransferManager.h>
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
index 6781de8..502cf2d 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
@@ -205,7 +205,7 @@ private:
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > randomByte(randomGen, dist);
ByteArray result(len);
for (size_t i=0; i < len; ++i ) {
- result[i] = static_cast<char>(randomByte());
+ result[i] = static_cast<unsigned char>(randomByte());
}
return result;
}
diff --git a/Swiften/JID/JID.cpp b/Swiften/JID/JID.cpp
index 0822595..1bdf390 100644
--- a/Swiften/JID/JID.cpp
+++ b/Swiften/JID/JID.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.
*/
@@ -18,6 +18,7 @@
#include <boost/assign/list_of.hpp>
#include <boost/algorithm/string/find_format.hpp>
#include <boost/algorithm/string/finder.hpp>
+#include <iostream>
#include <sstream>
#include <Swiften/Base/String.h>
@@ -111,6 +112,8 @@ struct EscapedCharacterFormatter {
};
#endif
+namespace Swift {
+
JID::JID(const char* jid) : valid_(true) {
initializeFromString(std::string(jid));
}
@@ -270,3 +273,10 @@ std::string JID::getUnescapedNode() const {
return result;
//return boost::find_format_all_copy(node_, EscapedCharacterFinder(), EscapedCharacterFormatter());
}
+
+std::ostream& operator<<(std::ostream& os, const JID& j) {
+ os << j.toString();
+ return os;
+}
+
+}
diff --git a/Swiften/JID/JID.h b/Swiften/JID/JID.h
index 08309d3..3ccf7de 100644
--- a/Swiften/JID/JID.h
+++ b/Swiften/JID/JID.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.
*/
@@ -7,11 +7,11 @@
#pragma once
#include <string>
-//#include <iosfwd>
-#include <iostream>
+#include <iosfwd>
#include <Swiften/Base/API.h>
+
namespace Swift {
/**
* This represents the JID used in XMPP
@@ -146,10 +146,7 @@ namespace Swift {
return compare(b, Swift::JID::WithResource) < 0;
}
- friend std::ostream& operator<<(std::ostream& os, const Swift::JID& j) {
- os << j.toString();
- return os;
- }
+ friend std::ostream& operator<<(std::ostream& os, const Swift::JID& j);
friend bool operator==(const Swift::JID& a, const Swift::JID& b) {
return a.compare(b, Swift::JID::WithResource) == 0;
@@ -170,4 +167,7 @@ namespace Swift {
bool hasResource_;
std::string resource_;
};
+
+ std::ostream& operator<<(std::ostream& os, const Swift::JID& j);
}
+
diff --git a/Swiften/Jingle/JingleSessionManager.cpp b/Swiften/Jingle/JingleSessionManager.cpp
index 2e15fcd..f31ddb8 100644
--- a/Swiften/Jingle/JingleSessionManager.cpp
+++ b/Swiften/Jingle/JingleSessionManager.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Remko Tronçon
+ * Copyright (c) 2011-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -7,6 +7,7 @@
#include <Swiften/Jingle/JingleSessionManager.h>
#include <Swiften/Jingle/JingleResponder.h>
#include <Swiften/Jingle/IncomingJingleSessionHandler.h>
+#include <Swiften/Base/Log.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Base/Algorithm.h>
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
index 6e79290..52d6654 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.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.
*/
@@ -9,6 +9,7 @@
#include <Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.h>
#include <Swiften/LinkLocal/DNSSD/DNSSDBrowseQuery.h>
#include <Swiften/EventLoop/EventLoop.h>
+#include <boost/numeric/conversion/cast.hpp>
namespace Swift {
class BonjourQuerier;
@@ -48,7 +49,7 @@ namespace Swift {
}
else {
//std::cout << "Discovered service: name:" << name << " domain:" << domain << " type: " << type << std::endl;
- DNSSDServiceID service(name, domain, type, interfaceIndex);
+ DNSSDServiceID service(name, domain, type, boost::numeric_cast<int>(interfaceIndex));
if (flags & kDNSServiceFlagsAdd) {
eventLoop->postEvent(boost::bind(boost::ref(onServiceAdded), service), shared_from_this());
}
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h
index 9fdd3d5..59d1af5 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.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.
*/
@@ -13,6 +13,7 @@
#include <Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h>
#include <Swiften/EventLoop/EventLoop.h>
#include <Swiften/Network/HostAddress.h>
+#include <boost/numeric/conversion/cast.hpp>
#include <netinet/in.h>
@@ -23,7 +24,7 @@ namespace Swift {
public:
BonjourResolveHostnameQuery(const std::string& hostname, int interfaceIndex, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) {
DNSServiceErrorType result = DNSServiceGetAddrInfo(
- &sdRef, 0, interfaceIndex, kDNSServiceProtocol_IPv4,
+ &sdRef, 0, boost::numeric_cast<unsigned int>(interfaceIndex), kDNSServiceProtocol_IPv4,
hostname.c_str(),
&BonjourResolveHostnameQuery::handleHostnameResolvedStatic, this);
if (result != kDNSServiceErr_NoError) {
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h
index 1fb050c..2eeac64 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.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.
*/
@@ -19,7 +19,7 @@ namespace Swift {
public:
BonjourResolveServiceQuery(const DNSSDServiceID& service, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) {
DNSServiceErrorType result = DNSServiceResolve(
- &sdRef, 0, service.getNetworkInterfaceID(),
+ &sdRef, 0, boost::numeric_cast<unsigned int>(service.getNetworkInterfaceID()),
service.getName().c_str(), service.getType().c_str(),
service.getDomain().c_str(),
&BonjourResolveServiceQuery::handleServiceResolvedStatic, this);
diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
index 19e0249..7e18315 100644
--- a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
+++ b/Swiften/LinkLocal/LinkLocalServiceInfo.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.
*/
@@ -110,11 +110,11 @@ std::pair<std::string,std::string> LinkLocalServiceInfo::readEntry(const ByteArr
inKey = false;
}
else {
- key += record[i];
+ key += static_cast<char>(record[i]);
}
}
else {
- value += record[i];
+ value += static_cast<char>(record[i]);
}
++i;
}
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;
diff --git a/Swiften/Parser/BOSHBodyExtractor.cpp b/Swiften/Parser/BOSHBodyExtractor.cpp
index eeebe8a..715a448 100644
--- a/Swiften/Parser/BOSHBodyExtractor.cpp
+++ b/Swiften/Parser/BOSHBodyExtractor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Remko Tronçon
+ * Copyright (c) 2011-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -7,6 +7,7 @@
#include <Swiften/Parser/BOSHBodyExtractor.h>
#include <boost/shared_ptr.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Parser/XMLParserClient.h>
#include <Swiften/Parser/XMLParser.h>
@@ -33,7 +34,7 @@ class BOSHBodyParserClient : public XMLParserClient {
BOSHBodyExtractor* bodyExtractor;
};
-inline bool isWhitespace(char c) {
+inline bool isWhitespace(unsigned char c) {
return c == ' ' || c == '\n' || c == '\t' || c == '\r';
}
@@ -117,13 +118,17 @@ BOSHBodyExtractor::BOSHBodyExtractor(XMLParserFactory* parserFactory, const Byte
body = BOSHBody();
if (!endElementSeen) {
- body->content = std::string(reinterpret_cast<const char*>(vecptr(data) + std::distance(data.begin(), i)), std::distance(i, j.base()));
+ body->content = std::string(
+ reinterpret_cast<const char*>(vecptr(data) + std::distance(data.begin(), i)),
+ boost::numeric_cast<size_t>(std::distance(i, j.base())));
}
// Parse the body element
BOSHBodyParserClient parserClient(this);
boost::shared_ptr<XMLParser> parser(parserFactory->createXMLParser(&parserClient));
- if (!parser->parse(std::string(reinterpret_cast<const char*>(vecptr(data)), std::distance(data.begin(), i)))) {
+ if (!parser->parse(std::string(
+ reinterpret_cast<const char*>(vecptr(data)),
+ boost::numeric_cast<size_t>(std::distance(data.begin(), i))))) {
/* TODO: This needs to be only validating the BOSH <body> element, so that XMPP parsing errors are caught at
the correct higher layer */
body = boost::optional<BOSHBody>();
diff --git a/Swiften/Parser/ExpatParser.cpp b/Swiften/Parser/ExpatParser.cpp
index 2483920..8b7bf82 100644
--- a/Swiften/Parser/ExpatParser.cpp
+++ b/Swiften/Parser/ExpatParser.cpp
@@ -55,7 +55,8 @@ static void handleEndElement(void* parser, const XML_Char* name) {
}
static void handleCharacterData(void* parser, const XML_Char* data, int len) {
- static_cast<XMLParser*>(parser)->getClient()->handleCharacterData(std::string(data, len));
+ assert(len >= 0);
+ static_cast<XMLParser*>(parser)->getClient()->handleCharacterData(std::string(data, static_cast<size_t>(len)));
}
static void handleXMLDeclaration(void*, const XML_Char*, const XML_Char*, int) {
diff --git a/Swiften/Parser/LibXMLParser.cpp b/Swiften/Parser/LibXMLParser.cpp
index 74ee051..e4938e1 100644
--- a/Swiften/Parser/LibXMLParser.cpp
+++ b/Swiften/Parser/LibXMLParser.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.
*/
@@ -33,7 +33,11 @@ static void handleStartElement(void* parser, const xmlChar* name, const xmlChar*
if (attributes[i+2]) {
attributeNS = std::string(reinterpret_cast<const char*>(attributes[i+2]));
}
- attributeValues.addAttribute(std::string(reinterpret_cast<const char*>(attributes[i])), attributeNS, std::string(reinterpret_cast<const char*>(attributes[i+3]), attributes[i+4]-attributes[i+3]));
+ attributeValues.addAttribute(
+ std::string(reinterpret_cast<const char*>(attributes[i])),
+ attributeNS,
+ std::string(reinterpret_cast<const char*>(attributes[i+3]),
+ boost::numeric_cast<size_t>(attributes[i+4]-attributes[i+3])));
}
static_cast<XMLParser*>(parser)->getClient()->handleStartElement(reinterpret_cast<const char*>(name), (xmlns ? reinterpret_cast<const char*>(xmlns) : std::string()), attributeValues);
}
@@ -43,7 +47,7 @@ static void handleEndElement(void *parser, const xmlChar* name, const xmlChar*,
}
static void handleCharacterData(void* parser, const xmlChar* data, int len) {
- static_cast<XMLParser*>(parser)->getClient()->handleCharacterData(std::string(reinterpret_cast<const char*>(data), len));
+ static_cast<XMLParser*>(parser)->getClient()->handleCharacterData(std::string(reinterpret_cast<const char*>(data), boost::numeric_cast<size_t>(len)));
}
static void handleError(void*, const char* /*m*/, ... ) {
@@ -87,7 +91,7 @@ LibXMLParser::~LibXMLParser() {
}
bool LibXMLParser::parse(const std::string& data) {
- if (xmlParseChunk(p->context_, data.c_str(), boost::numeric_cast<unsigned int>(data.size()), false) == XML_ERR_OK) {
+ if (xmlParseChunk(p->context_, data.c_str(), boost::numeric_cast<int>(data.size()), false) == XML_ERR_OK) {
return true;
}
xmlError* error = xmlCtxtGetLastError(p->context_);
diff --git a/Swiften/Parser/PayloadParsers/JingleIBBTransportMethodPayloadParser.cpp b/Swiften/Parser/PayloadParsers/JingleIBBTransportMethodPayloadParser.cpp
index a3dfd12..cfdccf9 100644
--- a/Swiften/Parser/PayloadParsers/JingleIBBTransportMethodPayloadParser.cpp
+++ b/Swiften/Parser/PayloadParsers/JingleIBBTransportMethodPayloadParser.cpp
@@ -18,7 +18,7 @@ namespace Swift {
void JingleIBBTransportMethodPayloadParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attributes) {
try {
- getPayloadInternal()->setBlockSize(boost::lexical_cast<int>(attributes.getAttributeValue("block-size").get_value_or("0")));
+ getPayloadInternal()->setBlockSize(boost::lexical_cast<unsigned int>(attributes.getAttributeValue("block-size").get_value_or("0")));
} catch (boost::bad_lexical_cast &) {
getPayloadInternal()->setBlockSize(0);
}
diff --git a/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp b/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp
index fd3d019..20bad8c 100644
--- a/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp
+++ b/Swiften/Parser/PayloadParsers/StreamInitiationParser.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.
*/
@@ -40,7 +40,7 @@ void StreamInitiationParser::handleStartElement(const std::string& element, cons
currentFile = StreamInitiationFileInfo();
currentFile.setName(attributes.getAttribute("name"));
try {
- currentFile.setSize(boost::lexical_cast<int>(attributes.getAttribute("size")));
+ currentFile.setSize(boost::lexical_cast<unsigned long long>(attributes.getAttribute("size")));
}
catch (boost::bad_lexical_cast&) {
}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/JingleParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/JingleParserTest.cpp
index 8719a5d..39ec98a 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/JingleParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/JingleParserTest.cpp
@@ -121,7 +121,7 @@ class JingleParserTest : public CppUnit::TestFixture {
JingleIBBTransportPayload::ref transportPaylod = payload->getTransport<JingleIBBTransportPayload>();
CPPUNIT_ASSERT(transportPaylod);
- CPPUNIT_ASSERT_EQUAL(4096, transportPaylod->getBlockSize());
+ CPPUNIT_ASSERT_EQUAL(4096U, transportPaylod->getBlockSize());
CPPUNIT_ASSERT_EQUAL(std::string("ch3d9s71"), transportPaylod->getSessionID());
}
@@ -158,7 +158,7 @@ class JingleParserTest : public CppUnit::TestFixture {
JingleIBBTransportPayload::ref transportPaylod = payload->getTransport<JingleIBBTransportPayload>();
CPPUNIT_ASSERT(transportPaylod);
- CPPUNIT_ASSERT_EQUAL(2048, transportPaylod->getBlockSize());
+ CPPUNIT_ASSERT_EQUAL(2048U, transportPaylod->getBlockSize());
CPPUNIT_ASSERT_EQUAL(std::string("ch3d9s71"), transportPaylod->getSessionID());
}
@@ -191,7 +191,7 @@ class JingleParserTest : public CppUnit::TestFixture {
JingleIBBTransportPayload::ref transportPaylod = payload->getTransport<JingleIBBTransportPayload>();
CPPUNIT_ASSERT(transportPaylod);
- CPPUNIT_ASSERT_EQUAL(2048, transportPaylod->getBlockSize());
+ CPPUNIT_ASSERT_EQUAL(2048U, transportPaylod->getBlockSize());
CPPUNIT_ASSERT_EQUAL(std::string("bt8a71h6"), transportPaylod->getSessionID());
}
@@ -468,7 +468,7 @@ class JingleParserTest : public CppUnit::TestFixture {
StreamInitiationFileInfo file = content->getDescription<JingleFileTransferDescription>()->getRequests()[0];
CPPUNIT_ASSERT_EQUAL(std::string("552da749930852c69ae5d2141d3766b1"), file.getHash());
- CPPUNIT_ASSERT_EQUAL(static_cast<boost::uintmax_t>(270336), file.getRangeOffset());
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned long long>(270336), file.getRangeOffset());
CPPUNIT_ASSERT_EQUAL(true, file.getSupportsRangeRequests());
}
diff --git a/Swiften/SASL/DIGESTMD5Properties.cpp b/Swiften/SASL/DIGESTMD5Properties.cpp
index 6d406e0..23a3476 100644
--- a/Swiften/SASL/DIGESTMD5Properties.cpp
+++ b/Swiften/SASL/DIGESTMD5Properties.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.
*/
@@ -48,13 +48,13 @@ DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray& data) {
ByteArray currentKey;
ByteArray currentValue;
for (size_t i = 0; i < data.size(); ++i) {
- char c = data[i];
+ char c = static_cast<char>(data[i]);
if (inKey) {
if (c == '=') {
inKey = false;
}
else {
- currentKey.push_back(c);
+ currentKey.push_back(static_cast<unsigned char>(c));
}
}
else {
@@ -71,7 +71,7 @@ DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray& data) {
currentValue = ByteArray();
}
else {
- currentValue.push_back(c);
+ currentValue.push_back(static_cast<unsigned char>(c));
}
}
}
diff --git a/Swiften/SASL/PLAINMessage.cpp b/Swiften/SASL/PLAINMessage.cpp
index 20ffea7..c43b446 100644
--- a/Swiften/SASL/PLAINMessage.cpp
+++ b/Swiften/SASL/PLAINMessage.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,7 +15,7 @@ PLAINMessage::PLAINMessage(const std::string& authcid, const SafeByteArray& pass
PLAINMessage::PLAINMessage(const SafeByteArray& value) {
size_t i = 0;
while (i < value.size() && value[i] != '\0') {
- authzid += value[i];
+ authzid += static_cast<char>(value[i]);
++i;
}
if (i == value.size()) {
@@ -23,7 +23,7 @@ PLAINMessage::PLAINMessage(const SafeByteArray& value) {
}
++i;
while (i < value.size() && value[i] != '\0') {
- authcid += value[i];
+ authcid += static_cast<char>(value[i]);
++i;
}
if (i == value.size()) {
diff --git a/Swiften/SConscript b/Swiften/SConscript
index 2111d26..b68dfec 100644
--- a/Swiften/SConscript
+++ b/Swiften/SConscript
@@ -128,6 +128,7 @@ if env["SCONS_STAGE"] == "build" :
"Elements/RosterItemExchangePayload.cpp",
"Elements/RosterPayload.cpp",
"Elements/Stanza.cpp",
+ "Elements/StanzaAck.cpp",
"Elements/StatusShow.cpp",
"Elements/StreamManagementEnabled.cpp",
"Elements/StreamResume.cpp",
diff --git a/Swiften/Serializer/PayloadSerializers/BlockSerializer.h b/Swiften/Serializer/PayloadSerializers/BlockSerializer.h
index 345463c..10ae8b0 100644
--- a/Swiften/Serializer/PayloadSerializers/BlockSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/BlockSerializer.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.
*/
@@ -10,7 +10,6 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
#include <Swiften/Serializer/XML/XMLElement.h>
-#include <Swiften/Base/foreach.h>
namespace Swift {
template<typename BLOCK_ELEMENT>
@@ -19,11 +18,12 @@ namespace Swift {
BlockSerializer(std::string tag) : GenericPayloadSerializer<BLOCK_ELEMENT>(), tag(tag) {
}
- virtual std::string serializePayload(boost::shared_ptr<BLOCK_ELEMENT> payload) const {
+ virtual std::string serializePayload(boost::shared_ptr<BLOCK_ELEMENT> payload) const {
XMLElement element(tag, "urn:xmpp:blocking");
- foreach (const JID& jid, payload->getItems()) {
+ const std::vector<JID>& items = payload->getItems();
+ for (std::vector<JID>::const_iterator i = items.begin(); i != items.end(); ++i) {
boost::shared_ptr<XMLElement> item = boost::make_shared<XMLElement>("item");
- item->setAttribute("jid", jid);
+ item->setAttribute("jid", *i);
}
return element.serialize();
}
diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
index e52436a..d654787 100644
--- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
+++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.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 @@
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wcast-align"
+#pragma clang diagnostic ignored "-Wsign-conversion"
namespace Swift {
diff --git a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp
index 3cb4827..77f780f 100644
--- a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp
+++ b/Swiften/TLS/OpenSSL/OpenSSLContext.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,6 +28,7 @@
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#pragma clang diagnostic ignored "-Wcast-align"
+#pragma clang diagnostic ignored "-Wsign-conversion"
namespace Swift {