diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2017-11-23 14:11:43 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2017-11-23 14:11:43 +0900 |
| commit | 795a0474df35c56307151cca5787cb8ae2df06e5 (patch) | |
| tree | 2197ade3cb882db0a82dfde676e0eff27e618930 /src | |
| parent | 20a7c43f2da248bb17f1338d00d663157dce2156 (diff) | |
clang-format-5.0
Diffstat (limited to 'src')
38 files changed, 477 insertions, 129 deletions
diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index bb26d010..a1eba628 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -119,7 +119,7 @@ void AbstractDiskWriter::openFile(int64_t totalLength) #else // !__MINGW32__ e.getErrNum() == ENOENT #endif // !__MINGW32__ - ) { + ) { initAndOpenFile(totalLength); } else { @@ -201,9 +201,10 @@ HANDLE openFileWithFlags(const std::string& filename, int flags, FILE_ATTRIBUTE_NORMAL, /* hTemplateFile */ 0); if (hn == INVALID_HANDLE_VALUE) { int errNum = GetLastError(); - throw DL_ABORT_EX3(errNum, fmt(EX_FILE_OPEN, filename.c_str(), - fileStrerror(errNum).c_str()), - errCode); + throw DL_ABORT_EX3( + errNum, + fmt(EX_FILE_OPEN, filename.c_str(), fileStrerror(errNum).c_str()), + errCode); } return hn; } @@ -217,9 +218,10 @@ int openFileWithFlags(const std::string& filename, int flags, ; if (fd < 0) { int errNum = errno; - throw DL_ABORT_EX3(errNum, fmt(EX_FILE_OPEN, filename.c_str(), - util::safeStrerror(errNum).c_str()), - errCode); + throw DL_ABORT_EX3( + errNum, + fmt(EX_FILE_OPEN, filename.c_str(), util::safeStrerror(errNum).c_str()), + errCode); } util::make_fd_cloexec(fd); #if defined(__APPLE__) && defined(__MACH__) @@ -454,9 +456,10 @@ void AbstractDiskWriter::writeData(const unsigned char* data, size_t len, error_code::NOT_ENOUGH_DISK_SPACE); } else { - throw DL_ABORT_EX3(errNum, fmt(EX_FILE_WRITE, filename_.c_str(), - fileStrerror(errNum).c_str()), - error_code::FILE_IO_ERROR); + throw DL_ABORT_EX3( + errNum, + fmt(EX_FILE_WRITE, filename_.c_str(), fileStrerror(errNum).c_str()), + error_code::FILE_IO_ERROR); } } } @@ -467,9 +470,10 @@ ssize_t AbstractDiskWriter::readData(unsigned char* data, size_t len, ssize_t ret; if ((ret = readDataInternal(data, len, offset)) < 0) { int errNum = fileError(); - throw DL_ABORT_EX3(errNum, fmt(EX_FILE_READ, filename_.c_str(), - fileStrerror(errNum).c_str()), - error_code::FILE_IO_ERROR); + throw DL_ABORT_EX3( + errNum, + fmt(EX_FILE_READ, filename_.c_str(), fileStrerror(errNum).c_str()), + error_code::FILE_IO_ERROR); } return ret; } @@ -526,17 +530,17 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) } #elif defined(__APPLE__) && defined(__MACH__) const auto toalloc = offset + length - size(); - fstore_t fstore = { - F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE, - 0, toalloc, 0}; + fstore_t fstore = {F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE, 0, + toalloc, 0}; if (fcntl(fd_, F_PREALLOCATE, &fstore) == -1) { // Retry non-contig. fstore.fst_flags = F_ALLOCATEALL; if (fcntl(fd_, F_PREALLOCATE, &fstore) == -1) { int err = errno; throw DL_ABORT_EX3( - err, fmt("fcntl(F_PREALLOCATE) of %" PRId64 " failed. cause: %s", - fstore.fst_length, util::safeStrerror(err).c_str()), + err, + fmt("fcntl(F_PREALLOCATE) of %" PRId64 " failed. cause: %s", + fstore.fst_length, util::safeStrerror(err).c_str()), error_code::FILE_IO_ERROR); } } @@ -559,10 +563,11 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) #elif HAVE_POSIX_FALLOCATE int r = posix_fallocate(fd_, offset, length); if (r != 0) { - throw DL_ABORT_EX3(r, fmt("posix_fallocate failed. cause: %s", - util::safeStrerror(r).c_str()), - isDiskFullError(r) ? error_code::NOT_ENOUGH_DISK_SPACE - : error_code::FILE_IO_ERROR); + throw DL_ABORT_EX3( + r, + fmt("posix_fallocate failed. cause: %s", util::safeStrerror(r).c_str()), + isDiskFullError(r) ? error_code::NOT_ENOUGH_DISK_SPACE + : error_code::FILE_IO_ERROR); } #else #error "no *_fallocate function available." diff --git a/src/ActivePeerConnectionCommand.cc b/src/ActivePeerConnectionCommand.cc index 2cf2441a..7e566b42 100644 --- a/src/ActivePeerConnectionCommand.cc +++ b/src/ActivePeerConnectionCommand.cc @@ -107,9 +107,9 @@ bool ActivePeerConnectionCommand::execute() int numConnection = 0; if (pieceStorage_->downloadFinished()) { if (btRuntime_->getMaxPeers() > btRuntime_->getConnections()) { - numConnection = std::min(numNewConnection_, - btRuntime_->getMaxPeers() - - btRuntime_->getConnections()); + numConnection = + std::min(numNewConnection_, btRuntime_->getMaxPeers() - + btRuntime_->getConnections()); } } else { diff --git a/src/AppleTLSSession.h b/src/AppleTLSSession.h index 5213b7b7..3fc065fc 100644 --- a/src/AppleTLSSession.h +++ b/src/AppleTLSSession.h @@ -128,6 +128,6 @@ private: OSStatus sockWrite(const void* data, size_t* len); OSStatus sockRead(void* data, size_t* len); }; -} +} // namespace aria2 #endif // TLS_SESSION_H diff --git a/src/AsyncNameResolver.h b/src/AsyncNameResolver.h index de7113c3..31a6ebe9 100644 --- a/src/AsyncNameResolver.h +++ b/src/AsyncNameResolver.h @@ -73,7 +73,7 @@ public: , ares_addr_node* servers #endif // HAVE_ARES_ADDR_NODE - ); + ); ~AsyncNameResolver(); diff --git a/src/AsyncNameResolverMan.cc b/src/AsyncNameResolverMan.cc index ef5fb741..be073561 100644 --- a/src/AsyncNameResolverMan.cc +++ b/src/AsyncNameResolverMan.cc @@ -93,7 +93,7 @@ void AsyncNameResolverMan::startAsyncFamily(const std::string& hostname, , e->getAsyncDNSServers() #endif // HAVE_ARES_ADDR_NODE - ); + ); asyncNameResolver_[numResolver_]->resolve(hostname); setNameResolverCheck(numResolver_, e, command); } diff --git a/src/ChecksumCheckIntegrityEntry.cc b/src/ChecksumCheckIntegrityEntry.cc index dc225b8b..e36a4558 100644 --- a/src/ChecksumCheckIntegrityEntry.cc +++ b/src/ChecksumCheckIntegrityEntry.cc @@ -78,8 +78,9 @@ void ChecksumCheckIntegrityEntry::onDownloadIncomplete( std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e) { if (redownload_) { - proceedFileAllocation(commands, make_unique<StreamFileAllocationEntry>( - getRequestGroup(), popNextCommand()), + proceedFileAllocation(commands, + make_unique<StreamFileAllocationEntry>( + getRequestGroup(), popNextCommand()), e); return; } diff --git a/src/DHTBucket.cc b/src/DHTBucket.cc index 52494970..6320c267 100644 --- a/src/DHTBucket.cc +++ b/src/DHTBucket.cc @@ -245,9 +245,8 @@ bool DHTBucket::operator==(const DHTBucket& bucket) const bool DHTBucket::needsRefresh() const { - return nodes_.size() < K || - lastUpdated_.difference(global::wallclock()) >= - DHT_BUCKET_REFRESH_INTERVAL; + return nodes_.size() < K || lastUpdated_.difference(global::wallclock()) >= + DHT_BUCKET_REFRESH_INTERVAL; } void DHTBucket::notifyUpdate() { lastUpdated_ = global::wallclock(); } diff --git a/src/DHTNode.cc b/src/DHTNode.cc index 85a5c426..6c88d11c 100644 --- a/src/DHTNode.cc +++ b/src/DHTNode.cc @@ -87,9 +87,8 @@ bool DHTNode::isBad() const { return condition_ >= BAD_CONDITION; } bool DHTNode::isQuestionable() const { - return !isBad() && - lastContact_.difference(global::wallclock()) >= - DHT_NODE_CONTACT_INTERVAL; + return !isBad() && lastContact_.difference(global::wallclock()) >= + DHT_NODE_CONTACT_INTERVAL; } void DHTNode::markGood() { condition_ = 0; } diff --git a/src/DHTNodeLookupEntry.h b/src/DHTNodeLookupEntry.h index 6475381b..f7a938aa 100644 --- a/src/DHTNodeLookupEntry.h +++ b/src/DHTNodeLookupEntry.h @@ -55,6 +55,6 @@ struct DHTNodeLookupEntry { bool operator==(const DHTNodeLookupEntry& entry) const; }; -} // namespace aria2; +} // namespace aria2 #endif // D_DHT_NODE_LOOKUP_ENTRY_H diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index febc81aa..415b8ebd 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -235,9 +235,9 @@ bool FtpConnection::sendPort(const std::shared_ptr<SocketCore>& serverSocket) bool FtpConnection::sendRest(const std::shared_ptr<Segment>& segment) { if (socketBuffer_.sendBufferIsEmpty()) { - std::string request = fmt("REST %" PRId64 "\r\n", - segment ? segment->getPositionToWrite() - : static_cast<int64_t>(0LL)); + std::string request = + fmt("REST %" PRId64 "\r\n", segment ? segment->getPositionToWrite() + : static_cast<int64_t>(0LL)); A2_LOG_INFO(fmt(MSG_SENDING_REQUEST, cuid_, request.c_str())); socketBuffer_.pushStr(std::move(request)); } diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index bcb6a9ec..58981dd7 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -202,7 +202,7 @@ bool HttpHeader::fieldContains(int hdKey, const char* value) util::splitIter((*i).second.begin(), (*i).second.end(), std::back_inserter(values), ',', true // doStrip - ); + ); for (const auto& v : values) { if (util::strieq(v.first, v.second, value)) { return true; diff --git a/src/HttpHeader.h b/src/HttpHeader.h index d8e59aef..50715635 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -163,6 +163,6 @@ public: int idInterestingHeader(const char* hdName); -} // namespace +} // namespace aria2 #endif // D_HTTP_HEADER_H diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index d0e44803..6009dc2f 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -279,9 +279,8 @@ bool HttpResponseCommand::executeInternal() // we ignore content-length when inflate is required fe->setLength(0); if (req->getMethod() == Request::METHOD_GET && - (totalLength != 0 || - !httpResponse->getHttpHeader()->defined( - HttpHeader::CONTENT_LENGTH))) { + (totalLength != 0 || !httpResponse->getHttpHeader()->defined( + HttpHeader::CONTENT_LENGTH))) { // DownloadContext::knowsTotalLength() == true only when // server says the size of file is 0 explicitly. getDownloadContext()->markTotalLengthIsUnknown(); @@ -422,9 +421,8 @@ bool HttpResponseCommand::handleOtherEncoding( httpResponse.get(), getContentEncodingStreamFilter(httpResponse.get())); // If chunked transfer-encoding is specified, we have to read end of // chunk markers(0\r\n\r\n, for example). - bool chunkedUsed = - streamFilter && - streamFilter->getName() == ChunkedDecodingStreamFilter::NAME; + bool chunkedUsed = streamFilter && streamFilter->getName() == + ChunkedDecodingStreamFilter::NAME; // For zero-length file, check existing file comparing its size if (!chunkedUsed && getDownloadContext()->knowsTotalLength() && diff --git a/src/HttpServer.h b/src/HttpServer.h index a958c7e5..7b86f038 100644 --- a/src/HttpServer.h +++ b/src/HttpServer.h @@ -57,8 +57,8 @@ namespace util { namespace security { class HMAC; class HMACResult; -} -} +} // namespace security +} // namespace util enum RequestType { RPC_TYPE_NONE, RPC_TYPE_XML, RPC_TYPE_JSON, RPC_TYPE_JSONP }; diff --git a/src/InitiateConnectionCommandFactory.cc b/src/InitiateConnectionCommandFactory.cc index 2f864501..f9097680 100644 --- a/src/InitiateConnectionCommandFactory.cc +++ b/src/InitiateConnectionCommandFactory.cc @@ -58,7 +58,7 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand( // for SSL || req->getProtocol() == "https" #endif // ENABLE_SSL - ) { + ) { if (requestGroup->getOption()->getAsBool(PREF_ENABLE_HTTP_KEEP_ALIVE)) { req->setKeepAliveHint(true); @@ -74,7 +74,7 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand( #ifdef HAVE_LIBSSH2 || req->getProtocol() == "sftp" #endif // HAVE_LIBSSH2 - ) { + ) { if (req->getFile().empty()) { throw DL_ABORT_EX(fmt("FTP/SFTP URI %s doesn't contain file path.", req->getUri().c_str())); diff --git a/src/LibgnutlsTLSSession.cc b/src/LibgnutlsTLSSession.cc index 42f7ce0c..386819a2 100644 --- a/src/LibgnutlsTLSSession.cc +++ b/src/LibgnutlsTLSSession.cc @@ -107,9 +107,9 @@ int GnuTLSSession::init(sock_t sockfd) rv_ = gnutls_init(&sslSession_, flags); #else // GNUTLS_VERSION_NUMBER >= 0x030000 - rv_ = gnutls_init(&sslSession_, - tlsContext_->getSide() == TLS_CLIENT ? GNUTLS_CLIENT - : GNUTLS_SERVER); + rv_ = gnutls_init(&sslSession_, tlsContext_->getSide() == TLS_CLIENT + ? GNUTLS_CLIENT + : GNUTLS_SERVER); #endif // GNUTLS_VERSION_NUMBER >= 0x030000 if (rv_ != GNUTLS_E_SUCCESS) { return TLS_ERR_ERROR; diff --git a/src/LibsslTLSContext.cc b/src/LibsslTLSContext.cc index 171e498c..62a5577d 100644 --- a/src/LibsslTLSContext.cc +++ b/src/LibsslTLSContext.cc @@ -125,15 +125,14 @@ OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side, TLSVersion minVer) }; // Disable SSLv2 and enable all workarounds for buggy servers - SSL_CTX_set_options(sslCtx_, - SSL_OP_ALL | SSL_OP_NO_SSLv2 | ver_opts + SSL_CTX_set_options(sslCtx_, SSL_OP_ALL | SSL_OP_NO_SSLv2 | ver_opts #ifdef SSL_OP_SINGLE_ECDH_USE - | SSL_OP_SINGLE_ECDH_USE + | SSL_OP_SINGLE_ECDH_USE #endif // SSL_OP_SINGLE_ECDH_USE #ifdef SSL_OP_NO_COMPRESSION - | SSL_OP_NO_COMPRESSION + | SSL_OP_NO_COMPRESSION #endif // SSL_OP_NO_COMPRESSION - ); + ); SSL_CTX_set_mode(sslCtx_, SSL_MODE_AUTO_RETRY); SSL_CTX_set_mode(sslCtx_, SSL_MODE_ENABLE_PARTIAL_WRITE); #ifdef SSL_MODE_RELEASE_BUFFERS diff --git a/src/LibuvEventPoll.cc b/src/LibuvEventPoll.cc index 3065e804..3b877fff 100644 --- a/src/LibuvEventPoll.cc +++ b/src/LibuvEventPoll.cc @@ -66,7 +66,7 @@ template <typename T> static void close_callback(uv_handle_t* handle) } static void timer_callback(uv_timer_t* handle) { uv_stop(handle->loop); } -} +} // namespace namespace aria2 { diff --git a/src/LpdMessageDispatcher.cc b/src/LpdMessageDispatcher.cc index 888bc80e..cda6cc04 100644 --- a/src/LpdMessageDispatcher.cc +++ b/src/LpdMessageDispatcher.cc @@ -121,4 +121,4 @@ std::string createLpdRequest(const std::string& multicastAddress, } // namespace bittorrent -} // namespac aria2 +} // namespace aria2 diff --git a/src/MessageDigest.cc b/src/MessageDigest.cc index 610d306e..60f368a8 100644 --- a/src/MessageDigest.cc +++ b/src/MessageDigest.cc @@ -61,7 +61,7 @@ HashTypeEntry hashTypes[] = { HashTypeEntry("sha-512", 5), HashTypeEntry("md5", 0), HashTypeEntry("adler32", 0), }; -} // namespace aria2 +} // namespace MessageDigest::MessageDigest(std::unique_ptr<MessageDigestImpl> impl) : pImpl_{std::move(impl)} diff --git a/src/Metalink2RequestGroup.cc b/src/Metalink2RequestGroup.cc index 26fa7575..3c564d13 100644 --- a/src/Metalink2RequestGroup.cc +++ b/src/Metalink2RequestGroup.cc @@ -139,9 +139,10 @@ void Metalink2RequestGroup::generate( const std::shared_ptr<Option>& option, const std::string& baseUri) { std::vector<std::shared_ptr<RequestGroup>> tempgroups; - createRequestGroup(tempgroups, metalink::parseAndQuery(binaryStream.get(), - option.get(), baseUri), - option); + createRequestGroup( + tempgroups, + metalink::parseAndQuery(binaryStream.get(), option.get(), baseUri), + option); auto mi = std::make_shared<MetadataInfo>(); setMetadataInfo(std::begin(tempgroups), std::end(tempgroups), mi); groups.insert(std::end(groups), std::begin(tempgroups), std::end(tempgroups)); diff --git a/src/MetalinkParserController.cc b/src/MetalinkParserController.cc index 6dd2e9ad..6082ce6a 100644 --- a/src/MetalinkParserController.cc +++ b/src/MetalinkParserController.cc @@ -254,7 +254,7 @@ void MetalinkParserController::commitResourceTransaction() else { tEntry_->resources.push_back(std::move(tResource_)); } -#else // !ENABLE_BITTORRENT +#else // !ENABLE_BITTORRENT tEntry_->resources.push_back(std::move(tResource_)); #endif // !ENABLE_BITTORRENT tResource_.reset(); diff --git a/src/NullWebSocketSessionMan.h b/src/NullWebSocketSessionMan.h index 4f760d12..ab81d116 100644 --- a/src/NullWebSocketSessionMan.h +++ b/src/NullWebSocketSessionMan.h @@ -62,6 +62,6 @@ public: } // namespace rpc -} // aria2 +} // namespace aria2 #endif // D_NULL_WEB_SOCKET_SESSION_MAN_H diff --git a/src/OpenedFileCounter.cc b/src/OpenedFileCounter.cc index dd213768..d97b2bbf 100644 --- a/src/OpenedFileCounter.cc +++ b/src/OpenedFileCounter.cc @@ -67,9 +67,8 @@ void OpenedFileCounter::ensureMaxOpenFileLimit(size_t numNewFiles) auto& requestGroups = rgman_->getRequestGroups(); auto mark = std::begin(requestGroups); - std::advance( - mark, - SimpleRandomizer::getInstance()->getRandomNumber(requestGroups.size())); + std::advance(mark, SimpleRandomizer::getInstance()->getRandomNumber( + requestGroups.size())); auto closeFun = [&left](const std::shared_ptr<RequestGroup>& group) { auto& ps = group->getPieceStorage(); diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 44d1c3bf..4339c912 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -755,7 +755,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers() new LocalFilePathOptionHandler( PREF_RPC_CERTIFICATE, TEXT_RPC_CERTIFICATE, NO_DEFAULT_VALUE, false) #endif // HAVE_APPLETLS - ); + ); op->addTag(TAG_RPC); handlers.push_back(op); } @@ -1041,7 +1041,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers() new LocalFilePathOptionHandler(PREF_CERTIFICATE, TEXT_CERTIFICATE, NO_DEFAULT_VALUE, false) #endif // HAVE_APPLETLS - ); + ); op->addTag(TAG_HTTP); op->addTag(TAG_HTTPS); handlers.push_back(op); @@ -1480,10 +1480,10 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers() handlers.push_back(op); } { - OptionHandler* op(new DefaultOptionHandler(PREF_BT_EXCLUDE_TRACKER, - TEXT_BT_EXCLUDE_TRACKER, - NO_DESCRIPTION, "URI,... " - "or *")); + OptionHandler* op(new DefaultOptionHandler( + PREF_BT_EXCLUDE_TRACKER, TEXT_BT_EXCLUDE_TRACKER, NO_DESCRIPTION, + "URI,... " + "or *")); op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); diff --git a/src/Platform.cc b/src/Platform.cc index cbeab9e9..5833bb22 100644 --- a/src/Platform.cc +++ b/src/Platform.cc @@ -85,7 +85,7 @@ void gnutls_log_callback(int level, const char* str) msg.resize(msg.size() - 1); A2_LOG_DEBUG(fmt("GnuTLS: <%d> %s", level, msg.c_str())); } -} +} // namespace #endif // HAVE_LIBGNUTLS bool Platform::initialized_ = false; diff --git a/src/RpcMethodImpl.cc b/src/RpcMethodImpl.cc index 15746097..38156053 100644 --- a/src/RpcMethodImpl.cc +++ b/src/RpcMethodImpl.cc @@ -791,9 +791,10 @@ void gatherProgress(Dict* entryDict, const std::shared_ptr<RequestGroup>& group, gatherProgressCommon(entryDict, group, keys); #ifdef ENABLE_BITTORRENT if (group->getDownloadContext()->hasAttribute(CTX_ATTR_BT)) { - gatherProgressBitTorrent(entryDict, group, bittorrent::getTorrentAttrs( - group->getDownloadContext()), - e->getBtRegistry()->get(group->getGID()), keys); + gatherProgressBitTorrent( + entryDict, group, + bittorrent::getTorrentAttrs(group->getDownloadContext()), + e->getBtRegistry()->get(group->getGID()), keys); } #endif // ENABLE_BITTORRENT if (e->getCheckIntegrityMan()) { @@ -1601,7 +1602,7 @@ void changeOption(const std::shared_ptr<RequestGroup>& group, #ifdef ENABLE_BITTORRENT && !dctx->hasAttribute(CTX_ATTR_BT) #endif // ENABLE_BITTORRENT - ) { + ) { // In case of Metalink for (auto& fileEntry : dctx->getFileEntries()) { // PREF_OUT is not applicable to Metalink. We have always diff --git a/src/SSHSession.h b/src/SSHSession.h index 4034add7..2891af31 100644 --- a/src/SSHSession.h +++ b/src/SSHSession.h @@ -135,6 +135,6 @@ private: LIBSSH2_SFTP_HANDLE* sftph_; sock_t fd_; }; -} +} // namespace aria2 #endif // SSH_SESSION_H diff --git a/src/SelectEventPoll.cc b/src/SelectEventPoll.cc index 5f6f3309..38f9de4b 100644 --- a/src/SelectEventPoll.cc +++ b/src/SelectEventPoll.cc @@ -199,7 +199,7 @@ void SelectEventPoll::poll(const struct timeval& tv) // winsock will report non-blocking connect() errors in efds, // unlike posix, which will mark such sockets as writable. retval = select(fdmax_ + 1, &rfds, &wfds, &efds, &ttv); -#else // !__MINGW32__ +#else // !__MINGW32__ retval = select(fdmax_ + 1, &rfds, &wfds, nullptr, &ttv); #endif // !__MINGW32__ } while (retval == -1 && errno == EINTR); diff --git a/src/SessionSerializer.cc b/src/SessionSerializer.cc index 8dd9008a..6dbdabea 100644 --- a/src/SessionSerializer.cc +++ b/src/SessionSerializer.cc @@ -223,14 +223,12 @@ bool writeDownloadResult(IOFile& fp, std::set<a2_gid_t>& metainfoCache, // also exists in remaining URIs. { Unique<std::string> unique; - if (hasRemaining && - !writeUri(fp, file->getRemainingUris().begin(), - file->getRemainingUris().end(), unique)) { + if (hasRemaining && !writeUri(fp, file->getRemainingUris().begin(), + file->getRemainingUris().end(), unique)) { return false; } - if (hasSpent && - !writeUri(fp, file->getSpentUris().begin(), - file->getSpentUris().end(), unique)) { + if (hasSpent && !writeUri(fp, file->getSpentUris().begin(), + file->getSpentUris().end(), unique)) { return false; } } diff --git a/src/StreamCheckIntegrityEntry.cc b/src/StreamCheckIntegrityEntry.cc index 17f26521..0701bb1f 100644 --- a/src/StreamCheckIntegrityEntry.cc +++ b/src/StreamCheckIntegrityEntry.cc @@ -58,8 +58,9 @@ void StreamCheckIntegrityEntry::onDownloadIncomplete( if (getRequestGroup()->getOption()->getAsBool(PREF_HASH_CHECK_ONLY)) { return; } - proceedFileAllocation(commands, make_unique<StreamFileAllocationEntry>( - getRequestGroup(), popNextCommand()), + proceedFileAllocation(commands, + make_unique<StreamFileAllocationEntry>( + getRequestGroup(), popNextCommand()), e); } diff --git a/src/TLSSession.h b/src/TLSSession.h index 6e8988f2..dc540ec9 100644 --- a/src/TLSSession.h +++ b/src/TLSSession.h @@ -118,6 +118,6 @@ private: TLSSession(const TLSSession&); TLSSession& operator=(const TLSSession&); }; -} +} // namespace aria2 #endif // TLS_SESSION_H diff --git a/src/ValueBaseStructParserStateMachine.h b/src/ValueBaseStructParserStateMachine.h index c41f3c8e..a049de3a 100644 --- a/src/ValueBaseStructParserStateMachine.h +++ b/src/ValueBaseStructParserStateMachine.h @@ -47,7 +47,7 @@ class ValueBase; namespace rpc { class XmlRpcRequestParserController; -} // namespace rpc; +} // namespace rpc class ValueBaseStructParserState; diff --git a/src/WebSocketResponseCommand.cc b/src/WebSocketResponseCommand.cc index 1fe92ee2..8dd0ce5d 100644 --- a/src/WebSocketResponseCommand.cc +++ b/src/WebSocketResponseCommand.cc @@ -55,8 +55,8 @@ WebSocketResponseCommand::~WebSocketResponseCommand() = default; void WebSocketResponseCommand::afterSend( const std::shared_ptr<HttpServer>& httpServer, DownloadEngine* e) { - auto wsSession = std::make_shared<WebSocketSession>( - httpServer->getSocket(), getDownloadEngine()); + auto wsSession = std::make_shared<WebSocketSession>(httpServer->getSocket(), + getDownloadEngine()); auto command = make_unique<WebSocketInteractionCommand>( getCuid(), wsSession, e, wsSession->getSocket()); wsSession->setCommand(command.get()); diff --git a/src/WebSocketSessionMan.h b/src/WebSocketSessionMan.h index 7014c24d..c3f3a071 100644 --- a/src/WebSocketSessionMan.h +++ b/src/WebSocketSessionMan.h @@ -69,6 +69,6 @@ private: } // namespace rpc -} // aria2 +} // namespace aria2 #endif // D_WEB_SOCKET_SESSION_MAN_H diff --git a/src/WinTLSSession.cc b/src/WinTLSSession.cc index eba81ce8..3ea20e41 100644 --- a/src/WinTLSSession.cc +++ b/src/WinTLSSession.cc @@ -612,7 +612,7 @@ restart: // ... and start sending it state_ = st_handshake_write; } - // Fall through + // Fall through case st_handshake_write_last: case st_handshake_write: { @@ -644,7 +644,7 @@ restart: // Have to read one or more response messages. state_ = st_handshake_read; } - // Fall through + // Fall through case st_handshake_read: { read: @@ -764,7 +764,7 @@ restart: goto restart; } } - // Fall through + // Fall through case st_handshake_done: if (obtainTLSRecordSizes() != 0) { diff --git a/src/console.cc b/src/console.cc index 98d05278..fe519bf5 100644 --- a/src/console.cc +++ b/src/console.cc @@ -48,7 +48,7 @@ namespace { Console consoleCout; Console consoleCerr; Console consoleCoutBackup; -}; +}; // namespace void initConsole(bool suppress) { diff --git a/src/util.cc b/src/util.cc index 6c1aed26..be73a6e4 100644 --- a/src/util.cc +++ b/src/util.cc @@ -323,7 +323,7 @@ bool isUtf8(const std::string& str) firstChar == 0x0au || // \n firstChar == 0x0cu || // \f firstChar == 0x0du // \r - ) { + ) { // UTF8-1 (without ctrl chars) } else if (in(firstChar, 0xc2u, 0xdfu)) { @@ -810,28 +810,375 @@ 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) @@ -1341,7 +1688,7 @@ static BOOL WINAPI HandlerRoutine(DWORD ctrlType) } return FALSE; } -} +} // namespace #endif void setGlobalSignalHandler(int sig, sigset_t* mask, signal_handler_t handler, @@ -1444,7 +1791,7 @@ std::string getXDGDir(const std::string& environmentVariable, if (p && #ifndef __MINGW32__ p[0] == '/' -#else // __MINGW32__ +#else // __MINGW32__ p[0] && p[1] == ':' #endif // __MINGW32__ ) { @@ -1598,9 +1945,10 @@ void mkdirs(const std::string& dirpath) if (!dir.mkdirs()) { int errNum = errno; if (!dir.isDir()) { - throw DL_ABORT_EX3(errNum, fmt(EX_MAKE_DIR, dir.getPath().c_str(), - safeStrerror(errNum).c_str()), - error_code::DIR_CREATE_ERROR); + throw DL_ABORT_EX3( + errNum, + fmt(EX_MAKE_DIR, dir.getPath().c_str(), safeStrerror(errNum).c_str()), + error_code::DIR_CREATE_ERROR); } } } @@ -1840,12 +2188,11 @@ std::string escapePath(const std::string& s) unsigned char c = cc; if (in(c, 0x00u, 0x1fu) || c == 0x7fu #ifdef __MINGW32__ - || - std::find(std::begin(WIN_INVALID_PATH_CHARS), - std::end(WIN_INVALID_PATH_CHARS), - c) != std::end(WIN_INVALID_PATH_CHARS) + || std::find(std::begin(WIN_INVALID_PATH_CHARS), + std::end(WIN_INVALID_PATH_CHARS), + c) != std::end(WIN_INVALID_PATH_CHARS) #endif // __MINGW32__ - ) { + ) { d += fmt("%%%02X", c); } else { |
