瀏覽代碼

Merge pull request #2106 from aria2/static-check-fix

Static check fix
Tatsuhiro Tsujikawa 2 年之前
父節點
當前提交
f05deb0cb2
共有 3 個文件被更改,包括 8 次插入4 次删除
  1. 2 2
      src/DHTRoutingTableDeserializer.cc
  2. 4 0
      src/DefaultBtProgressInfoFile.cc
  3. 2 2
      src/UriListParser.cc

+ 2 - 2
src/DHTRoutingTableDeserializer.cc

@@ -196,8 +196,8 @@ void DHTRoutingTableDeserializer::deserialize(const std::string& filename)
 
     nodes.push_back(node);
   }
-  localNode_ = localNode;
-  nodes_ = nodes;
+  localNode_ = std::move(localNode);
+  nodes_ = std::move(nodes);
   A2_LOG_INFO("DHT routing table was loaded successfully");
 }
 

+ 4 - 0
src/DefaultBtProgressInfoFile.cc

@@ -289,6 +289,10 @@ void DefaultBtProgressInfoFile::load()
     pieceLength = ntohl(pieceLength);
   }
 
+  if (pieceLength == 0) {
+    throw DL_ABORT_EX("piece length must not be 0");
+  }
+
   uint64_t totalLength;
   READ_CHECK(fp, &totalLength, sizeof(totalLength));
   if (version >= 1) {

+ 2 - 2
src/UriListParser.cc

@@ -77,7 +77,7 @@ void UriListParser::parseNext(std::vector<std::string>& uris, Option& op)
           if (fp_->eof()) {
             break;
           }
-          else if (!fp_) {
+          else if (!*fp_) {
             throw DL_ABORT_EX("UriListParser:I/O error.");
           }
           else {
@@ -102,7 +102,7 @@ void UriListParser::parseNext(std::vector<std::string>& uris, Option& op)
       if (fp_->eof()) {
         return;
       }
-      else if (!fp_) {
+      else if (!*fp_) {
         throw DL_ABORT_EX("UriListParser:I/O error.");
       }
     }