From 645876deedb72aa8ebd2a56773f7dd5bb0133b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Mon, 13 Jun 2011 15:52:30 +0200 Subject: Fixed some CppCheck warnings. diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp index 8fc869b..57e53e4 100644 --- a/Swiften/Client/UnitTest/ClientSessionTest.cpp +++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp @@ -527,7 +527,7 @@ class ClientSessionTest : public CppUnit::TestFixture { } Event popEvent() { - CPPUNIT_ASSERT(receivedEvents.size() > 0); + CPPUNIT_ASSERT(!receivedEvents.empty()); Event event = receivedEvents.front(); receivedEvents.pop_front(); return event; diff --git a/Swiften/Component/ComponentConnector.h b/Swiften/Component/ComponentConnector.h index 34451d7..b47f5da 100644 --- a/Swiften/Component/ComponentConnector.h +++ b/Swiften/Component/ComponentConnector.h @@ -27,7 +27,7 @@ namespace Swift { typedef boost::shared_ptr ref; static ComponentConnector::ref create(const std::string& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) { - return ComponentConnector::ref(new ComponentConnector(hostname, port, resolver, connectionFactory, timerFactory)); + return ref(new ComponentConnector(hostname, port, resolver, connectionFactory, timerFactory)); } void setTimeoutMilliseconds(int milliseconds); diff --git a/Swiften/Elements/ChatState.h b/Swiften/Elements/ChatState.h index 5c83318..477fd27 100644 --- a/Swiften/Elements/ChatState.h +++ b/Swiften/Elements/ChatState.h @@ -18,7 +18,7 @@ namespace Swift { state_ = state; } - ChatStateType getChatState() { return state_; } + ChatStateType getChatState() const { return state_; } void setChatState(ChatStateType state) {state_ = state;} private: diff --git a/Swiften/Elements/ErrorPayload.h b/Swiften/Elements/ErrorPayload.h index 6d31a98..f21ba98 100644 --- a/Swiften/Elements/ErrorPayload.h +++ b/Swiften/Elements/ErrorPayload.h @@ -73,7 +73,7 @@ namespace Swift { payload_ = payload; } - boost::shared_ptr getPayload() { + boost::shared_ptr getPayload() const { return payload_; } diff --git a/Swiften/Elements/Form.h b/Swiften/Elements/Form.h index 3b93be4..47ff7d4 100644 --- a/Swiften/Elements/Form.h +++ b/Swiften/Elements/Form.h @@ -31,12 +31,12 @@ namespace Swift { void addField(boost::shared_ptr field) { fields_.push_back(field); } const std::vector >& getFields() const { return fields_; } void setTitle(const std::string& title) { title_ = title; } - const std::string& getTitle() { return title_; } + const std::string& getTitle() const { return title_; } void setInstructions(const std::string& instructions) { instructions_ = instructions; } - const std::string& getInstructions() { return instructions_; } + const std::string& getInstructions() const { return instructions_; } - Type getType() { return type_; } + Type getType() const { return type_; } void setType(Type type) { type_ = type; } std::string getFormType() const; diff --git a/Swiften/Elements/IBB.h b/Swiften/Elements/IBB.h index 8138e83..64c9f14 100644 --- a/Swiften/Elements/IBB.h +++ b/Swiften/Elements/IBB.h @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -31,20 +32,20 @@ namespace Swift { } static IBB::ref createIBBOpen(const std::string& streamID, int blockSize) { - IBB::ref result(new IBB(Open, streamID)); + IBB::ref result = boost::make_shared(Open, streamID); result->setBlockSize(blockSize); return result; } static IBB::ref createIBBData(const std::string& streamID, int sequenceNumber, const std::vector& data) { - IBB::ref result(new IBB(Data, streamID)); + IBB::ref result = boost::make_shared(Data, streamID); result->setSequenceNumber(sequenceNumber); result->setData(data); return result; } static IBB::ref createIBBClose(const std::string& streamID) { - return IBB::ref(new IBB(Close, streamID)); + return boost::make_shared(Close, streamID); } void setAction(Action action) { diff --git a/Swiften/Elements/MUCPayload.h b/Swiften/Elements/MUCPayload.h index 8b75bd4..3b99111 100644 --- a/Swiften/Elements/MUCPayload.h +++ b/Swiften/Elements/MUCPayload.h @@ -40,19 +40,19 @@ namespace Swift { since_ = since; } - int getMaxChars() { + int getMaxChars() const{ return maxChars_; } - int getMaxStanzas() { + int getMaxStanzas() const{ return maxStanzas_; } - int getSeconds() { + int getSeconds() const { return seconds_; } - boost::posix_time::ptime getSince() { + const boost::posix_time::ptime& getSince() const { return since_; } diff --git a/Swiften/Elements/VCard.h b/Swiften/Elements/VCard.h index cb05056..f9822c9 100644 --- a/Swiften/Elements/VCard.h +++ b/Swiften/Elements/VCard.h @@ -60,10 +60,10 @@ namespace Swift { const std::string& getNickname() const { return nick_; } void setPhoto(const ByteArray& photo) { photo_ = photo; } - const ByteArray& getPhoto() { return photo_; } + const ByteArray& getPhoto() const { return photo_; } void setPhotoType(const std::string& photoType) { photoType_ = photoType; } - const std::string& getPhotoType() { return photoType_; } + const std::string& getPhotoType() const { return photoType_; } const std::string& getUnknownContent() const { return unknownContent_; } void addUnknownContent(const std::string& c) { diff --git a/Swiften/Elements/VCardUpdate.h b/Swiften/Elements/VCardUpdate.h index e225a4a..782106c 100644 --- a/Swiften/Elements/VCardUpdate.h +++ b/Swiften/Elements/VCardUpdate.h @@ -15,7 +15,7 @@ namespace Swift { VCardUpdate(const std::string& photoHash = "") : photoHash_(photoHash) {} void setPhotoHash(const std::string& photoHash) { photoHash_ = photoHash; } - const std::string& getPhotoHash() { return photoHash_; } + const std::string& getPhotoHash() const { return photoHash_; } private: std::string photoHash_; diff --git a/Swiften/EventLoop/EventLoop.h b/Swiften/EventLoop/EventLoop.h index 69ec68e..9e47112 100644 --- a/Swiften/EventLoop/EventLoop.h +++ b/Swiften/EventLoop/EventLoop.h @@ -35,7 +35,7 @@ namespace Swift { private: struct HasOwner { HasOwner(boost::shared_ptr owner) : owner(owner) {} - bool operator()(const Event& event) { return event.owner == owner; } + bool operator()(const Event& event) const { return event.owner == owner; } boost::shared_ptr owner; }; boost::mutex eventsMutex_; diff --git a/Swiften/Network/BoostIOServiceThread.h b/Swiften/Network/BoostIOServiceThread.h index ea04b02..00fb397 100644 --- a/Swiften/Network/BoostIOServiceThread.h +++ b/Swiften/Network/BoostIOServiceThread.h @@ -16,7 +16,7 @@ namespace Swift { BoostIOServiceThread(); ~BoostIOServiceThread(); - boost::shared_ptr getIOService() { + boost::shared_ptr getIOService() const { return ioService_; } diff --git a/Swiften/Network/Connector.h b/Swiften/Network/Connector.h index 42dca77..8336299 100644 --- a/Swiften/Network/Connector.h +++ b/Swiften/Network/Connector.h @@ -28,7 +28,7 @@ namespace Swift { typedef boost::shared_ptr ref; static Connector::ref create(const std::string& hostname, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) { - return Connector::ref(new Connector(hostname, resolver, connectionFactory, timerFactory)); + return ref(new Connector(hostname, resolver, connectionFactory, timerFactory)); } void setTimeoutMilliseconds(int milliseconds); diff --git a/Swiften/Parser/PayloadParsers/SecurityLabelParser.cpp b/Swiften/Parser/PayloadParsers/SecurityLabelParser.cpp index 0b0f104..4177baa 100644 --- a/Swiften/Parser/PayloadParsers/SecurityLabelParser.cpp +++ b/Swiften/Parser/PayloadParsers/SecurityLabelParser.cpp @@ -62,7 +62,7 @@ void SecurityLabelParser::handleCharacterData(const std::string& data) { } } -boost::shared_ptr SecurityLabelParser::getLabelPayload() { +boost::shared_ptr SecurityLabelParser::getLabelPayload() const { return getPayloadInternal(); } diff --git a/Swiften/Parser/PayloadParsers/SecurityLabelParser.h b/Swiften/Parser/PayloadParsers/SecurityLabelParser.h index 676cebc..5357028 100644 --- a/Swiften/Parser/PayloadParsers/SecurityLabelParser.h +++ b/Swiften/Parser/PayloadParsers/SecurityLabelParser.h @@ -19,7 +19,7 @@ namespace Swift { virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); virtual void handleEndElement(const std::string& element, const std::string&); virtual void handleCharacterData(const std::string& data); - boost::shared_ptr getLabelPayload(); + boost::shared_ptr getLabelPayload() const; private: enum Level { TopLevel = 0, diff --git a/Swiften/TLS/ServerIdentityVerifier.cpp b/Swiften/TLS/ServerIdentityVerifier.cpp index 7c68774..a908ad0 100644 --- a/Swiften/TLS/ServerIdentityVerifier.cpp +++ b/Swiften/TLS/ServerIdentityVerifier.cpp @@ -63,7 +63,7 @@ bool ServerIdentityVerifier::certificateVerifies(Certificate::ref certificate) { return false; } -bool ServerIdentityVerifier::matchesDomain(const std::string& s) { +bool ServerIdentityVerifier::matchesDomain(const std::string& s) const { if (boost::starts_with(s, "*.")) { std::string matchString(s.substr(2, s.npos)); std::string matchDomain = encodedDomain; @@ -78,7 +78,7 @@ bool ServerIdentityVerifier::matchesDomain(const std::string& s) { } } -bool ServerIdentityVerifier::matchesAddress(const std::string& s) { +bool ServerIdentityVerifier::matchesAddress(const std::string& s) const { return s == domain; } diff --git a/Swiften/TLS/ServerIdentityVerifier.h b/Swiften/TLS/ServerIdentityVerifier.h index c1abd5e..b09abd9 100644 --- a/Swiften/TLS/ServerIdentityVerifier.h +++ b/Swiften/TLS/ServerIdentityVerifier.h @@ -20,8 +20,8 @@ namespace Swift { bool certificateVerifies(Certificate::ref); private: - bool matchesDomain(const std::string&); - bool matchesAddress(const std::string&); + bool matchesDomain(const std::string&) const ; + bool matchesAddress(const std::string&) const; private: std::string domain; -- cgit v0.10.2-6-g49f6