Fix some compiler warnings

pull/709/merge
Nils Maier 2016-07-19 15:36:09 +02:00
parent 665a1d1b35
commit f5ceeebe86
8 changed files with 16 additions and 8 deletions

View File

@ -84,7 +84,6 @@ std::unique_ptr<Dict> DHTGetPeersReplyMessage::getResponse()
if (!closestKNodes_.empty()) { if (!closestKNodes_.empty()) {
std::array<unsigned char, DHTBucket::K * 38> buffer; std::array<unsigned char, DHTBucket::K * 38> buffer;
const auto clen = bittorrent::getCompactLength(family_); const auto clen = bittorrent::getCompactLength(family_);
const auto unit = clen + DHT_ID_LENGTH;
auto last = std::begin(buffer); auto last = std::begin(buffer);
size_t k = 0; size_t k = 0;
for (auto i = std::begin(closestKNodes_); for (auto i = std::begin(closestKNodes_);
@ -92,7 +91,9 @@ std::unique_ptr<Dict> DHTGetPeersReplyMessage::getResponse()
std::array<unsigned char, COMPACT_LEN_IPV6> compact; std::array<unsigned char, COMPACT_LEN_IPV6> compact;
auto compactlen = bittorrent::packcompact( auto compactlen = bittorrent::packcompact(
compact.data(), (*i)->getIPAddress(), (*i)->getPort()); compact.data(), (*i)->getIPAddress(), (*i)->getPort());
if (compactlen == clen) { auto cclen =
static_cast<std::make_unsigned<decltype(clen)>::type>((clen));
if (clen >= 0 && compactlen == cclen) {
last = std::copy_n((*i)->getID(), DHT_ID_LENGTH, last); last = std::copy_n((*i)->getID(), DHT_ID_LENGTH, last);
last = std::copy_n(std::begin(compact), compactlen, last); last = std::copy_n(std::begin(compact), compactlen, last);
++k; ++k;
@ -132,7 +133,9 @@ std::unique_ptr<Dict> DHTGetPeersReplyMessage::getResponse()
const auto clen = bittorrent::getCompactLength(family_); const auto clen = bittorrent::getCompactLength(family_);
auto compactlen = bittorrent::packcompact( auto compactlen = bittorrent::packcompact(
compact.data(), (*i)->getIPAddress(), (*i)->getPort()); compact.data(), (*i)->getIPAddress(), (*i)->getPort());
if (compactlen == clen) { auto cclen =
static_cast<std::make_unsigned<decltype(clen)>::type>((clen));
if (clen > 0 && compactlen == cclen) {
valuesList->append(String::g(compact.data(), compactlen)); valuesList->append(String::g(compact.data(), compactlen));
} }
} }

View File

@ -95,7 +95,7 @@ public:
addPeer(const std::vector<std::shared_ptr<Peer>>& peers) CXX11_OVERRIDE; addPeer(const std::vector<std::shared_ptr<Peer>>& peers) CXX11_OVERRIDE;
std::shared_ptr<Peer> addAndCheckoutPeer(const std::shared_ptr<Peer>& peer, std::shared_ptr<Peer> addAndCheckoutPeer(const std::shared_ptr<Peer>& peer,
cuid_t cuid); cuid_t cuid) CXX11_OVERRIDE;
const std::deque<std::shared_ptr<Peer>>& getUnusedPeers(); const std::deque<std::shared_ptr<Peer>>& getUnusedPeers();

View File

@ -184,8 +184,9 @@ std::shared_ptr<Request> FileEntry::getRequestWithInFlightHosts(
continue; continue;
} }
return req; break;
} }
return req;
} }
std::shared_ptr<Request> FileEntry::getRequest( std::shared_ptr<Request> FileEntry::getRequest(

View File

@ -544,7 +544,7 @@ HttpResponseCommand::createHttpDownloadCommand(
getRequestGroup()->getURISelector()->tuneDownloadCommand( getRequestGroup()->getURISelector()->tuneDownloadCommand(
getFileEntry()->getRemainingUris(), command.get()); getFileEntry()->getRemainingUris(), command.get());
return std::move(command); return command;
} }
void HttpResponseCommand::poolConnection() void HttpResponseCommand::poolConnection()

View File

@ -625,7 +625,7 @@ void OptimizeConcurrentDownloadsOptionHandler::parseArg(
for (;;) { for (;;) {
char* end; char* end;
errno = 0; errno = 0;
auto dbl = strtod(sptr->c_str(), &end); strtod(sptr->c_str(), &end);
if (errno != 0 || sptr->c_str() + sptr->size() != end) { if (errno != 0 || sptr->c_str() + sptr->size() != end) {
throw DL_ABORT_EX(fmt("Bad number '%s'", sptr->c_str())); throw DL_ABORT_EX(fmt("Bad number '%s'", sptr->c_str()));
} }

View File

@ -35,6 +35,7 @@
#ifndef D_UNKNOWN_LENGTH_PIECE_STORAGE_H #ifndef D_UNKNOWN_LENGTH_PIECE_STORAGE_H
#define D_UNKNOWN_LENGTH_PIECE_STORAGE_H #define D_UNKNOWN_LENGTH_PIECE_STORAGE_H
#include "FatalException.h"
#include "PieceStorage.h" #include "PieceStorage.h"
namespace aria2 { namespace aria2 {
@ -236,6 +237,7 @@ public:
getAdvertisedPieceIndexes(std::vector<size_t>& indexes, cuid_t myCuid, getAdvertisedPieceIndexes(std::vector<size_t>& indexes, cuid_t myCuid,
uint64_t lastHaveIndex) CXX11_OVERRIDE uint64_t lastHaveIndex) CXX11_OVERRIDE
{ {
throw FATAL_EXCEPTION("Not Implemented!");
} }
virtual void removeAdvertisedPiece(const Timer& expiry) CXX11_OVERRIDE {} virtual void removeAdvertisedPiece(const Timer& expiry) CXX11_OVERRIDE {}

View File

@ -39,7 +39,7 @@ public:
} }
virtual std::shared_ptr<Peer> virtual std::shared_ptr<Peer>
addAndCheckoutPeer(const std::shared_ptr<Peer>& peer, cuid_t cuid) addAndCheckoutPeer(const std::shared_ptr<Peer>& peer, cuid_t cuid) CXX11_OVERRIDE
{ {
unusedPeers.push_back(peer); unusedPeers.push_back(peer);
return nullptr; return nullptr;

View File

@ -6,6 +6,7 @@
#include <algorithm> #include <algorithm>
#include "BitfieldMan.h" #include "BitfieldMan.h"
#include "FatalException.h"
#include "Piece.h" #include "Piece.h"
#include "DiskAdaptor.h" #include "DiskAdaptor.h"
@ -250,6 +251,7 @@ public:
getAdvertisedPieceIndexes(std::vector<size_t>& indexes, cuid_t myCuid, getAdvertisedPieceIndexes(std::vector<size_t>& indexes, cuid_t myCuid,
uint64_t lastHaveIndex) CXX11_OVERRIDE uint64_t lastHaveIndex) CXX11_OVERRIDE
{ {
throw FATAL_EXCEPTION("Not Implemented!");
} }
virtual void removeAdvertisedPiece(const Timer& expiry) CXX11_OVERRIDE {} virtual void removeAdvertisedPiece(const Timer& expiry) CXX11_OVERRIDE {}