From f5ceeebe8604c6b5d08de5744d245c6b0551a9b9 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Tue, 19 Jul 2016 15:36:09 +0200 Subject: [PATCH] Fix some compiler warnings --- src/DHTGetPeersReplyMessage.cc | 9 ++++++--- src/DefaultPeerStorage.h | 2 +- src/FileEntry.cc | 3 ++- src/HttpResponseCommand.cc | 2 +- src/OptionHandlerImpl.cc | 2 +- src/UnknownLengthPieceStorage.h | 2 ++ test/MockPeerStorage.h | 2 +- test/MockPieceStorage.h | 2 ++ 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/DHTGetPeersReplyMessage.cc b/src/DHTGetPeersReplyMessage.cc index 2ae92f3b..2e6c1871 100644 --- a/src/DHTGetPeersReplyMessage.cc +++ b/src/DHTGetPeersReplyMessage.cc @@ -84,7 +84,6 @@ std::unique_ptr DHTGetPeersReplyMessage::getResponse() if (!closestKNodes_.empty()) { std::array buffer; const auto clen = bittorrent::getCompactLength(family_); - const auto unit = clen + DHT_ID_LENGTH; auto last = std::begin(buffer); size_t k = 0; for (auto i = std::begin(closestKNodes_); @@ -92,7 +91,9 @@ std::unique_ptr DHTGetPeersReplyMessage::getResponse() std::array compact; auto compactlen = bittorrent::packcompact( compact.data(), (*i)->getIPAddress(), (*i)->getPort()); - if (compactlen == clen) { + auto cclen = + static_cast::type>((clen)); + if (clen >= 0 && compactlen == cclen) { last = std::copy_n((*i)->getID(), DHT_ID_LENGTH, last); last = std::copy_n(std::begin(compact), compactlen, last); ++k; @@ -132,7 +133,9 @@ std::unique_ptr DHTGetPeersReplyMessage::getResponse() const auto clen = bittorrent::getCompactLength(family_); auto compactlen = bittorrent::packcompact( compact.data(), (*i)->getIPAddress(), (*i)->getPort()); - if (compactlen == clen) { + auto cclen = + static_cast::type>((clen)); + if (clen > 0 && compactlen == cclen) { valuesList->append(String::g(compact.data(), compactlen)); } } diff --git a/src/DefaultPeerStorage.h b/src/DefaultPeerStorage.h index 1daba84d..4ba716aa 100644 --- a/src/DefaultPeerStorage.h +++ b/src/DefaultPeerStorage.h @@ -95,7 +95,7 @@ public: addPeer(const std::vector>& peers) CXX11_OVERRIDE; std::shared_ptr addAndCheckoutPeer(const std::shared_ptr& peer, - cuid_t cuid); + cuid_t cuid) CXX11_OVERRIDE; const std::deque>& getUnusedPeers(); diff --git a/src/FileEntry.cc b/src/FileEntry.cc index 95b3f50a..453c6816 100644 --- a/src/FileEntry.cc +++ b/src/FileEntry.cc @@ -184,8 +184,9 @@ std::shared_ptr FileEntry::getRequestWithInFlightHosts( continue; } - return req; + break; } + return req; } std::shared_ptr FileEntry::getRequest( diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index dc1501e7..7d942524 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -544,7 +544,7 @@ HttpResponseCommand::createHttpDownloadCommand( getRequestGroup()->getURISelector()->tuneDownloadCommand( getFileEntry()->getRemainingUris(), command.get()); - return std::move(command); + return command; } void HttpResponseCommand::poolConnection() diff --git a/src/OptionHandlerImpl.cc b/src/OptionHandlerImpl.cc index 3b66e3ae..12412993 100644 --- a/src/OptionHandlerImpl.cc +++ b/src/OptionHandlerImpl.cc @@ -625,7 +625,7 @@ void OptimizeConcurrentDownloadsOptionHandler::parseArg( for (;;) { char* end; errno = 0; - auto dbl = strtod(sptr->c_str(), &end); + strtod(sptr->c_str(), &end); if (errno != 0 || sptr->c_str() + sptr->size() != end) { throw DL_ABORT_EX(fmt("Bad number '%s'", sptr->c_str())); } diff --git a/src/UnknownLengthPieceStorage.h b/src/UnknownLengthPieceStorage.h index 3263870f..a8384cee 100644 --- a/src/UnknownLengthPieceStorage.h +++ b/src/UnknownLengthPieceStorage.h @@ -35,6 +35,7 @@ #ifndef D_UNKNOWN_LENGTH_PIECE_STORAGE_H #define D_UNKNOWN_LENGTH_PIECE_STORAGE_H +#include "FatalException.h" #include "PieceStorage.h" namespace aria2 { @@ -236,6 +237,7 @@ public: getAdvertisedPieceIndexes(std::vector& indexes, cuid_t myCuid, uint64_t lastHaveIndex) CXX11_OVERRIDE { + throw FATAL_EXCEPTION("Not Implemented!"); } virtual void removeAdvertisedPiece(const Timer& expiry) CXX11_OVERRIDE {} diff --git a/test/MockPeerStorage.h b/test/MockPeerStorage.h index 7aa0b0c2..e5508d04 100644 --- a/test/MockPeerStorage.h +++ b/test/MockPeerStorage.h @@ -39,7 +39,7 @@ public: } virtual std::shared_ptr - addAndCheckoutPeer(const std::shared_ptr& peer, cuid_t cuid) + addAndCheckoutPeer(const std::shared_ptr& peer, cuid_t cuid) CXX11_OVERRIDE { unusedPeers.push_back(peer); return nullptr; diff --git a/test/MockPieceStorage.h b/test/MockPieceStorage.h index 89297363..379f9743 100644 --- a/test/MockPieceStorage.h +++ b/test/MockPieceStorage.h @@ -6,6 +6,7 @@ #include #include "BitfieldMan.h" +#include "FatalException.h" #include "Piece.h" #include "DiskAdaptor.h" @@ -250,6 +251,7 @@ public: getAdvertisedPieceIndexes(std::vector& indexes, cuid_t myCuid, uint64_t lastHaveIndex) CXX11_OVERRIDE { + throw FATAL_EXCEPTION("Not Implemented!"); } virtual void removeAdvertisedPiece(const Timer& expiry) CXX11_OVERRIDE {}