diff options
| author | Nils Maier <maierman@web.de> | 2014-05-28 03:41:09 +0200 |
|---|---|---|
| committer | Nils Maier <maierman@web.de> | 2014-05-29 19:38:34 +0200 |
| commit | b9fe4119c0f7165669e87cb1423efb030eb96c4d (patch) | |
| tree | be711120896da0db842537c0bf2a0b864c0182ec /src | |
| parent | c8ccb434288dff750ff7a8d22d0551043b1eb1e5 (diff) | |
New round of clang-modernize
Diffstat (limited to 'src')
| -rw-r--r-- | src/AdaptiveURISelector.cc | 4 | ||||
| -rw-r--r-- | src/AdaptiveURISelector.h | 2 | ||||
| -rw-r--r-- | src/BtBitfieldMessage.cc | 2 | ||||
| -rw-r--r-- | src/ColorizedStream.h | 4 | ||||
| -rw-r--r-- | src/DNSCache.h | 2 | ||||
| -rw-r--r-- | src/Event.h | 4 | ||||
| -rw-r--r-- | src/HashFuncEntry.h | 4 | ||||
| -rw-r--r-- | src/LibgcryptARC4Encryptor.cc | 6 | ||||
| -rw-r--r-- | src/LibgcryptDHKeyExchange.cc | 14 | ||||
| -rw-r--r-- | src/LibgnutlsTLSSession.cc | 4 | ||||
| -rw-r--r-- | src/LibsslDHKeyExchange.cc | 20 | ||||
| -rw-r--r-- | src/LibsslMessageDigestImpl.cc | 2 | ||||
| -rw-r--r-- | src/LibsslTLSContext.cc | 16 | ||||
| -rw-r--r-- | src/LibsslTLSSession.cc | 6 | ||||
| -rw-r--r-- | src/Netrc.cc | 2 | ||||
| -rw-r--r-- | src/OptionHandlerFactory.cc | 4 | ||||
| -rw-r--r-- | src/Peer.cc | 2 | ||||
| -rw-r--r-- | src/RequestSlot.h | 4 | ||||
| -rw-r--r-- | src/SegmentMan.cc | 2 | ||||
| -rw-r--r-- | src/UDPTrackerClient.cc | 8 | ||||
| -rw-r--r-- | src/aria2api.cc | 9 | ||||
| -rw-r--r-- | src/daemon.cc | 6 | ||||
| -rw-r--r-- | src/download_helper.cc | 4 |
23 files changed, 66 insertions, 65 deletions
diff --git a/src/AdaptiveURISelector.cc b/src/AdaptiveURISelector.cc index 5794ac88..afa42a5b 100644 --- a/src/AdaptiveURISelector.cc +++ b/src/AdaptiveURISelector.cc @@ -66,8 +66,8 @@ namespace aria2 { */ AdaptiveURISelector::AdaptiveURISelector -(const std::shared_ptr<ServerStatMan>& serverStatMan, RequestGroup* requestGroup) - : serverStatMan_(serverStatMan), +(std::shared_ptr<ServerStatMan> serverStatMan, RequestGroup* requestGroup) + : serverStatMan_(std::move(serverStatMan)), requestGroup_(requestGroup) { resetCounters(); diff --git a/src/AdaptiveURISelector.h b/src/AdaptiveURISelector.h index 92535467..a9f5d8ac 100644 --- a/src/AdaptiveURISelector.h +++ b/src/AdaptiveURISelector.h @@ -71,7 +71,7 @@ private: int getNbTestedServers(const std::deque<std::string>& uris) const; std::string getBestMirror(const std::deque<std::string>& uris) const; public: - AdaptiveURISelector(const std::shared_ptr<ServerStatMan>& serverStatMan, + AdaptiveURISelector(std::shared_ptr<ServerStatMan> serverStatMan, RequestGroup* requestGroup); virtual ~AdaptiveURISelector(); diff --git a/src/BtBitfieldMessage.cc b/src/BtBitfieldMessage.cc index 9cfa3bd1..0238c83a 100644 --- a/src/BtBitfieldMessage.cc +++ b/src/BtBitfieldMessage.cc @@ -108,7 +108,7 @@ unsigned char* BtBitfieldMessage::createMessage() { * total: 5+bitfieldLength bytes */ const size_t msgLength = 5+bitfieldLength_; - auto msg = new unsigned char[msgLength]; + auto msg = new unsigned char[msgLength]; bittorrent::createPeerMessageString(msg, msgLength, 1+bitfieldLength_, ID); memcpy(msg+5, bitfield_, bitfieldLength_); return msg; diff --git a/src/ColorizedStream.h b/src/ColorizedStream.h index 431c8149..fb5e4b7e 100644 --- a/src/ColorizedStream.h +++ b/src/ColorizedStream.h @@ -40,6 +40,8 @@ #include <sstream> #include <deque> +#include "config.h" + namespace aria2 { namespace colors { @@ -105,7 +107,7 @@ public: elems.push_back(std::make_pair(eString, "")); } - traits_t::int_type overflow(traits_t::int_type c) + traits_t::int_type overflow(traits_t::int_type c) CXX11_OVERRIDE { elems.back().second.push_back((char)c); return std::char_traits<char>::not_eof(c); diff --git a/src/DNSCache.h b/src/DNSCache.h index a639843c..d7b487a8 100644 --- a/src/DNSCache.h +++ b/src/DNSCache.h @@ -114,7 +114,7 @@ public: (OutputIterator out, const std::string& hostname, uint16_t port) const { std::shared_ptr<CacheEntry> target(new CacheEntry(hostname, port)); - CacheEntrySet::iterator i = entries_.find(target); + auto i = entries_.find(target); if(i != entries_.end()) { (*i)->getAllGoodAddrs(out); } diff --git a/src/Event.h b/src/Event.h index 006724da..19238f87 100644 --- a/src/Event.h +++ b/src/Event.h @@ -314,9 +314,9 @@ private: sock_t sockets_[ARES_GETSOCK_MAXNUM]; public: - AsyncNameResolverEntry(const std::shared_ptr<AsyncNameResolver>& nameResolver, + AsyncNameResolverEntry(std::shared_ptr<AsyncNameResolver> nameResolver, Command* command): - nameResolver_(nameResolver), command_(command), socketsSize_(0) {} + nameResolver_(std::move(nameResolver)), command_(command), socketsSize_(0) {} bool operator==(const AsyncNameResolverEntry& entry) { diff --git a/src/HashFuncEntry.h b/src/HashFuncEntry.h index 68b0ffa1..dfa86f46 100644 --- a/src/HashFuncEntry.h +++ b/src/HashFuncEntry.h @@ -50,8 +50,8 @@ struct HashFuncEntry { typedef HashFunc HashFuncType; std::string hashType; HashFunc hashFunc; - HashFuncEntry(const std::string& hashType, const HashFunc& hashFunc): - hashType(hashType), hashFunc(hashFunc) + HashFuncEntry(std::string hashType, const HashFunc& hashFunc): + hashType(std::move(hashType)), hashFunc(hashFunc) {} }; diff --git a/src/LibgcryptARC4Encryptor.cc b/src/LibgcryptARC4Encryptor.cc index 0290e4e6..08711633 100644 --- a/src/LibgcryptARC4Encryptor.cc +++ b/src/LibgcryptARC4Encryptor.cc @@ -51,7 +51,7 @@ void handleError(gcry_error_t err) } // namespace ARC4Encryptor::ARC4Encryptor() - : hdl_(0) + : hdl_(nullptr) {} ARC4Encryptor::~ARC4Encryptor() @@ -71,7 +71,7 @@ void ARC4Encryptor::init(const unsigned char* key, size_t keyLength) if((r = gcry_cipher_setkey(hdl_, key, keyLength))) { handleError(r); } - if((r = gcry_cipher_setiv(hdl_, 0, 0))) { + if((r = gcry_cipher_setiv(hdl_, nullptr, 0))) { handleError(r); } } @@ -84,7 +84,7 @@ void ARC4Encryptor::encrypt size_t inlen; if(in == out) { out = const_cast<unsigned char*>(in); - in = 0; + in = nullptr; inlen = 0; } else { inlen = len; diff --git a/src/LibgcryptDHKeyExchange.cc b/src/LibgcryptDHKeyExchange.cc index a691b4a8..edfae9cc 100644 --- a/src/LibgcryptDHKeyExchange.cc +++ b/src/LibgcryptDHKeyExchange.cc @@ -49,10 +49,10 @@ void handleError(gcry_error_t err) DHKeyExchange::DHKeyExchange() : keyLength_(0), - prime_(0), - generator_(0), - privateKey_(0), - publicKey_(0) + prime_(nullptr), + generator_(nullptr), + privateKey_(nullptr), + publicKey_(nullptr) {} DHKeyExchange::~DHKeyExchange() @@ -72,14 +72,14 @@ void DHKeyExchange::init(const unsigned char* prime, size_t primeBits, gcry_mpi_release(privateKey_); { gcry_error_t r = gcry_mpi_scan(&prime_, GCRYMPI_FMT_HEX, - prime, 0, 0); + prime, 0, nullptr); if(r) { handleError(r); } } { gcry_error_t r = gcry_mpi_scan(&generator_, GCRYMPI_FMT_HEX, - generator, 0, 0); + generator, 0, nullptr); if(r) { handleError(r); } @@ -137,7 +137,7 @@ size_t DHKeyExchange::computeSecret(unsigned char* out, size_t outLength, GCRYMPI_FMT_USG, peerPublicKeyData, peerPublicKeyLength, - 0); + nullptr); if(r) { handleError(r); } diff --git a/src/LibgnutlsTLSSession.cc b/src/LibgnutlsTLSSession.cc index 94abf6f9..c35c0e27 100644 --- a/src/LibgnutlsTLSSession.cc +++ b/src/LibgnutlsTLSSession.cc @@ -48,7 +48,7 @@ TLSSession* TLSSession::make(TLSContext* ctx) } GnuTLSSession::GnuTLSSession(GnuTLSContext* tlsContext) - : sslSession_(0), + : sslSession_(nullptr), tlsContext_(tlsContext), rv_(0) {} @@ -265,7 +265,7 @@ int GnuTLSSession::tlsConnect(const std::string& hostname, for(int i = 0; !(ret < 0); ++i) { altNameLen = sizeof(altName); ret = gnutls_x509_crt_get_subject_alt_name(cert, i, altName, - &altNameLen, 0); + &altNameLen, nullptr); if(ret == GNUTLS_SAN_DNSNAME) { dnsNames.push_back(std::string(altName, altNameLen)); } else if(ret == GNUTLS_SAN_IPADDRESS) { diff --git a/src/LibsslDHKeyExchange.cc b/src/LibsslDHKeyExchange.cc index 5137a197..82daa433 100644 --- a/src/LibsslDHKeyExchange.cc +++ b/src/LibsslDHKeyExchange.cc @@ -49,17 +49,17 @@ void handleError(const std::string& funName) { throw DL_ABORT_EX (fmt("Exception in libssl routine %s(DHKeyExchange class): %s", - funName.c_str(), ERR_error_string(ERR_get_error(), 0))); + funName.c_str(), ERR_error_string(ERR_get_error(), nullptr))); } } // namespace DHKeyExchange::DHKeyExchange() - : bnCtx_(0), + : bnCtx_(nullptr), keyLength_(0), - prime_(0), - generator_(0), - privateKey_(0), - publicKey_(0) + prime_(nullptr), + generator_(nullptr), + privateKey_(nullptr), + publicKey_(nullptr) {} DHKeyExchange::~DHKeyExchange() @@ -82,11 +82,11 @@ void DHKeyExchange::init(const unsigned char* prime, size_t primeBits, } BN_free(prime_); - prime_ = 0; + prime_ = nullptr; BN_free(generator_); - generator_ = 0; + generator_ = nullptr; BN_free(privateKey_); - privateKey_ = 0; + privateKey_ = nullptr; if(BN_hex2bn(&prime_, reinterpret_cast<const char*>(prime)) == 0) { handleError("BN_hex2bn in init"); @@ -150,7 +150,7 @@ size_t DHKeyExchange::computeSecret(unsigned char* out, size_t outLength, } - BIGNUM* peerPublicKey = BN_bin2bn(peerPublicKeyData, peerPublicKeyLength, 0); + BIGNUM* peerPublicKey = BN_bin2bn(peerPublicKeyData, peerPublicKeyLength, nullptr); if(!peerPublicKey) { handleError("BN_bin2bn in computeSecret"); } diff --git a/src/LibsslMessageDigestImpl.cc b/src/LibsslMessageDigestImpl.cc index e4536a4c..037fc45f 100644 --- a/src/LibsslMessageDigestImpl.cc +++ b/src/LibsslMessageDigestImpl.cc @@ -57,7 +57,7 @@ public: return len_; } virtual void reset() CXX11_OVERRIDE { - EVP_DigestInit_ex(&ctx_, md_, 0); + EVP_DigestInit_ex(&ctx_, md_, nullptr); } virtual void update(const void* data, size_t length) CXX11_OVERRIDE { auto bytes = reinterpret_cast<const char*>(data); diff --git a/src/LibsslTLSContext.cc b/src/LibsslTLSContext.cc index c6543b15..c8419ced 100644 --- a/src/LibsslTLSContext.cc +++ b/src/LibsslTLSContext.cc @@ -87,7 +87,7 @@ TLSContext* TLSContext::make(TLSSessionSide side) } OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side) - : sslCtx_(0), + : sslCtx_(nullptr), side_(side), verifyPeer_(true) { @@ -97,7 +97,7 @@ OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side) } else { good_ = false; A2_LOG_ERROR(fmt("SSL_CTX_new() failed. Cause: %s", - ERR_error_string(ERR_get_error(), 0))); + ERR_error_string(ERR_get_error(), nullptr))); return; } // Disable SSLv2 and enable all workarounds for buggy servers @@ -139,13 +139,13 @@ bool OpenSSLTLSContext::addCredentialFile(const std::string& certfile, SSL_FILETYPE_PEM) != 1) { A2_LOG_ERROR(fmt("Failed to load private key from %s. Cause: %s", keyfile.c_str(), - ERR_error_string(ERR_get_error(), 0))); + ERR_error_string(ERR_get_error(), nullptr))); return false; } if(SSL_CTX_use_certificate_chain_file(sslCtx_, certfile.c_str()) != 1) { A2_LOG_ERROR(fmt("Failed to load certificate from %s. Cause: %s", certfile.c_str(), - ERR_error_string(ERR_get_error(), 0))); + ERR_error_string(ERR_get_error(), nullptr))); return false; } A2_LOG_INFO(fmt("Credential files(cert=%s, key=%s) were successfully added.", @@ -177,7 +177,7 @@ bool OpenSSLTLSContext::addP12CredentialFile(const std::string& p12file) } EVP_PKEY *pkey; X509 *cert; - STACK_OF(X509) *ca = 0; + STACK_OF(X509) *ca = nullptr; if (!PKCS12_parse(p12.get(), "", &pkey, &cert, &ca)) { A2_LOG_ERROR(fmt("Failed to parse PKCS12 file: %s. " "If you meant to use PEM, you'll also have to specify " @@ -219,7 +219,7 @@ bool OpenSSLTLSContext::addSystemTrustedCACerts() { if(SSL_CTX_set_default_verify_paths(sslCtx_) != 1) { A2_LOG_INFO(fmt(MSG_LOADING_SYSTEM_TRUSTED_CA_CERTS_FAILED, - ERR_error_string(ERR_get_error(), 0))); + ERR_error_string(ERR_get_error(), nullptr))); return false; } else { A2_LOG_INFO("System trusted CA certificates were successfully added."); @@ -229,10 +229,10 @@ bool OpenSSLTLSContext::addSystemTrustedCACerts() bool OpenSSLTLSContext::addTrustedCACertFile(const std::string& certfile) { - if(SSL_CTX_load_verify_locations(sslCtx_, certfile.c_str(), 0) != 1) { + if(SSL_CTX_load_verify_locations(sslCtx_, certfile.c_str(), nullptr) != 1) { A2_LOG_ERROR(fmt(MSG_LOADING_TRUSTED_CA_CERT_FAILED, certfile.c_str(), - ERR_error_string(ERR_get_error(), 0))); + ERR_error_string(ERR_get_error(), nullptr))); return false; } else { A2_LOG_INFO("Trusted CA certificates were successfully added."); diff --git a/src/LibsslTLSSession.cc b/src/LibsslTLSSession.cc index 492c87c1..311c52d2 100644 --- a/src/LibsslTLSSession.cc +++ b/src/LibsslTLSSession.cc @@ -50,7 +50,7 @@ TLSSession* TLSSession::make(TLSContext* ctx) } OpenSSLTLSSession::OpenSSLTLSSession(OpenSSLTLSContext* tlsContext) - : ssl_(0), + : ssl_(nullptr), tlsContext_(tlsContext), rv_(1) {} @@ -205,7 +205,7 @@ int OpenSSLTLSSession::tlsConnect(const std::string& hostname, std::vector<std::string> ipAddrs; GENERAL_NAMES* altNames; altNames = reinterpret_cast<GENERAL_NAMES*> - (X509_get_ext_d2i(peerCert, NID_subject_alt_name, NULL, NULL)); + (X509_get_ext_d2i(peerCert, NID_subject_alt_name, nullptr, NULL)); if(altNames) { std::unique_ptr<GENERAL_NAMES, decltype(&GENERAL_NAMES_free)> altNamesDeleter(altNames, GENERAL_NAMES_free); @@ -289,7 +289,7 @@ std::string OpenSSLTLSSession::getLastErrorString() return "unknown syscall error"; } } else { - return ERR_error_string(err, 0); + return ERR_error_string(err, nullptr); } } case SSL_ERROR_SSL: diff --git a/src/Netrc.cc b/src/Netrc.cc index fc7b3aaa..c36c83e6 100644 --- a/src/Netrc.cc +++ b/src/Netrc.cc @@ -228,7 +228,7 @@ class AuthHostMatch { private: std::string hostname; public: - AuthHostMatch(const std::string& hostname):hostname(hostname) {} + AuthHostMatch(std::string hostname) : hostname(std::move(hostname)) {} bool operator()(const std::unique_ptr<Authenticator>& authenticator) { diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 7ef8a325..a08e6634 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -869,9 +869,9 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers() handlers.push_back(op); } { - DefaultOptionHandler* op(new DefaultOptionHandler + auto op = new DefaultOptionHandler (PREF_RPC_SECRET, - TEXT_RPC_SECRET)); + TEXT_RPC_SECRET); op->addTag(TAG_RPC); op->setEraseAfterParse(true); op->setAllowEmpty(false); diff --git a/src/Peer.cc b/src/Peer.cc index bf35e0bb..8b467db5 100644 --- a/src/Peer.cc +++ b/src/Peer.cc @@ -46,7 +46,7 @@ namespace aria2 { Peer::Peer(std::string ipaddr, uint16_t port, bool incoming): - ipaddr_(ipaddr), + ipaddr_(std::move(ipaddr)), port_(port), origPort_(port), cuid_(0), diff --git a/src/RequestSlot.h b/src/RequestSlot.h index 2208d26f..e89d9480 100644 --- a/src/RequestSlot.h +++ b/src/RequestSlot.h @@ -45,10 +45,10 @@ namespace aria2 { class RequestSlot { public: RequestSlot(size_t index, int32_t begin, int32_t length, size_t blockIndex, - const std::shared_ptr<Piece>& piece = nullptr) + std::shared_ptr<Piece> piece = nullptr) : dispatchedTime_(global::wallclock()), index_(index), begin_(begin), length_(length), blockIndex_(blockIndex), - piece_(piece) + piece_(std::move(piece)) {} RequestSlot():dispatchedTime_(0), index_(0), begin_(0), length_(0), diff --git a/src/SegmentMan.cc b/src/SegmentMan.cc index dc94d851..131c7630 100644 --- a/src/SegmentMan.cc +++ b/src/SegmentMan.cc @@ -347,7 +347,7 @@ class FindSegmentEntry { private: std::shared_ptr<Segment> segment_; public: - FindSegmentEntry(const std::shared_ptr<Segment>& segment):segment_(segment) {} + FindSegmentEntry(std::shared_ptr<Segment> segment):segment_(std::move(segment)) {} bool operator()(const std::shared_ptr<SegmentEntry>& segmentEntry) const { diff --git a/src/UDPTrackerClient.cc b/src/UDPTrackerClient.cc index 237fca7b..d42d368e 100644 --- a/src/UDPTrackerClient.cc +++ b/src/UDPTrackerClient.cc @@ -122,8 +122,8 @@ struct CollectAddrPortMatch { std::string remoteAddr; uint16_t remotePort; CollectAddrPortMatch(std::vector<std::shared_ptr<UDPTrackerRequest> >& dest, - const std::string& remoteAddr, uint16_t remotePort) - : dest(dest), remoteAddr(remoteAddr), remotePort(remotePort) + std::string remoteAddr, uint16_t remotePort) + : dest(dest), remoteAddr(std::move(remoteAddr)), remotePort(remotePort) {} }; } // namespace @@ -501,9 +501,9 @@ struct FailConnectDelete { std::string remoteAddr; uint16_t remotePort; int error; - FailConnectDelete(const std::string& remoteAddr, uint16_t remotePort, + FailConnectDelete(std::string remoteAddr, uint16_t remotePort, int error) - : remoteAddr(remoteAddr), remotePort(remotePort), error(error) + : remoteAddr(std::move(remoteAddr)), remotePort(remotePort), error(error) {} }; } // namespace diff --git a/src/aria2api.cc b/src/aria2api.cc index 933d17ac..14f8afc0 100644 --- a/src/aria2api.cc +++ b/src/aria2api.cc @@ -522,9 +522,8 @@ std::vector<A2Gid> getActiveDownload(Session* session) auto& e = session->context->reqinfo->getDownloadEngine(); const RequestGroupList& groups = e->getRequestGroupMan()->getRequestGroups(); std::vector<A2Gid> res; - for(RequestGroupList::const_iterator i = groups.begin(), - eoi = groups.end(); i != eoi; ++i) { - res.push_back((*i)->getGID()); + for(const auto& group : groups) { + res.push_back(group->getGID()); } return res; } @@ -815,8 +814,8 @@ struct RequestGroupDH : public DownloadHandle { namespace { struct DownloadResultDH : public DownloadHandle { - DownloadResultDH(const std::shared_ptr<DownloadResult>& dr) - : dr(dr) + DownloadResultDH(std::shared_ptr<DownloadResult> dr) + : dr(std::move(dr)) {} virtual ~DownloadResultDH() {} virtual DownloadStatus getStatus() CXX11_OVERRIDE diff --git a/src/daemon.cc b/src/daemon.cc index 7e991c98..154385c1 100644 --- a/src/daemon.cc +++ b/src/daemon.cc @@ -65,13 +65,13 @@ int daemon(int nochdir, int noclose) } } if(noclose == 0) { - if(freopen("/dev/null", "r", stdin) == 0) { + if(freopen("/dev/null", "r", stdin) == nullptr) { return -1; } - if(freopen("/dev/null", "w", stdout) == 0) { + if(freopen("/dev/null", "w", stdout) == nullptr) { return -1; } - if(freopen("/dev/null", "w", stderr) == 0) { + if(freopen("/dev/null", "w", stderr) == nullptr) { return -1; } } diff --git a/src/download_helper.cc b/src/download_helper.cc index 931ab505..950be9ab 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -332,10 +332,10 @@ private: bool throwOnError_; public: AccRequestGroup(std::vector<std::shared_ptr<RequestGroup>>& requestGroups, - const std::shared_ptr<Option>& option, + std::shared_ptr<Option> option, bool ignoreLocalPath = false, bool throwOnError = false): - requestGroups_(requestGroups), option_(option), + requestGroups_(requestGroups), option_(std::move(option)), ignoreLocalPath_(ignoreLocalPath), throwOnError_(throwOnError) {} |
