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/Parser
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/Parser')
-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
6 files changed, 26 insertions, 16 deletions
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());
}