Преглед на файлове

Merge branch 'clang-format-3.9'

Tatsuhiro Tsujikawa преди 9 години
родител
ревизия
df19921b83
променени са 52 файла, в които са добавени 386 реда и са изтрити 296 реда
  1. 54 25
      .clang-format
  2. 5 3
      examples/libaria2ex.cc
  3. 3 2
      examples/libaria2wx.cc
  4. 2 1
      src/AbstractCommand.cc
  5. 1 5
      src/Adler32MessageDigestImpl.h
  6. 12 10
      src/AppleMessageDigestImpl.cc
  7. 4 2
      src/AppleTLSSession.cc
  8. 2 2
      src/AuthConfigFactory.cc
  9. 2 1
      src/AuthConfigFactory.h
  10. 2 2
      src/ConsoleStatCalc.cc
  11. 4 3
      src/DHTGetPeersCommand.cc
  12. 7 9
      src/DHTMessageDispatcher.h
  13. 9 8
      src/DHTMessageDispatcherImpl.h
  14. 2 1
      src/DNSCache.h
  15. 20 18
      src/DefaultBtAnnounce.cc
  16. 3 2
      src/DefaultBtMessageReceiver.cc
  17. 2 2
      src/DownloadEngine.cc
  18. 2 1
      src/EpollEventPoll.h
  19. 6 5
      src/FileAllocationCommand.cc
  20. 25 8
      src/HttpHeader.cc
  21. 8 5
      src/IndexedList.h
  22. 1 2
      src/InitiateConnectionCommandFactory.cc
  23. 2 1
      src/KqueueEventPoll.h
  24. 2 1
      src/LibuvEventPoll.h
  25. 6 6
      src/OptionHandlerFactory.cc
  26. 2 1
      src/PollEventPoll.h
  27. 2 1
      src/PortEventPoll.h
  28. 2 1
      src/RequestGroupMan.cc
  29. 33 11
      src/RpcMethodFactory.cc
  30. 2 1
      src/SelectEventPoll.h
  31. 2 1
      src/ServerStatMan.h
  32. 1 2
      src/SimpleRandomizer.cc
  33. 6 3
      src/SpeedCalc.cc
  34. 1 2
      src/TimerA2.h
  35. 1 2
      src/ValueBase.h
  36. 2 2
      src/a2netcompat.h
  37. 2 2
      src/alloca.c
  38. 1 1
      src/array_fun.h
  39. 1 1
      src/bignum.h
  40. 1 2
      src/cookie_helper.cc
  41. 4 12
      src/crypto_hash.cc
  42. 6 7
      src/uri_split.c
  43. 21 24
      src/util.cc
  44. 15 11
      src/version_usage.cc
  45. 4 4
      test/BtRegistryTest.cc
  46. 6 4
      test/CookieStorageTest.cc
  47. 1 1
      test/IndexedListTest.cc
  48. 9 8
      test/MockDHTMessageDispatcher.h
  49. 32 25
      test/RpcMethodTest.cc
  50. 37 37
      test/UtilSecurityTest.cc
  51. 3 2
      test/UtilTest2.cc
  52. 3 3
      test/ValueBaseJsonParserTest.cc

+ 54 - 25
.clang-format

@@ -1,65 +1,94 @@
 ---
 Language:        Cpp
-# BasedOnStyle:  LLVM
 AccessModifierOffset: -2
 AlignAfterOpenBracket: true
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
 AlignEscapedNewlinesLeft: false
 AlignOperands:   true
 AlignTrailingComments: true
 AllowAllParametersOfDeclarationOnNextLine: true
 AllowShortBlocksOnASingleLine: false
 AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
 AllowShortIfStatementsOnASingleLine: false
 AllowShortLoopsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: All
-AlwaysBreakAfterDefinitionReturnType: false
-AlwaysBreakTemplateDeclarations: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
 AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+  AfterClass:      false
+  AfterControlStatement: false
+  AfterEnum:       false
+  AfterFunction:   true
+  AfterNamespace:  false
+  AfterObjCDeclaration: false
+  AfterStruct:     false
+  AfterUnion:      false
+  BeforeCatch:     true
+  BeforeElse:      true
+  IndentBraces:    false
 BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Stroustrup
 BreakBeforeTernaryOperators: true
 BreakConstructorInitializersBeforeComma: false
-BinPackParameters: true
-BinPackArguments: true
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
 ColumnLimit:     80
+CommentPragmas:  '^ IWYU pragma:'
 ConstructorInitializerAllOnOneLineOrOnePerLine: true
 ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
 DerivePointerAlignment: false
+DisableFormat:   false
 ExperimentalAutoDetectBinPacking: false
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeCategories:
+  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
+    Priority:        2
+  - Regex:           '^(<|"(gtest|isl|json)/)'
+    Priority:        3
+  - Regex:           '.*'
+    Priority:        1
+IncludeIsMainRegex: '$'
 IndentCaseLabels: false
+IndentWidth:     2
 IndentWrappedFunctionNames: false
-IndentFunctionDeclarationAfterType: false
-MaxEmptyLinesToKeep: 1
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
 KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
 NamespaceIndentation: None
 ObjCBlockIndentWidth: 2
 ObjCSpaceAfterProperty: false
 ObjCSpaceBeforeProtocolList: true
 PenaltyBreakBeforeFirstCallParameter: 19
 PenaltyBreakComment: 300
-PenaltyBreakString: 1000
 PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 60
 PointerAlignment: Left
+ReflowComments:  true
+SortIncludes:    false
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
 SpacesBeforeTrailingComments: 1
-Cpp11BracedListStyle: true
+SpacesInAngles:  false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
 Standard:        Cpp11
-IndentWidth:     2
 TabWidth:        8
 UseTab:          Never
-BreakBeforeBraces: Stroustrup
-SpacesInParentheses: false
-SpacesInSquareBrackets: false
-SpacesInAngles:  false
-SpaceInEmptyParentheses: false
-SpacesInCStyleCastParentheses: false
-SpaceAfterCStyleCast: false
-SpacesInContainerLiterals: true
-SpaceBeforeAssignmentOperators: true
-ContinuationIndentWidth: 4
-CommentPragmas:  '^ IWYU pragma:'
-ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
-SpaceBeforeParens: ControlStatements
-DisableFormat:   false
 ...
 

+ 5 - 3
examples/libaria2ex.cc

@@ -111,8 +111,9 @@ int main(int argc, char** argv)
     // the application can call aria2 API to add URI or query progress
     // here
     auto now = std::chrono::steady_clock::now();
-    auto count = std::chrono::duration_cast<std::chrono::milliseconds>(
-                     now - start).count();
+    auto count =
+        std::chrono::duration_cast<std::chrono::milliseconds>(now - start)
+            .count();
     // Print progress information once per 500ms
     if (count >= 500) {
       start = now;
@@ -130,7 +131,8 @@ int main(int argc, char** argv)
                     << "(" << (dh->getTotalLength() > 0
                                    ? (100 * dh->getCompletedLength() /
                                       dh->getTotalLength())
-                                   : 0) << "%)"
+                                   : 0)
+                    << "%)"
                     << " D:" << dh->getDownloadSpeed() / 1024
                     << "KiB/s, U:" << dh->getUploadSpeed() / 1024 << "KiB/s"
                     << std::endl;

+ 3 - 2
examples/libaria2wx.cc

@@ -389,8 +389,9 @@ int downloaderJob(JobQueue& jobq, NotifyQueue& notifyq)
       break;
     }
     auto now = std::chrono::steady_clock::now();
-    auto count = std::chrono::duration_cast<std::chrono::milliseconds>(
-                     now - start).count();
+    auto count =
+        std::chrono::duration_cast<std::chrono::milliseconds>(now - start)
+            .count();
     while (!jobq.empty()) {
       std::unique_ptr<Job> job = jobq.pop();
       job->execute(session);

+ 2 - 1
src/AbstractCommand.cc

@@ -329,7 +329,8 @@ bool AbstractCommand::execute()
                              req_->getConnectedPort());
       }
       if (e_->findCachedIPAddress(req_->getConnectedHostname(),
-                                  req_->getConnectedPort()).empty()) {
+                                  req_->getConnectedPort())
+              .empty()) {
         A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - All IP addresses were marked bad."
                          " Removing Entry.",
                          getCuid()));

+ 1 - 5
src/Adler32MessageDigestImpl.h

@@ -41,11 +41,7 @@ namespace aria2 {
 
 #ifdef HAVE_ZLIB
 
-#define ADLER32_MESSAGE_DIGEST                                                 \
-  {                                                                            \
-    "adler32", make_hi<Adler32MessageDigestImpl>()                             \
-  }                                                                            \
-  ,
+#define ADLER32_MESSAGE_DIGEST {"adler32", make_hi<Adler32MessageDigestImpl>()},
 
 class Adler32MessageDigestImpl : public MessageDigestImpl {
 public:

+ 12 - 10
src/AppleMessageDigestImpl.cc

@@ -71,21 +71,23 @@ private:
 };
 
 typedef MessageDigestBase<CC_MD5_DIGEST_LENGTH, CC_MD5_CTX, CC_MD5_Init,
-                          CC_MD5_Update, CC_MD5_Final> MessageDigestMD5;
+                          CC_MD5_Update, CC_MD5_Final>
+    MessageDigestMD5;
 typedef MessageDigestBase<CC_SHA1_DIGEST_LENGTH, CC_SHA1_CTX, CC_SHA1_Init,
-                          CC_SHA1_Update, CC_SHA1_Final> MessageDigestSHA1;
+                          CC_SHA1_Update, CC_SHA1_Final>
+    MessageDigestSHA1;
 typedef MessageDigestBase<CC_SHA224_DIGEST_LENGTH, CC_SHA256_CTX,
-                          CC_SHA224_Init, CC_SHA224_Update,
-                          CC_SHA224_Final> MessageDigestSHA224;
+                          CC_SHA224_Init, CC_SHA224_Update, CC_SHA224_Final>
+    MessageDigestSHA224;
 typedef MessageDigestBase<CC_SHA256_DIGEST_LENGTH, CC_SHA256_CTX,
-                          CC_SHA256_Init, CC_SHA256_Update,
-                          CC_SHA256_Final> MessageDigestSHA256;
+                          CC_SHA256_Init, CC_SHA256_Update, CC_SHA256_Final>
+    MessageDigestSHA256;
 typedef MessageDigestBase<CC_SHA384_DIGEST_LENGTH, CC_SHA512_CTX,
-                          CC_SHA384_Init, CC_SHA384_Update,
-                          CC_SHA384_Final> MessageDigestSHA384;
+                          CC_SHA384_Init, CC_SHA384_Update, CC_SHA384_Final>
+    MessageDigestSHA384;
 typedef MessageDigestBase<CC_SHA512_DIGEST_LENGTH, CC_SHA512_CTX,
-                          CC_SHA512_Init, CC_SHA512_Update,
-                          CC_SHA512_Final> MessageDigestSHA512;
+                          CC_SHA512_Init, CC_SHA512_Update, CC_SHA512_Final>
+    MessageDigestSHA512;
 
 } // namespace
 

+ 4 - 2
src/AppleTLSSession.cc

@@ -107,7 +107,8 @@ static struct {
 } kSuites[] = {
     // From CipherSuite.h (10.11)
     SUITE(SSL_NULL_WITH_NULL_NULL, 0x0000),
-    SUITE(SSL_RSA_WITH_NULL_MD5, 0x0001), SUITE(SSL_RSA_WITH_NULL_SHA, 0x0002),
+    SUITE(SSL_RSA_WITH_NULL_MD5, 0x0001),
+    SUITE(SSL_RSA_WITH_NULL_SHA, 0x0002),
     SUITE(SSL_RSA_EXPORT_WITH_RC4_40_MD5, 0x0003),
     SUITE(SSL_RSA_WITH_RC4_128_MD5, 0x0004),
     SUITE(SSL_RSA_WITH_RC4_128_SHA, 0x0005),
@@ -173,7 +174,8 @@ static struct {
     SUITE(TLS_ECDH_anon_WITH_AES_128_CBC_SHA, 0xC018),
     SUITE(TLS_ECDH_anon_WITH_AES_256_CBC_SHA, 0xC019),
     SUITE(TLS_NULL_WITH_NULL_NULL, 0x0000),
-    SUITE(TLS_RSA_WITH_NULL_MD5, 0x0001), SUITE(TLS_RSA_WITH_NULL_SHA, 0x0002),
+    SUITE(TLS_RSA_WITH_NULL_MD5, 0x0001),
+    SUITE(TLS_RSA_WITH_NULL_SHA, 0x0002),
     SUITE(TLS_RSA_WITH_RC4_128_MD5, 0x0004),
     SUITE(TLS_RSA_WITH_RC4_128_SHA, 0x0005),
     SUITE(TLS_RSA_WITH_3DES_EDE_CBC_SHA, 0x000A),

+ 2 - 2
src/AuthConfigFactory.cc

@@ -84,8 +84,8 @@ AuthConfigFactory::createAuthConfig(const std::shared_ptr<Request>& request,
                                   request->getPassword());
       }
       else {
-        return createHttpAuthResolver(op)
-            ->resolveAuthConfig(request->getHost());
+        return createHttpAuthResolver(op)->resolveAuthConfig(
+            request->getHost());
       }
     }
   }

+ 2 - 1
src/AuthConfigFactory.h

@@ -76,7 +76,8 @@ public:
 class AuthConfigFactory {
 public:
   typedef std::set<std::unique_ptr<BasicCred>,
-                   DerefLess<std::unique_ptr<BasicCred>>> BasicCredSet;
+                   DerefLess<std::unique_ptr<BasicCred>>>
+      BasicCredSet;
 
 private:
   std::unique_ptr<Netrc> netrc_;

+ 2 - 2
src/ConsoleStatCalc.cc

@@ -259,8 +259,8 @@ void printProgressSummary(const RequestGroupList& groups, size_t cols,
       o << " as of " << buf;
     }
   }
-  o << " *** \n" << std::setfill(SEP_CHAR) << std::setw(cols) << SEP_CHAR
-    << "\n";
+  o << " *** \n"
+    << std::setfill(SEP_CHAR) << std::setw(cols) << SEP_CHAR << "\n";
   global::cout()->write(o.str().c_str());
   std::for_each(groups.begin(), groups.end(),
                 PrintSummary(cols, e, sizeFormatter));

+ 4 - 3
src/DHTGetPeersCommand.cc

@@ -97,9 +97,10 @@ bool DHTGetPeersCommand::execute()
                      elapsed >= GET_PEER_INTERVAL_LOW)) ||
                    (btRuntime_->getConnections() == 0 &&
                     elapsed >= GET_PEER_INTERVAL_ZERO))))) {
-    A2_LOG_DEBUG(fmt("Issuing PeerLookup for infoHash=%s",
-                     bittorrent::getInfoHashString(
-                         requestGroup_->getDownloadContext()).c_str()));
+    A2_LOG_DEBUG(
+        fmt("Issuing PeerLookup for infoHash=%s",
+            bittorrent::getInfoHashString(requestGroup_->getDownloadContext())
+                .c_str()));
     task_ = taskFactory_->createPeerLookupTask(
         requestGroup_->getDownloadContext(), e_->getBtRegistry()->getTcpPort(),
         peerStorage_);

+ 7 - 9
src/DHTMessageDispatcher.h

@@ -50,16 +50,14 @@ class DHTMessageDispatcher {
 public:
   virtual ~DHTMessageDispatcher() = default;
 
-  virtual void
-  addMessageToQueue(std::unique_ptr<DHTMessage> message,
-                    std::chrono::seconds timeout,
-                    std::unique_ptr<DHTMessageCallback>
-                        callback = std::unique_ptr<DHTMessageCallback>{}) = 0;
+  virtual void addMessageToQueue(std::unique_ptr<DHTMessage> message,
+                                 std::chrono::seconds timeout,
+                                 std::unique_ptr<DHTMessageCallback> callback =
+                                     std::unique_ptr<DHTMessageCallback>{}) = 0;
 
-  virtual void
-  addMessageToQueue(std::unique_ptr<DHTMessage> message,
-                    std::unique_ptr<DHTMessageCallback>
-                        callback = std::unique_ptr<DHTMessageCallback>{}) = 0;
+  virtual void addMessageToQueue(std::unique_ptr<DHTMessage> message,
+                                 std::unique_ptr<DHTMessageCallback> callback =
+                                     std::unique_ptr<DHTMessageCallback>{}) = 0;
 
   virtual void sendMessages() = 0;
 

+ 9 - 8
src/DHTMessageDispatcherImpl.h

@@ -56,15 +56,16 @@ private:
 public:
   DHTMessageDispatcherImpl(const std::shared_ptr<DHTMessageTracker>& tracker);
 
-  virtual void addMessageToQueue(
-      std::unique_ptr<DHTMessage> message, std::chrono::seconds timeout,
-      std::unique_ptr<DHTMessageCallback>
-          callback = std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE;
+  virtual void
+  addMessageToQueue(std::unique_ptr<DHTMessage> message,
+                    std::chrono::seconds timeout,
+                    std::unique_ptr<DHTMessageCallback> callback =
+                        std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE;
 
-  virtual void addMessageToQueue(
-      std::unique_ptr<DHTMessage> message,
-      std::unique_ptr<DHTMessageCallback>
-          callback = std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE;
+  virtual void
+  addMessageToQueue(std::unique_ptr<DHTMessage> message,
+                    std::unique_ptr<DHTMessageCallback> callback =
+                        std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE;
 
   virtual void sendMessages() CXX11_OVERRIDE;
 

+ 2 - 1
src/DNSCache.h

@@ -98,7 +98,8 @@ private:
   };
 
   typedef std::set<std::shared_ptr<CacheEntry>,
-                   DerefLess<std::shared_ptr<CacheEntry>>> CacheEntrySet;
+                   DerefLess<std::shared_ptr<CacheEntry>>>
+      CacheEntrySet;
   CacheEntrySet entries_;
 
 public:

+ 20 - 18
src/DefaultBtAnnounce.cc

@@ -161,24 +161,26 @@ std::string DefaultBtAnnounce::getAnnounceUrl()
   const size_t keyLen = 8;
   std::string uri = announceList_.getAnnounce();
   uri += uriHasQuery(uri) ? "&" : "?";
-  uri += fmt("info_hash=%s&"
-             "peer_id=%s&"
-             "uploaded=%" PRId64 "&"
-             "downloaded=%" PRId64 "&"
-             "left=%" PRId64 "&"
-             "compact=1&"
-             "key=%s&"
-             "numwant=%d&"
-             "no_peer_id=1",
-             util::percentEncode(bittorrent::getInfoHash(downloadContext_),
-                                 INFO_HASH_LENGTH).c_str(),
-             util::percentEncode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH)
-                 .c_str(),
-             stat.getSessionUploadLength(), stat.getSessionDownloadLength(),
-             left, util::percentEncode(bittorrent::getStaticPeerId() +
-                                           PEER_ID_LENGTH - keyLen,
-                                       keyLen).c_str(),
-             numWant);
+  uri +=
+      fmt("info_hash=%s&"
+          "peer_id=%s&"
+          "uploaded=%" PRId64 "&"
+          "downloaded=%" PRId64 "&"
+          "left=%" PRId64 "&"
+          "compact=1&"
+          "key=%s&"
+          "numwant=%d&"
+          "no_peer_id=1",
+          util::percentEncode(bittorrent::getInfoHash(downloadContext_),
+                              INFO_HASH_LENGTH)
+              .c_str(),
+          util::percentEncode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH)
+              .c_str(),
+          stat.getSessionUploadLength(), stat.getSessionDownloadLength(), left,
+          util::percentEncode(
+              bittorrent::getStaticPeerId() + PEER_ID_LENGTH - keyLen, keyLen)
+              .c_str(),
+          numWant);
   if (tcpPort_) {
     uri += fmt("&port=%u", tcpPort_);
   }

+ 3 - 2
src/DefaultBtMessageReceiver.cc

@@ -88,8 +88,9 @@ DefaultBtMessageReceiver::receiveHandshake(bool quickReply)
     }
     else {
       throw DL_ABORT_EX(
-          fmt("Bad Info Hash %s", util::toHex(peerConnection_->getBuffer() + 28,
-                                              INFO_HASH_LENGTH).c_str()));
+          fmt("Bad Info Hash %s",
+              util::toHex(peerConnection_->getBuffer() + 28, INFO_HASH_LENGTH)
+                  .c_str()));
     }
     if (peerConnection_->getBufferLength() ==
             BtHandshakeMessage::MESSAGE_LENGTH &&

+ 2 - 2
src/DownloadEngine.cc

@@ -431,8 +431,8 @@ std::multimap<std::string, DownloadEngine::SocketPoolEntry>::iterator
 DownloadEngine::findSocketPoolEntry(const std::string& key)
 {
   std::pair<std::multimap<std::string, SocketPoolEntry>::iterator,
-            std::multimap<std::string, SocketPoolEntry>::iterator> range =
-      socketPool_.equal_range(key);
+            std::multimap<std::string, SocketPoolEntry>::iterator>
+      range = socketPool_.equal_range(key);
   for (auto i = range.first, eoi = range.second; i != eoi; ++i) {
     const SocketPoolEntry& e = (*i).second;
     // We assume that if socket is readable it means peer shutdowns

+ 2 - 1
src/EpollEventPoll.h

@@ -76,7 +76,8 @@ private:
   KSocketEntrySet socketEntries_;
 #ifdef ENABLE_ASYNC_DNS
   typedef std::map<std::pair<AsyncNameResolver*, Command*>,
-                   KAsyncNameResolverEntry> KAsyncNameResolverEntrySet;
+                   KAsyncNameResolverEntry>
+      KAsyncNameResolverEntrySet;
   KAsyncNameResolverEntrySet nameResolverEntries_;
 #endif // ENABLE_ASYNC_DNS
 

+ 6 - 5
src/FileAllocationCommand.cc

@@ -72,11 +72,12 @@ bool FileAllocationCommand::executeInternal()
   }
   fileAllocationEntry_->allocateChunk();
   if (fileAllocationEntry_->finished()) {
-    A2_LOG_DEBUG(fmt(MSG_ALLOCATION_COMPLETED,
-                     static_cast<long int>(
-                         std::chrono::duration_cast<std::chrono::seconds>(
-                             timer_.difference(global::wallclock())).count()),
-                     getRequestGroup()->getTotalLength()));
+    A2_LOG_DEBUG(fmt(
+        MSG_ALLOCATION_COMPLETED,
+        static_cast<long int>(std::chrono::duration_cast<std::chrono::seconds>(
+                                  timer_.difference(global::wallclock()))
+                                  .count()),
+        getRequestGroup()->getTotalLength()));
     std::vector<std::unique_ptr<Command>> commands;
     fileAllocationEntry_->prepareForNextAction(commands, getDownloadEngine());
     getDownloadEngine()->addCommand(std::move(commands));

+ 25 - 8
src/HttpHeader.cc

@@ -195,8 +195,8 @@ void HttpHeader::setReasonPhrase(const std::string& reasonPhrase)
 bool HttpHeader::fieldContains(int hdKey, const char* value)
 {
   std::pair<std::multimap<int, std::string>::const_iterator,
-            std::multimap<int, std::string>::const_iterator> range =
-      equalRange(hdKey);
+            std::multimap<int, std::string>::const_iterator>
+      range = equalRange(hdKey);
   for (auto i = range.first; i != range.second; ++i) {
     std::vector<Scip> values;
     util::splitIter((*i).second.begin(), (*i).second.end(),
@@ -221,12 +221,29 @@ bool HttpHeader::isKeepAlive() const
 
 namespace {
 const char* INTERESTING_HEADER_NAMES[] = {
-    "accept-encoding", "access-control-request-headers",
-    "access-control-request-method", "authorization", "connection",
-    "content-disposition", "content-encoding", "content-length",
-    "content-range", "content-type", "digest", "infohash", "last-modified",
-    "link", "location", "origin", "port", "retry-after", "sec-websocket-key",
-    "sec-websocket-version", "set-cookie", "transfer-encoding", "upgrade",
+    "accept-encoding",
+    "access-control-request-headers",
+    "access-control-request-method",
+    "authorization",
+    "connection",
+    "content-disposition",
+    "content-encoding",
+    "content-length",
+    "content-range",
+    "content-type",
+    "digest",
+    "infohash",
+    "last-modified",
+    "link",
+    "location",
+    "origin",
+    "port",
+    "retry-after",
+    "sec-websocket-key",
+    "sec-websocket-version",
+    "set-cookie",
+    "transfer-encoding",
+    "upgrade",
 };
 } // namespace
 

+ 8 - 5
src/IndexedList.h

@@ -50,10 +50,12 @@ template <typename SeqType, typename ValueType, typename ReferenceType,
           typename PointerType, typename SeqIteratorType>
 struct IndexedListIterator {
   typedef IndexedListIterator<SeqType, ValueType, ValueType&, ValueType*,
-                              typename SeqType::iterator> iterator;
+                              typename SeqType::iterator>
+      iterator;
   typedef IndexedListIterator<SeqType, ValueType, const ValueType&,
                               const ValueType*,
-                              typename SeqType::const_iterator> const_iterator;
+                              typename SeqType::const_iterator>
+      const_iterator;
 
   typedef typename SeqIteratorType::iterator_category iterator_category;
   typedef ValueType value_type;
@@ -314,11 +316,12 @@ public:
   typedef std::deque<std::pair<KeyType, ValuePtrType>> SeqType;
 
   typedef IndexedListIterator<SeqType, ValuePtrType, ValuePtrType&,
-                              ValuePtrType*,
-                              typename SeqType::iterator> iterator;
+                              ValuePtrType*, typename SeqType::iterator>
+      iterator;
   typedef IndexedListIterator<SeqType, ValuePtrType, const ValuePtrType&,
                               const ValuePtrType*,
-                              typename SeqType::const_iterator> const_iterator;
+                              typename SeqType::const_iterator>
+      const_iterator;
 
   ValuePtrType& operator[](size_t n) { return seq_[n].second; }
 

+ 1 - 2
src/InitiateConnectionCommandFactory.cc

@@ -56,8 +56,7 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand(
   if (req->getProtocol() == "http"
 #ifdef ENABLE_SSL
       // for SSL
-      ||
-      req->getProtocol() == "https"
+      || req->getProtocol() == "https"
 #endif // ENABLE_SSL
       ) {
 

+ 2 - 1
src/KqueueEventPoll.h

@@ -81,7 +81,8 @@ private:
   KSocketEntrySet socketEntries_;
 #ifdef ENABLE_ASYNC_DNS
   typedef std::map<std::pair<AsyncNameResolver*, Command*>,
-                   KAsyncNameResolverEntry> KAsyncNameResolverEntrySet;
+                   KAsyncNameResolverEntry>
+      KAsyncNameResolverEntrySet;
   KAsyncNameResolverEntrySet nameResolverEntries_;
 #endif // ENABLE_ASYNC_DNS
 

+ 2 - 1
src/LibuvEventPoll.h

@@ -115,7 +115,8 @@ private:
 
 #ifdef ENABLE_ASYNC_DNS
   typedef std::map<std::pair<AsyncNameResolver*, Command*>,
-                   KAsyncNameResolverEntry> KAsyncNameResolverEntrySet;
+                   KAsyncNameResolverEntry>
+      KAsyncNameResolverEntrySet;
 #endif // ENABLE_ASYNC_DNS
 
   uv_loop_t* loop_;

+ 6 - 6
src/OptionHandlerFactory.cc

@@ -299,21 +299,21 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
 #endif // defined(HAVE_EPOLL)
                                                  {
 #ifdef HAVE_EPOLL
-                                                  V_EPOLL,
+                                                     V_EPOLL,
 #endif // HAVE_EPOLL
 #ifdef HAVE_KQUEUE
-                                                  V_KQUEUE,
+                                                     V_KQUEUE,
 #endif // HAVE_KQUEUE
 #ifdef HAVE_PORT_ASSOCIATE
-                                                  V_PORT,
+                                                     V_PORT,
 #endif // HAVE_PORT_ASSOCIATE
 #ifdef HAVE_LIBUV
-                                                  V_LIBUV,
+                                                     V_LIBUV,
 #endif // HAVE_LIBUV
 #ifdef HAVE_POLL
-                                                  V_POLL,
+                                                     V_POLL,
 #endif // HAVE_POLL
-                                                  V_SELECT}));
+                                                     V_SELECT}));
     op->addTag(TAG_ADVANCED);
     handlers.push_back(op);
   }

+ 2 - 1
src/PollEventPoll.h

@@ -76,7 +76,8 @@ private:
   KSocketEntrySet socketEntries_;
 #ifdef ENABLE_ASYNC_DNS
   typedef std::map<std::pair<AsyncNameResolver*, Command*>,
-                   KAsyncNameResolverEntry> KAsyncNameResolverEntrySet;
+                   KAsyncNameResolverEntry>
+      KAsyncNameResolverEntrySet;
   KAsyncNameResolverEntrySet nameResolverEntries_;
 #endif // ENABLE_ASYNC_DNS
 

+ 2 - 1
src/PortEventPoll.h

@@ -77,7 +77,8 @@ private:
 
 private:
   typedef std::set<std::shared_ptr<KSocketEntry>,
-                   DerefLess<std::shared_ptr<KSocketEntry>>> KSocketEntrySet;
+                   DerefLess<std::shared_ptr<KSocketEntry>>>
+      KSocketEntrySet;
   KSocketEntrySet socketEntries_;
 #ifdef ENABLE_ASYNC_DNS
   typedef std::set<std::shared_ptr<KAsyncNameResolverEntry>,

+ 2 - 1
src/RequestGroupMan.cc

@@ -777,7 +777,8 @@ void formatDownloadResultCommon(
   if (downloadResult->sessionTime.count() > 0) {
     o << std::setw(8)
       << util::abbrevSize(downloadResult->sessionDownloadLength * 1000 /
-                          downloadResult->sessionTime.count()) << "B/s";
+                          downloadResult->sessionTime.count())
+      << "B/s";
   }
   else {
     o << std::setw(11);

+ 33 - 11
src/RpcMethodFactory.cc

@@ -53,21 +53,43 @@ namespace {
 std::vector<std::string> rpcMethodNames = {
     "aria2.addUri",
 #ifdef ENABLE_BITTORRENT
-    "aria2.addTorrent", "aria2.getPeers",
+    "aria2.addTorrent",
+    "aria2.getPeers",
 #endif // ENABLE_BITTORRENT
 #ifdef ENABLE_METALINK
     "aria2.addMetalink",
 #endif // ENABLE_METALINK
-    "aria2.remove", "aria2.pause", "aria2.forcePause", "aria2.pauseAll",
-    "aria2.forcePauseAll", "aria2.unpause", "aria2.unpauseAll",
-    "aria2.forceRemove", "aria2.changePosition", "aria2.tellStatus",
-    "aria2.getUris", "aria2.getFiles", "aria2.getServers", "aria2.tellActive",
-    "aria2.tellWaiting", "aria2.tellStopped", "aria2.getOption",
-    "aria2.changeUri", "aria2.changeOption", "aria2.getGlobalOption",
-    "aria2.changeGlobalOption", "aria2.purgeDownloadResult",
-    "aria2.removeDownloadResult", "aria2.getVersion", "aria2.getSessionInfo",
-    "aria2.shutdown", "aria2.forceShutdown", "aria2.getGlobalStat",
-    "aria2.saveSession", "system.multicall", "system.listMethods",
+    "aria2.remove",
+    "aria2.pause",
+    "aria2.forcePause",
+    "aria2.pauseAll",
+    "aria2.forcePauseAll",
+    "aria2.unpause",
+    "aria2.unpauseAll",
+    "aria2.forceRemove",
+    "aria2.changePosition",
+    "aria2.tellStatus",
+    "aria2.getUris",
+    "aria2.getFiles",
+    "aria2.getServers",
+    "aria2.tellActive",
+    "aria2.tellWaiting",
+    "aria2.tellStopped",
+    "aria2.getOption",
+    "aria2.changeUri",
+    "aria2.changeOption",
+    "aria2.getGlobalOption",
+    "aria2.changeGlobalOption",
+    "aria2.purgeDownloadResult",
+    "aria2.removeDownloadResult",
+    "aria2.getVersion",
+    "aria2.getSessionInfo",
+    "aria2.shutdown",
+    "aria2.forceShutdown",
+    "aria2.getGlobalStat",
+    "aria2.saveSession",
+    "system.multicall",
+    "system.listMethods",
     "system.listNotifications",
 };
 } // namespace

+ 2 - 1
src/SelectEventPoll.h

@@ -156,7 +156,8 @@ private:
   SocketEntrySet socketEntries_;
 #ifdef ENABLE_ASYNC_DNS
   typedef std::map<std::pair<AsyncNameResolver*, Command*>,
-                   AsyncNameResolverEntry> AsyncNameResolverEntrySet;
+                   AsyncNameResolverEntry>
+      AsyncNameResolverEntrySet;
   AsyncNameResolverEntrySet nameResolverEntries_;
 #endif // ENABLE_ASYNC_DNS
 

+ 2 - 1
src/ServerStatMan.h

@@ -66,7 +66,8 @@ public:
 
 private:
   typedef std::set<std::shared_ptr<ServerStat>,
-                   DerefLess<std::shared_ptr<ServerStat>>> ServerStatSet;
+                   DerefLess<std::shared_ptr<ServerStat>>>
+      ServerStatSet;
   ServerStatSet serverStats_;
 };
 

+ 1 - 2
src/SimpleRandomizer.cc

@@ -107,8 +107,7 @@ void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len)
          * check out. If the call failed, we'll not take this branch at all
          * and disable support below.
          */
-        ||
-        errno != ENOSYS
+        || errno != ENOSYS
 #endif
         ) {
       if (rv < -1) {

+ 6 - 3
src/SpeedCalc.cc

@@ -75,7 +75,8 @@ int SpeedCalc::calculateSpeed()
     return 0;
   }
   auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
-                     timeSlots_[0].first.difference(now)).count();
+                     timeSlots_[0].first.difference(now))
+                     .count();
   if (elapsed <= 0) {
     elapsed = 1;
   }
@@ -102,7 +103,8 @@ int SpeedCalc::calculateNewestSpeed(int seconds)
   }
 
   auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
-                     (*--it).first.difference(now)).count();
+                     (*--it).first.difference(now))
+                     .count();
   if (elapsed <= 0) {
     elapsed = 1;
   }
@@ -128,7 +130,8 @@ void SpeedCalc::update(size_t bytes)
 int SpeedCalc::calculateAvgSpeed() const
 {
   auto milliElapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
-                          start_.difference(global::wallclock())).count();
+                          start_.difference(global::wallclock()))
+                          .count();
   // if milliElapsed is too small, the average speed is rubbish, better
   // return 0
   if (milliElapsed > 4) {

+ 1 - 2
src/TimerA2.h

@@ -55,8 +55,7 @@ public:
   Timer(Timer&& time) = default;
 
   template <typename duration>
-  constexpr explicit Timer(const duration& t)
-      : tp_(t)
+  constexpr explicit Timer(const duration& t) : tp_(t)
   {
   }
 

+ 1 - 2
src/ValueBase.h

@@ -87,8 +87,7 @@ public:
   String(const unsigned char* data, size_t length);
 
   template <typename InputIterator>
-  String(InputIterator first, InputIterator last)
-      : str_(first, last)
+  String(InputIterator first, InputIterator last) : str_(first, last)
   {
   }
 

+ 2 - 2
src/a2netcompat.h

@@ -44,14 +44,14 @@
 #endif // __MINGW32__
 
 #ifdef __MINGW32__
-#define a2_sockopt_t char *
+#define a2_sockopt_t char*
 #ifndef HAVE_GETADDRINFO
 #define HAVE_GETADDRINFO
 #endif // !HAVE_GETADDRINFO
 #undef HAVE_GAI_STRERROR
 #undef gai_strerror
 #else
-#define a2_sockopt_t void *
+#define a2_sockopt_t void*
 #endif // __MINGW32__
 
 #ifdef HAVE_NETDB_H

+ 2 - 2
src/alloca.c

@@ -61,7 +61,7 @@ you lose-- must know STACK_DIRECTION at compile - time
 #if defined(CRAY) && defined(CRAY_STACKSEG_END)
     long
     i00afunc();
-#define ADDRESS_FUNCTION(arg) (char*) i00afunc(&(arg))
+#define ADDRESS_FUNCTION(arg) (char*)i00afunc(&(arg))
 #else
 #define ADDRESS_FUNCTION(arg) &(arg)
 #endif
@@ -344,7 +344,7 @@ static long i00afunc(long* address)
 {
   struct stk_stat status;
   struct stk_trailer* trailer;
-  long* block, size;
+  long *block, size;
   long result = 0;
 
   /* We want to iterate through all of the segments.  The first

+ 1 - 1
src/array_fun.h

@@ -42,7 +42,7 @@
 
 namespace aria2 {
 
-template <typename T, size_t N> constexpr size_t arraySize(T(&)[N])
+template <typename T, size_t N> constexpr size_t arraySize(T (&)[N])
 {
   return N;
 }

+ 1 - 1
src/bignum.h

@@ -196,7 +196,7 @@ public:
   }
   ulong<dim>& operator*=(const ulong<dim>& rhs)
   {
-    *this = *this* rhs;
+    *this = *this * rhs;
     return *this;
   }
 

+ 1 - 2
src/cookie_helper.cc

@@ -135,8 +135,7 @@ bool parseDate(time_t& time, std::string::const_iterator first,
       minute = getInteger(hEnd + 1, mEnd);
       second = getInteger(mEnd + 1, sEnd);
       continue;
-    NOT_TIME:
-      ;
+    NOT_TIME:;
     }
     if (!foundDayOfMonth) {
       std::string::const_iterator j = getNextDigit((*i).begin(), (*i).end());

+ 4 - 12
src/crypto_hash.cc

@@ -1032,18 +1032,10 @@ static const std::set<std::string> names{
 
 // For fast name |lookup|
 static const std::unordered_map<std::string, Algorithms> mapped{
-    {"md5", algoMD5},
-    {"sha", algoSHA1},
-    {"sha1", algoSHA1},
-    {"sha-1", algoSHA1},
-    {"sha224", algoSHA224},
-    {"sha-224", algoSHA224},
-    {"sha256", algoSHA256},
-    {"sha-256", algoSHA256},
-    {"sha384", algoSHA384},
-    {"sha-384", algoSHA384},
-    {"sha512", algoSHA512},
-    {"sha-512", algoSHA512},
+    {"md5", algoMD5},        {"sha", algoSHA1},       {"sha1", algoSHA1},
+    {"sha-1", algoSHA1},     {"sha224", algoSHA224},  {"sha-224", algoSHA224},
+    {"sha256", algoSHA256},  {"sha-256", algoSHA256}, {"sha384", algoSHA384},
+    {"sha-384", algoSHA384}, {"sha512", algoSHA512},  {"sha-512", algoSHA512},
 };
 static const auto mapped_end = mapped.end();
 } // namespace

+ 6 - 7
src/uri_split.c

@@ -74,13 +74,12 @@ static int is_digit(char c) { return '0' <= c && c <= '9'; }
 int uri_split(uri_split_result* res, const char* uri)
 {
   int state = URI_BEFORE_SCHEME;
-  const char* scheme_first = NULL, * scheme_last = NULL, * host_first = NULL,
-              * host_last = NULL, * path_first = NULL, * path_last = NULL,
-              * query_first = NULL, * query_last = NULL,
-              * fragment_first = NULL, * fragment_last = NULL,
-              * user_first = NULL, * user_last = NULL, * passwd_first = NULL,
-              * passwd_last = NULL, * last_atmark = NULL, * last_slash = NULL,
-              * p = uri;
+  const char *scheme_first = NULL, *scheme_last = NULL, *host_first = NULL,
+             *host_last = NULL, *path_first = NULL, *path_last = NULL,
+             *query_first = NULL, *query_last = NULL, *fragment_first = NULL,
+             *fragment_last = NULL, *user_first = NULL, *user_last = NULL,
+             *passwd_first = NULL, *passwd_last = NULL, *last_atmark = NULL,
+             *last_slash = NULL, *p = uri;
   int32_t port = -1;
   uint8_t flags = 0;
 

+ 21 - 24
src/util.cc

@@ -547,7 +547,7 @@ bool parseLong(T& res, F f, const std::string& s, int base)
     return false;
   }
   if (*endptr != '\0') {
-    for (const char* i = endptr, * eoi = s.c_str() + s.size(); i < eoi; ++i) {
+    for (const char *i = endptr, *eoi = s.c_str() + s.size(); i < eoi; ++i) {
       if (!isspace(*i)) {
         return false;
       }
@@ -750,7 +750,7 @@ void parsePrioritizePieceRange(
 std::string iso8859p1ToUtf8(const char* src, size_t len)
 {
   std::string dest;
-  for (const char* p = src, * last = src + len; p != last; ++p) {
+  for (const char *p = src, *last = src + len; p != last; ++p) {
     unsigned char c = *p;
     if (0xa0u <= c) {
       if (c <= 0xbfu) {
@@ -810,31 +810,28 @@ static const uint8_t utf8d[] = {
      * The first part of the table maps bytes to character classes that
      * to reduce the size of the transition table and create bitmasks.
      */
-    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1,
-    1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  9,  9,  9,  9,  9,  9,  9,  9,
-    9,  9,  9,  9,  9,  9,  9,  9,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
-    7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
-    7,  7,  8,  8,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
-    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  10, 3,  3,  3,
-    3,  3,  3,  3,  3,  3,  3,  3,  3,  4,  3,  3,  11, 6,  6,  6,  5,  8,  8,
-    8,  8,  8,  8,  8,  8,  8,  8,  8,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9,
+    9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 2, 2, 2, 2, 2, 2,
+    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 10,
+    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 11, 6, 6, 6, 5, 8, 8, 8, 8, 8,
+    8, 8, 8, 8, 8, 8,
 
     /*
      * The second part is a transition table that maps a combination
      * of a state of the automaton and a character class to a state.
      */
-    0,  12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12,
-    12, 12, 12, 12, 12, 12, 0,  12, 12, 12, 12, 12, 0,  12, 0,  12, 12, 12, 24,
-    12, 12, 12, 12, 12, 24, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 24, 12,
-    12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12,
-    12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 36, 12, 36, 12,
-    12, 12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+    0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12,
+    12, 12, 12, 12, 12, 12, 0, 12, 12, 12, 12, 12, 0, 12, 0, 12, 12, 12, 24, 12,
+    12, 12, 12, 12, 24, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12,
+    12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12,
+    12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12,
+    12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
 };
 
 static uint32_t utf8dfa(uint32_t* state, uint32_t* codep, uint32_t byte)
@@ -884,8 +881,8 @@ ssize_t parse_content_disposition(char* dest, size_t destlen,
                                   const char** charsetp, size_t* charsetlenp,
                                   const char* in, size_t len)
 {
-  const char* p = in, * eop = in + len, * mark_first = nullptr,
-              * mark_last = nullptr;
+  const char *p = in, *eop = in + len, *mark_first = nullptr,
+             *mark_last = nullptr;
   int state = CD_BEFORE_DISPOSITION_TYPE;
   int in_file_parm = 0;
   int flags = 0;

+ 15 - 11
src/version_usage.cc

@@ -67,14 +67,17 @@ void showVersion()
            "This program is distributed in the hope that it will be useful,\n"
            "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
            "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
-           "GNU General Public License for more details.\n") << "\n"
-      << _("** Configuration **") << "\n" << _("Enabled Features") << ": "
-      << featureSummary() << "\n" << _("Hash Algorithms") << ": "
-      << MessageDigest::getSupportedHashTypeString() << "\n" << _("Libraries")
-      << ": " << usedLibs() << "\n" << _("Compiler") << ": "
-      << usedCompilerAndPlatform() << "\n" << _("System") << ": "
-      << getOperatingSystemInfo() << "\n"
-      << "\n" << fmt(_("Report bugs to %s"), PACKAGE_BUGREPORT) << "\n"
+           "GNU General Public License for more details.\n")
+      << "\n"
+      << _("** Configuration **") << "\n"
+      << _("Enabled Features") << ": " << featureSummary() << "\n"
+      << _("Hash Algorithms") << ": "
+      << MessageDigest::getSupportedHashTypeString() << "\n"
+      << _("Libraries") << ": " << usedLibs() << "\n"
+      << _("Compiler") << ": " << usedCompilerAndPlatform() << "\n"
+      << _("System") << ": " << getOperatingSystemInfo() << "\n"
+      << "\n"
+      << fmt(_("Report bugs to %s"), PACKAGE_BUGREPORT) << "\n"
       << _("Visit") << " " << PACKAGE_URL << std::endl;
 }
 
@@ -105,8 +108,9 @@ void showUsage(const std::string& keyword,
     out->printf("\n");
     out->printf(_("Options:"));
     out->printf("\n");
-    for (std::vector<const OptionHandler*>::const_iterator i = handlers.begin(),
-                                                           eoi = handlers.end();
+    for (std::vector<const OptionHandler *>::const_iterator
+             i = handlers.begin(),
+             eoi = handlers.end();
          i != eoi; ++i) {
       write(out, *(*i));
       out->printf("\n");
@@ -121,7 +125,7 @@ void showUsage(const std::string& keyword,
       out->printf("\n");
       out->printf(_("Options:"));
       out->printf("\n");
-      for (std::vector<const OptionHandler*>::const_iterator
+      for (std::vector<const OptionHandler *>::const_iterator
                i = handlers.begin(),
                eoi = handlers.end();
            i != eoi; ++i) {

+ 4 - 4
test/BtRegistryTest.cc

@@ -70,10 +70,10 @@ void BtRegistryTest::testGetDownloadContext_infoHash()
     attrs1->infoHash = "hash1";
     auto attrs2 = make_unique<TorrentAttribute>();
     attrs2->infoHash = "hash2";
-    btRegistry.getDownloadContext(1)
-        ->setAttribute(CTX_ATTR_BT, std::move(attrs1));
-    btRegistry.getDownloadContext(2)
-        ->setAttribute(CTX_ATTR_BT, std::move(attrs2));
+    btRegistry.getDownloadContext(1)->setAttribute(CTX_ATTR_BT,
+                                                   std::move(attrs1));
+    btRegistry.getDownloadContext(2)->setAttribute(CTX_ATTR_BT,
+                                                   std::move(attrs2));
   }
   CPPUNIT_ASSERT(btRegistry.getDownloadContext("hash1"));
   CPPUNIT_ASSERT(btRegistry.getDownloadContext("hash1").get() ==

+ 6 - 4
test/CookieStorageTest.cc

@@ -77,8 +77,9 @@ void CookieStorageTest::testStore()
   CPPUNIT_ASSERT_EQUAL((size_t)1, st.size());
   CPPUNIT_ASSERT(st.contains(*goodCookie()));
 
-  auto anotherCookie =
-      []() { return createCookie("k", "v", "mirror", true, "/", true); };
+  auto anotherCookie = []() {
+    return createCookie("k", "v", "mirror", true, "/", true);
+  };
   CPPUNIT_ASSERT(st.store(anotherCookie(), now));
   CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
   CPPUNIT_ASSERT(st.contains(*anotherCookie()));
@@ -107,8 +108,9 @@ void CookieStorageTest::testStore()
   CPPUNIT_ASSERT_EQUAL((size_t)1, st.size());
   CPPUNIT_ASSERT(st.contains(*anotherCookie()));
 
-  auto fromNumericHost =
-      []() { return createCookie("k", "v", "192.168.1.1", true, "/", false); };
+  auto fromNumericHost = []() {
+    return createCookie("k", "v", "192.168.1.1", true, "/", false);
+  };
   CPPUNIT_ASSERT(st.store(fromNumericHost(), now));
   CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
   CPPUNIT_ASSERT(st.contains(*fromNumericHost()));

+ 1 - 1
test/IndexedListTest.cc

@@ -109,7 +109,7 @@ void IndexedListTest::testErase()
     CPPUNIT_ASSERT_EQUAL((size_t)(std::distance(i, list.end())), list.size());
 
     int* pp = ++p;
-    for (IndexedList<int, int*>::iterator j = list.begin(); j != list.end();
+    for (IndexedList<int, int *>::iterator j = list.begin(); j != list.end();
          ++j, ++pp) {
       CPPUNIT_ASSERT_EQUAL(*pp, **j);
     }

+ 9 - 8
test/MockDHTMessageDispatcher.h

@@ -29,19 +29,20 @@ public:
 public:
   MockDHTMessageDispatcher() {}
 
-  virtual void addMessageToQueue(
-      std::unique_ptr<DHTMessage> message, std::chrono::seconds timeout,
-      std::unique_ptr<DHTMessageCallback>
-          callback = std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE
+  virtual void
+  addMessageToQueue(std::unique_ptr<DHTMessage> message,
+                    std::chrono::seconds timeout,
+                    std::unique_ptr<DHTMessageCallback> callback =
+                        std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE
   {
     messageQueue_.push_back(
         Entry(std::move(message), std::move(timeout), std::move(callback)));
   }
 
-  virtual void addMessageToQueue(
-      std::unique_ptr<DHTMessage> message,
-      std::unique_ptr<DHTMessageCallback>
-          callback = std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE
+  virtual void
+  addMessageToQueue(std::unique_ptr<DHTMessage> message,
+                    std::unique_ptr<DHTMessageCallback> callback =
+                        std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE
   {
     messageQueue_.push_back(
         Entry(std::move(message), DHT_MESSAGE_TIMEOUT, std::move(callback)));

+ 32 - 25
test/RpcMethodTest.cc

@@ -340,14 +340,15 @@ RpcRequest createAddTorrentReq()
 void RpcMethodTest::testAddTorrent()
 {
   File(e_->getOption()->get(PREF_DIR) +
-       "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").remove();
+       "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent")
+      .remove();
   AddTorrentRpcMethod m;
   {
     // Saving upload metadata is disabled by option.
     auto res = m.execute(createAddTorrentReq(), e_.get());
-    CPPUNIT_ASSERT(
-        !File(e_->getOption()->get(PREF_DIR) +
-              "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").exists());
+    CPPUNIT_ASSERT(!File(e_->getOption()->get(PREF_DIR) +
+                         "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent")
+                        .exists());
     CPPUNIT_ASSERT_EQUAL(0, res.code);
     CPPUNIT_ASSERT_EQUAL(sizeof(a2_gid_t) * 2,
                          downcast<String>(res.param)->s().size());
@@ -355,9 +356,9 @@ void RpcMethodTest::testAddTorrent()
   e_->getOption()->put(PREF_RPC_SAVE_UPLOAD_METADATA, A2_V_TRUE);
   {
     auto res = m.execute(createAddTorrentReq(), e_.get());
-    CPPUNIT_ASSERT(
-        File(e_->getOption()->get(PREF_DIR) +
-             "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").exists());
+    CPPUNIT_ASSERT(File(e_->getOption()->get(PREF_DIR) +
+                        "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent")
+                       .exists());
     CPPUNIT_ASSERT_EQUAL(0, res.code);
     a2_gid_t gid;
     CPPUNIT_ASSERT_EQUAL(
@@ -457,7 +458,8 @@ RpcRequest createAddMetalinkReq()
 void RpcMethodTest::testAddMetalink()
 {
   File(e_->getOption()->get(PREF_DIR) +
-       "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").remove();
+       "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
+      .remove();
   AddMetalinkRpcMethod m;
   {
     // Saving upload metadata is disabled by option.
@@ -472,9 +474,9 @@ void RpcMethodTest::testAddMetalink()
     CPPUNIT_ASSERT_EQUAL(
         0, GroupId::toNumericId(
                gid2, downcast<String>(resParams->get(1))->s().c_str()));
-    CPPUNIT_ASSERT(
-        !File(e_->getOption()->get(PREF_DIR) +
-              "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists());
+    CPPUNIT_ASSERT(!File(e_->getOption()->get(PREF_DIR) +
+                         "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
+                        .exists());
   }
   e_->getOption()->put(PREF_RPC_SAVE_UPLOAD_METADATA, A2_V_TRUE);
   {
@@ -489,9 +491,9 @@ void RpcMethodTest::testAddMetalink()
     CPPUNIT_ASSERT_EQUAL(
         0, GroupId::toNumericId(
                gid4, downcast<String>(resParams->get(1))->s().c_str()));
-    CPPUNIT_ASSERT(
-        File(e_->getOption()->get(PREF_DIR) +
-             "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists());
+    CPPUNIT_ASSERT(File(e_->getOption()->get(PREF_DIR) +
+                        "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
+                       .exists());
 
     auto tar = findReservedGroup(e_->getRequestGroupMan().get(), gid3);
     CPPUNIT_ASSERT(tar);
@@ -1018,8 +1020,10 @@ void RpcMethodTest::testGatherProgressCommon()
   CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"),
                        downcast<String>(file->get("path"))->s());
   CPPUNIT_ASSERT_EQUAL(
-      uris[0], downcast<String>(downcast<Dict>(downcast<List>(file->get("uris"))
-                                                   ->get(0))->get("uri"))->s());
+      uris[0],
+      downcast<String>(
+          downcast<Dict>(downcast<List>(file->get("uris"))->get(0))->get("uri"))
+          ->s());
   CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR),
                        downcast<String>(entry->get("dir"))->s());
 
@@ -1389,15 +1393,18 @@ void RpcMethodTest::testSystemMulticall()
   CPPUNIT_ASSERT_EQUAL(
       GroupId::toHex(getReservedGroup(rgman.get(), 1)->getGID()),
       downcast<String>(downcast<List>(resParams->get(1))->get(0))->s());
-  CPPUNIT_ASSERT_EQUAL((int64_t)1,
-                       downcast<Integer>(downcast<Dict>(resParams->get(2))
-                                             ->get("faultCode"))->i());
-  CPPUNIT_ASSERT_EQUAL((int64_t)1,
-                       downcast<Integer>(downcast<Dict>(resParams->get(3))
-                                             ->get("faultCode"))->i());
-  CPPUNIT_ASSERT_EQUAL((int64_t)1,
-                       downcast<Integer>(downcast<Dict>(resParams->get(4))
-                                             ->get("faultCode"))->i());
+  CPPUNIT_ASSERT_EQUAL(
+      (int64_t)1,
+      downcast<Integer>(downcast<Dict>(resParams->get(2))->get("faultCode"))
+          ->i());
+  CPPUNIT_ASSERT_EQUAL(
+      (int64_t)1,
+      downcast<Integer>(downcast<Dict>(resParams->get(3))->get("faultCode"))
+          ->i());
+  CPPUNIT_ASSERT_EQUAL(
+      (int64_t)1,
+      downcast<Integer>(downcast<Dict>(resParams->get(4))->get("faultCode"))
+          ->i());
   CPPUNIT_ASSERT(downcast<List>(resParams->get(5)));
   CPPUNIT_ASSERT(downcast<List>(resParams->get(6)));
 }

+ 37 - 37
test/UtilSecurityTest.cc

@@ -24,7 +24,7 @@ static struct hmachash {
               "\x0b\x0b\x0b\x0b\x0b"},
      {20},
      {
-      "\x48\x69\x20\x54\x68\x65\x72\x65" /* "Hi There" */
+         "\x48\x69\x20\x54\x68\x65\x72\x65" /* "Hi There" */
      },
      {8},
      {/* HMAC-SHA-1 */
@@ -48,9 +48,9 @@ static struct hmachash {
      },
      {4},
      {
-      "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74"
-      "\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"
-      /* "what do ya want for nothing?" */
+         "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74"
+         "\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"
+         /* "what do ya want for nothing?" */
      },
      {28},
      {/* HMAC-SHA-1 */
@@ -173,22 +173,22 @@ static struct hmachash {
               "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"},
      {80, 131},
      {
-      "Test Using Larger Than Block-Size Key and "
-      "Larger Than One Block-Size Data",
-      "\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x74\x65\x73\x74\x20"
-      "\x75\x73\x69\x6e\x67\x20\x61\x20\x6c\x61\x72\x67\x65\x72\x20"
-      "\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73\x69\x7a\x65"
-      "\x20\x6b\x65\x79\x20\x61\x6e\x64\x20\x61\x20\x6c\x61\x72\x67"
-      "\x65\x72\x20\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73"
-      "\x69\x7a\x65\x20\x64\x61\x74\x61\x2e\x20\x54\x68\x65\x20\x6b"
-      "\x65\x79\x20\x6e\x65\x65\x64\x73\x20\x74\x6f\x20\x62\x65\x20"
-      "\x68\x61\x73\x68\x65\x64\x20\x62\x65\x66\x6f\x72\x65\x20\x62"
-      "\x65\x69\x6e\x67\x20\x75\x73\x65\x64\x20\x62\x79\x20\x74\x68"
-      "\x65\x20\x48\x4d\x41\x43\x20\x61\x6c\x67\x6f\x72\x69\x74\x68"
-      "\x6d\x2e"
-      /* "This is a test using a larger than block-size key and a "
-          "larger than block-size data.  The key needs to be hashed "
-          "before being used by the HMAC algorithm." */
+         "Test Using Larger Than Block-Size Key and "
+         "Larger Than One Block-Size Data",
+         "\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x74\x65\x73\x74\x20"
+         "\x75\x73\x69\x6e\x67\x20\x61\x20\x6c\x61\x72\x67\x65\x72\x20"
+         "\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73\x69\x7a\x65"
+         "\x20\x6b\x65\x79\x20\x61\x6e\x64\x20\x61\x20\x6c\x61\x72\x67"
+         "\x65\x72\x20\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73"
+         "\x69\x7a\x65\x20\x64\x61\x74\x61\x2e\x20\x54\x68\x65\x20\x6b"
+         "\x65\x79\x20\x6e\x65\x65\x64\x73\x20\x74\x6f\x20\x62\x65\x20"
+         "\x68\x61\x73\x68\x65\x64\x20\x62\x65\x66\x6f\x72\x65\x20\x62"
+         "\x65\x69\x6e\x67\x20\x75\x73\x65\x64\x20\x62\x79\x20\x74\x68"
+         "\x65\x20\x48\x4d\x41\x43\x20\x61\x6c\x67\x6f\x72\x69\x74\x68"
+         "\x6d\x2e"
+         /* "This is a test using a larger than block-size key and a "
+             "larger than block-size data.  The key needs to be hashed "
+             "before being used by the HMAC algorithm." */
      },
      {73, 152},
      {/* HMAC-SHA-1 */
@@ -342,32 +342,32 @@ static struct pbkdf2 {
      "salt",
      4,
      1,
-     {0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9, 0xb5, 0x24,
-      0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6},
+     {0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9,
+      0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6},
      20},
     {"password",
      8,
      "salt",
      4,
      1,
-     {0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9, 0xb5, 0x24,
-      0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6},
+     {0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9,
+      0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6},
      0},
     {"password",
      8,
      "salt",
      4,
      2,
-     {0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c, 0xcd, 0x1e, 0xd9, 0x2a,
-      0xce, 0x1d, 0x41, 0xf0, 0xd8, 0xde, 0x89, 0x57},
+     {0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c, 0xcd, 0x1e,
+      0xd9, 0x2a, 0xce, 0x1d, 0x41, 0xf0, 0xd8, 0xde, 0x89, 0x57},
      20},
     {"password",
      8,
      "salt",
      4,
      4096,
-     {0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a, 0xbe, 0xad, 0x49, 0xd9,
-      0x26, 0xf7, 0x21, 0xd0, 0x65, 0xa4, 0x29, 0xc1},
+     {0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a, 0xbe, 0xad,
+      0x49, 0xd9, 0x26, 0xf7, 0x21, 0xd0, 0x65, 0xa4, 0x29, 0xc1},
      20},
     /* Disabled due to #236
     {
@@ -380,15 +380,15 @@ static struct pbkdf2 {
     },
     */
     {
-     "passwordPASSWORDpassword",
-     24,
-     "saltSALTsaltSALTsaltSALTsaltSALTsalt",
-     36,
-     4096,
-     {0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b, 0x80, 0xc8, 0xd8, 0x36,
-      0x62, 0xc0, 0xe4, 0x4a, 0x8b, 0x29, 0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70,
-      0x38},
-     25,
+        "passwordPASSWORDpassword",
+        24,
+        "saltSALTsaltSALTsaltSALTsaltSALTsalt",
+        36,
+        4096,
+        {0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b, 0x80,
+         0xc8, 0xd8, 0x36, 0x62, 0xc0, 0xe4, 0x4a, 0x8b, 0x29,
+         0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70, 0x38},
+        25,
     },
     {"pass\0word",
      9,

+ 3 - 2
test/UtilTest2.cc

@@ -670,8 +670,9 @@ void UtilTest2::testGenerateRandomData()
   double mean = sum / counts.size();
   vector<double> diff(counts.size());
   transform(counts.begin(), counts.end(), diff.begin(),
-            [&](const decltype(counts)::value_type& elem)
-                -> double { return (double)elem.second - mean; });
+            [&](const decltype(counts)::value_type& elem) -> double {
+              return (double)elem.second - mean;
+            });
   double sq_sum = inner_product(diff.begin(), diff.end(), diff.begin(), 0.0);
   double stddev = sqrt(sq_sum / counts.size());
   cout << "stddev: " << fixed << stddev << endl;

+ 3 - 3
test/ValueBaseJsonParserTest.cc

@@ -177,13 +177,13 @@ void ValueBaseJsonParserTest::testParseUpdate()
     const Integer* i = downcast<Integer>(list->get(0));
     CPPUNIT_ASSERT_EQUAL((Integer::ValueType)0, i->i());
     const Integer* i1 = downcast<Integer>(list->get(1));
-    CPPUNIT_ASSERT_EQUAL((Integer::ValueType) - 1, i1->i());
+    CPPUNIT_ASSERT_EQUAL((Integer::ValueType)-1, i1->i());
     const Integer* i2 = downcast<Integer>(list->get(2));
     CPPUNIT_ASSERT_EQUAL((Integer::ValueType)1, i2->i());
     const Integer* i3 = downcast<Integer>(list->get(3));
-    CPPUNIT_ASSERT_EQUAL((Integer::ValueType) - 1, i3->i());
+    CPPUNIT_ASSERT_EQUAL((Integer::ValueType)-1, i3->i());
     const Integer* i4 = downcast<Integer>(list->get(4));
-    CPPUNIT_ASSERT_EQUAL((Integer::ValueType) - 1, i4->i());
+    CPPUNIT_ASSERT_EQUAL((Integer::ValueType)-1, i4->i());
   }
   {
     // escape chars: ", \, /, \b, \f, \n, \r, \t