diff --git a/src/CacheDigest.cc b/src/CacheDigest.cc index 46884c37095..6d862d2a397 100644 --- a/src/CacheDigest.cc +++ b/src/CacheDigest.cc @@ -55,7 +55,7 @@ CacheDigest::CacheDigest(uint64_t aCapacity, uint8_t bpe) : mask_size(0), bits_per_entry(bpe) { - assert(SQUID_MD5_DIGEST_LENGTH == 16); /* our hash functions rely on 16 byte keys */ + static_assert(SQUID_MD5_DIGEST_LENGTH == 16); /* our hash functions rely on 16 byte keys */ updateCapacity(aCapacity); } diff --git a/src/DiskIO/DiskThreads/aiops_win32.cc b/src/DiskIO/DiskThreads/aiops_win32.cc index 2ee8f73a5b2..448c935ce47 100644 --- a/src/DiskIO/DiskThreads/aiops_win32.cc +++ b/src/DiskIO/DiskThreads/aiops_win32.cc @@ -273,7 +273,7 @@ squidaio_init(void) /* Create threads and get them to sit in their wait loop */ squidaio_thread_pool = memPoolCreate("aio_thread", sizeof(squidaio_thread_t)); - assert(NUMTHREADS > 0); + static_assert(NUMTHREADS > 0); for (i = 0; i < NUMTHREADS; ++i) { threadp = (squidaio_thread_t *)squidaio_thread_pool->alloc(); diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 39422123fc7..de38fa4210a 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -121,7 +121,7 @@ void httpHeaderInitModule(void) { /* check that we have enough space for masks */ - assert(8 * sizeof(HttpHeaderMask) >= Http::HdrType::enumEnd_); + static_assert(8 * sizeof(HttpHeaderMask) >= Http::HdrType::enumEnd_); // masks are needed for stats page still for (auto h : WholeEnum()) { diff --git a/src/fs/rock/RockRebuild.cc b/src/fs/rock/RockRebuild.cc index af79b7be647..0de6165c03e 100644 --- a/src/fs/rock/RockRebuild.cc +++ b/src/fs/rock/RockRebuild.cc @@ -358,7 +358,7 @@ Rock::Rebuild::start() failure("cannot read db header", errno); // slot prefix of SM_PAGE_SIZE should fit both core entry header and ours - assert(sizeof(DbCellHeader) < SM_PAGE_SIZE); + static_assert(sizeof(DbCellHeader) < SM_PAGE_SIZE); buf.init(SM_PAGE_SIZE, SM_PAGE_SIZE); dbOffset = SwapDir::HeaderSize + loadingPos * dbSlotSize; diff --git a/src/fs/rock/RockSwapDir.cc b/src/fs/rock/RockSwapDir.cc index 6ec7e0e79c8..4d203f2d0fd 100644 --- a/src/fs/rock/RockSwapDir.cc +++ b/src/fs/rock/RockSwapDir.cc @@ -185,8 +185,7 @@ int64_t Rock::SwapDir::slotLimitAbsolute() const { // the max value is an invalid one; all values must be below the limit - assert(std::numeric_limits::max() == - std::numeric_limits::max()); + static_assert(std::numeric_limits::max() == std::numeric_limits::max()); return std::numeric_limits::max(); } diff --git a/src/htcp.cc b/src/htcp.cc index 2b10fff1258..21c72eb31f3 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -336,7 +336,7 @@ htcpBuildAuth(char *buf, size_t buflen) { htcpAuthHeader auth; size_t copy_sz = 0; - assert(2 == sizeof(uint16_t)); + static_assert(sizeof(uint16_t) == 2); auth.length = htons(2); copy_sz += 2; if (buflen < copy_sz) diff --git a/src/security/Session.cc b/src/security/Session.cc index 755c5be9c24..be6a6869927 100644 --- a/src/security/Session.cc +++ b/src/security/Session.cc @@ -423,8 +423,8 @@ initializeSessionCache() { // Check if the MemMap keys and data are enough big to hold // session ids and session data - assert(SSL_SESSION_ID_SIZE >= MEMMAP_SLOT_KEY_SIZE); - assert(SSL_SESSION_MAX_SIZE >= MEMMAP_SLOT_DATA_SIZE); + static_assert(SSL_SESSION_ID_SIZE >= MEMMAP_SLOT_KEY_SIZE); + static_assert(SSL_SESSION_MAX_SIZE >= MEMMAP_SLOT_DATA_SIZE); int configuredItems = ::Config.SSL.sessionCacheSize / sizeof(Ipc::MemMap::Slot); if (IamWorkerProcess() && configuredItems) diff --git a/src/stat.cc b/src/stat.cc index 969a7b37519..2728cba79b4 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -867,7 +867,7 @@ GetAvgStat(Mgr::IntervalActionData& stats, int minutes, int hours) StatCounters *l; double dt; double ct; - assert(N_COUNT_HIST > 1); + static_assert(N_COUNT_HIST > 1); assert(minutes > 0 || hours > 0); f = &CountHist[0]; l = f; @@ -1688,7 +1688,7 @@ bool statSawRecentRequests() { const auto recentMinutes = 5; - assert(N_COUNT_HIST > recentMinutes); + static_assert(N_COUNT_HIST > recentMinutes); // Math below computes the number of requests during the last 0-6 minutes. // CountHist is based on "minutes passed since Squid start" periods. It cannot diff --git a/src/store_key_md5.cc b/src/store_key_md5.cc index 44f5af30fd2..6545993286a 100644 --- a/src/store_key_md5.cc +++ b/src/store_key_md5.cc @@ -86,7 +86,7 @@ storeKeyPrivate() pid_t pid; int32_t kid; } key = { 0, getpid(), KidIdentifier }; - assert(sizeof(key) == SQUID_MD5_DIGEST_LENGTH); + static_assert(sizeof(key) == SQUID_MD5_DIGEST_LENGTH); ++key.count; return reinterpret_cast(&key); } diff --git a/test-suite/mem_node_test.cc b/test-suite/mem_node_test.cc index f9fad547524..77a0d2da375 100644 --- a/test-suite/mem_node_test.cc +++ b/test-suite/mem_node_test.cc @@ -22,7 +22,7 @@ main(int, char *[]) * the store will never trim memory */ assert (mem_node::InUseCount() == 1); - assert (SM_PAGE_SIZE > 50); + static_assert(SM_PAGE_SIZE > 50); aNode->nodeBuffer.length = 45; assert (aNode->start() == 0); assert (aNode->end() == 45);