Selaa lähdekoodia

Fix some compiler warnings

Nils Maier 9 vuotta sitten
vanhempi
commit
f5ceeebe86

+ 6 - 3
src/DHTGetPeersReplyMessage.cc

@@ -84,7 +84,6 @@ std::unique_ptr<Dict> DHTGetPeersReplyMessage::getResponse()
   if (!closestKNodes_.empty()) {
     std::array<unsigned char, DHTBucket::K * 38> 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<Dict> DHTGetPeersReplyMessage::getResponse()
       std::array<unsigned char, COMPACT_LEN_IPV6> compact;
       auto compactlen = bittorrent::packcompact(
           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(std::begin(compact), compactlen, last);
         ++k;
@@ -132,7 +133,9 @@ std::unique_ptr<Dict> 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<std::make_unsigned<decltype(clen)>::type>((clen));
+      if (clen > 0 && compactlen == cclen) {
         valuesList->append(String::g(compact.data(), compactlen));
       }
     }

+ 1 - 1
src/DefaultPeerStorage.h

@@ -95,7 +95,7 @@ public:
   addPeer(const std::vector<std::shared_ptr<Peer>>& peers) CXX11_OVERRIDE;
 
   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();
 

+ 2 - 1
src/FileEntry.cc

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

+ 1 - 1
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()

+ 1 - 1
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()));
       }

+ 2 - 0
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<size_t>& indexes, cuid_t myCuid,
                             uint64_t lastHaveIndex) CXX11_OVERRIDE
   {
+    throw FATAL_EXCEPTION("Not Implemented!");
   }
 
   virtual void removeAdvertisedPiece(const Timer& expiry) CXX11_OVERRIDE {}

+ 1 - 1
test/MockPeerStorage.h

@@ -39,7 +39,7 @@ public:
   }
 
   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);
     return nullptr;

+ 2 - 0
test/MockPieceStorage.h

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