diff --git a/src/DHTNode.cc b/src/DHTNode.cc index c075773e..150ce8c4 100644 --- a/src/DHTNode.cc +++ b/src/DHTNode.cc @@ -89,7 +89,7 @@ bool DHTNode::isGood() const return !isBad() && !isQuestionable(); } -#define BAD_CONDITION 5 +constexpr int BAD_CONDITION = 5; bool DHTNode::isBad() const { diff --git a/src/PeerConnection.h b/src/PeerConnection.h index e9adb6ae..b724ab4f 100644 --- a/src/PeerConnection.h +++ b/src/PeerConnection.h @@ -52,7 +52,7 @@ class ARC4Encryptor; // The maximum length of buffer. If the message length (including 4 // bytes length and payload length) is larger than this value, it is // dropped. -#define MAX_BUFFER_CAPACITY (16*1024+128) +constexpr size_t MAX_BUFFER_CAPACITY = 16 * 1024 + 128; class PeerConnection { private: diff --git a/src/Platform.cc b/src/Platform.cc index 8520440d..0e1912da 100644 --- a/src/Platform.cc +++ b/src/Platform.cc @@ -72,10 +72,10 @@ #endif // HAVE_LIBGMP #include "LogFactory.h" -#define A2_MIN_GCRYPT_VERSION "1.2.4" +namespace aria2 { -namespace { #ifdef HAVE_LIBGNUTLS +namespace { void gnutls_log_callback(int level, const char *str) { using namespace aria2; @@ -84,11 +84,8 @@ namespace { msg.resize(msg.size() - 1); A2_LOG_DEBUG(fmt("GnuTLS: <%d> %s", level, msg.c_str())); } -#endif // HAVE_LIBGNUTLS } - - -namespace aria2 { +#endif // HAVE_LIBGNUTLS bool Platform::initialized_ = false; @@ -126,7 +123,7 @@ bool Platform::setUp() OpenSSL_add_all_algorithms(); #endif // HAVE_OPENSSL #ifdef HAVE_LIBGCRYPT - if(!gcry_check_version(A2_MIN_GCRYPT_VERSION)) { + if(!gcry_check_version("1.2.4")) { throw DL_ABORT_EX("gcry_check_version() failed."); } gcry_control(GCRYCTL_DISABLE_SECMEM, 0); diff --git a/src/SingleFileAllocationIterator.cc b/src/SingleFileAllocationIterator.cc index be31d820..c2aa16c7 100644 --- a/src/SingleFileAllocationIterator.cc +++ b/src/SingleFileAllocationIterator.cc @@ -45,8 +45,8 @@ namespace aria2 { -#define BUFSIZE (256*1024) -#define ALIGNMENT 512 +constexpr size_t BUFSIZE = 256 * 1024; +constexpr size_t ALIGNMENT = 512; SingleFileAllocationIterator::SingleFileAllocationIterator (BinaryStream* stream,