From 10bdbe66170336200c220fa64416f75bc8e5fe13 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 11 Aug 2026 20:44:30 +0000 Subject: [PATCH 1/6] remove PURIFY and NODEBUG --- compat/assert.h | 10 ++++------ src/debug/Stream.h | 12 +----------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/compat/assert.h b/compat/assert.h index cf6693275b4..d38308ceef4 100644 --- a/compat/assert.h +++ b/compat/assert.h @@ -9,14 +9,12 @@ #ifndef SQUID_COMPAT_ASSERT_H #define SQUID_COMPAT_ASSERT_H -#if PURIFY -#define assert(EX) ((void)0) -#elif defined(NODEBUG) -#define assert(EX) ((void)0) -#else -#define assert(EX) ((EX)?((void)0):xassert( # EX , __FILE__, __LINE__)) +#if defined(assert) +#undef assert #endif +#define assert(EX) ((EX)?((void)0):xassert( # EX , __FILE__, __LINE__)) + #ifdef __cplusplus extern "C" void #else diff --git a/src/debug/Stream.h b/src/debug/Stream.h index 9c69d95410c..314a4bfe128 100644 --- a/src/debug/Stream.h +++ b/src/debug/Stream.h @@ -12,23 +12,13 @@ #define SQUID_SRC_DEBUG_STREAM_H #include "base/Here.h" +#include "compat/assert.h" // XXX should be mem/forward.h once it removes dependencies on typedefs.h #include "mem/AllocatorProxy.h" #include -#undef assert #include #include -#if defined(assert) -#undef assert -#endif -#if PURIFY -#define assert(EX) ((void)0) -#elif defined(NODEBUG) -#define assert(EX) ((void)0) -#else -#define assert(EX) ((EX)?((void)0):xassert( # EX , __FILE__, __LINE__)) -#endif /* defined debug section limits */ #define MAX_DEBUG_SECTIONS 100 From a88757650c05ed53218766637081f0d8fe1fc24f Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 11 Aug 2026 20:47:37 +0000 Subject: [PATCH 2/6] compat/assert.h is only used in c++ code --- compat/assert.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/compat/assert.h b/compat/assert.h index d38308ceef4..f301924a76c 100644 --- a/compat/assert.h +++ b/compat/assert.h @@ -15,12 +15,7 @@ #define assert(EX) ((EX)?((void)0):xassert( # EX , __FILE__, __LINE__)) -#ifdef __cplusplus -extern "C" void -#else extern void -#endif xassert(const char *, const char *, int); #endif /* SQUID_COMPAT_ASSERT_H */ - From 8d50e019efbb58e6f15a30eb020bb03172146c86 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 11 Aug 2026 20:50:13 +0000 Subject: [PATCH 3/6] remove references to NDEBUG --- src/base/Assure.h | 10 ---------- src/base/TextException.h | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/base/Assure.h b/src/base/Assure.h index bd35176b31a..4d85168f76c 100644 --- a/src/base/Assure.h +++ b/src/base/Assure.h @@ -24,8 +24,6 @@ while (!(condition)) \ ReportAndThrow_((debugLevel), (description), (location)) -#if !defined(NDEBUG) - /// Like assert() but throws an exception instead of aborting the process. Use /// this macro to detect code logic mistakes (i.e. bugs) where aborting the /// current AsyncJob or a similar task is unlikely to jeopardize Squid service @@ -40,13 +38,5 @@ #define Assure2(condition, description) \ Assure_(0, (condition), ("assurance failed: " description), Here()) -#else - -/* do-nothing implementations for NDEBUG builds */ -#define Assure(condition) ((void)0) -#define Assure2(condition, description) ((void)0) - -#endif /* NDEBUG */ - #endif /* SQUID_SRC_BASE_ASSURE_H */ diff --git a/src/base/TextException.h b/src/base/TextException.h index 1d9e578d1cd..33c876a789f 100644 --- a/src/base/TextException.h +++ b/src/base/TextException.h @@ -70,8 +70,8 @@ std::ostream &operator <<(std::ostream &, const TextException &); Assure_(3, (condition), ("check failed: " description), (location)) /// Like Assure() but only logs the exception if level-3 debugging is enabled -/// and runs even when NDEBUG macro is defined. Deprecated: Use Assure() for -/// code logic checks and throw explicitly when input validation fails. +/// Deprecated: Use Assure() for code logic checks and throw +/// explicitly when input validation fails. #define Must(condition) Must3((condition), #condition, Here()) /// Reports and swallows all exceptions to prevent compiler warnings and runtime From c49c3b2ab7cadaa9829731e67b87dc9908eba5c8 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 11 Aug 2026 20:55:18 +0000 Subject: [PATCH 4/6] remove references --- compat/mswindows.cc | 2 -- lib/hash.cc | 1 - lib/tests/testRFC1738.cc | 1 - src/base/JobWait.cc | 1 - src/dns/rfc1035.cc | 1 - src/dns/rfc3596.cc | 1 - src/ip/Address.cc | 1 - src/log/file/log_file_daemon.cc | 1 - src/mem/Pool.cc | 1 - src/mem/PoolChunked.cc | 1 - src/mem/PoolMalloc.cc | 1 - src/tests/testRFC1035.cc | 2 -- 12 files changed, 14 deletions(-) diff --git a/compat/mswindows.cc b/compat/mswindows.cc index 9cf4acbe0bc..0e897f356bc 100644 --- a/compat/mswindows.cc +++ b/compat/mswindows.cc @@ -20,8 +20,6 @@ #define sys_nerr _sys_nerr -#undef assert -#include #include #include #include diff --git a/lib/hash.cc b/lib/hash.cc index be13c32c2f8..146bad6f382 100644 --- a/lib/hash.cc +++ b/lib/hash.cc @@ -11,7 +11,6 @@ #include "squid.h" #include "hash.h" -#include #include #include #include diff --git a/lib/tests/testRFC1738.cc b/lib/tests/testRFC1738.cc index 5e02ad652f8..1399a9f711d 100644 --- a/lib/tests/testRFC1738.cc +++ b/lib/tests/testRFC1738.cc @@ -9,7 +9,6 @@ #include "squid.h" #include "unitTestMain.h" -#include #include /* Being a C library code it is best bodily included and tested with C++ type-safe techniques. */ diff --git a/src/base/JobWait.cc b/src/base/JobWait.cc index 6adf2221a3f..b7fe5c38c40 100644 --- a/src/base/JobWait.cc +++ b/src/base/JobWait.cc @@ -10,7 +10,6 @@ #include "base/AsyncJobCalls.h" #include "base/JobWait.h" -#include #include JobWaitBase::JobWaitBase() = default; diff --git a/src/dns/rfc1035.cc b/src/dns/rfc1035.cc index 1d5b9de419f..d3c9ee9852b 100644 --- a/src/dns/rfc1035.cc +++ b/src/dns/rfc1035.cc @@ -19,7 +19,6 @@ #include "dns/rfc2671.h" #include "util.h" -#include #include #if HAVE_UNISTD_H #include diff --git a/src/dns/rfc3596.cc b/src/dns/rfc3596.cc index 87c2c9a3702..7078e263f32 100644 --- a/src/dns/rfc3596.cc +++ b/src/dns/rfc3596.cc @@ -18,7 +18,6 @@ #if HAVE_MEMORY_H #include #endif -#include #if HAVE_NETINET_IN_H #include #endif diff --git a/src/ip/Address.cc b/src/ip/Address.cc index b7081eaeba5..3074f0f2c46 100644 --- a/src/ip/Address.cc +++ b/src/ip/Address.cc @@ -14,7 +14,6 @@ #include "ip/tools.h" #include "util.h" -#include #include #if HAVE_ARPA_INET_H /* for inet_ntoa() */ diff --git a/src/log/file/log_file_daemon.cc b/src/log/file/log_file_daemon.cc index 7cee44cc72f..0e8c346c755 100644 --- a/src/log/file/log_file_daemon.cc +++ b/src/log/file/log_file_daemon.cc @@ -10,7 +10,6 @@ #include "compat/unistd.h" -#include #include #include #include diff --git a/src/mem/Pool.cc b/src/mem/Pool.cc index 358deff4e1e..4bfb86d7cc3 100644 --- a/src/mem/Pool.cc +++ b/src/mem/Pool.cc @@ -16,7 +16,6 @@ #include "mem/PoolMalloc.h" #include "mem/Stats.h" -#include #include extern time_t squid_curtime; diff --git a/src/mem/PoolChunked.cc b/src/mem/PoolChunked.cc index cdfa1afd3ff..43979e4eaa1 100644 --- a/src/mem/PoolChunked.cc +++ b/src/mem/PoolChunked.cc @@ -14,7 +14,6 @@ #include "mem/PoolChunked.h" #include "mem/Stats.h" -#include #include #define MEM_MAX_MMAP_CHUNKS 2048 diff --git a/src/mem/PoolMalloc.cc b/src/mem/PoolMalloc.cc index 6ff84333327..5c8b636e348 100644 --- a/src/mem/PoolMalloc.cc +++ b/src/mem/PoolMalloc.cc @@ -15,7 +15,6 @@ #include "mem/PoolMalloc.h" #include "mem/Stats.h" -#include #include extern time_t squid_curtime; diff --git a/src/tests/testRFC1035.cc b/src/tests/testRFC1035.cc index 619cc9ac6d4..e7b30779158 100644 --- a/src/tests/testRFC1035.cc +++ b/src/tests/testRFC1035.cc @@ -11,8 +11,6 @@ #include "dns/rfc1035.h" #include "unitTestMain.h" -// #include - /* * test the DNS resolver RFC 1035 Engine */ From 41bbc565cff5688ccc1cf205d81f8cf87bb4ff88 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 11 Aug 2026 21:36:05 +0000 Subject: [PATCH 5/6] Also use compat/assert.h from C files --- compat/assert.h | 4 ++++ lib/heap.c | 3 --- lib/snmplib/parse.c | 3 --- lib/snmplib/snmp_msg.c | 3 --- test-suite/waiter.c | 4 ---- 5 files changed, 4 insertions(+), 13 deletions(-) diff --git a/compat/assert.h b/compat/assert.h index f301924a76c..066e5320f55 100644 --- a/compat/assert.h +++ b/compat/assert.h @@ -15,7 +15,11 @@ #define assert(EX) ((EX)?((void)0):xassert( # EX , __FILE__, __LINE__)) +#ifdef __cplusplus +extern "C" void +#else extern void +#endif xassert(const char *, const char *, int); #endif /* SQUID_COMPAT_ASSERT_H */ diff --git a/lib/heap.c b/lib/heap.c index 5f81e9f67d6..5fecedb1bc2 100644 --- a/lib/heap.c +++ b/lib/heap.c @@ -21,9 +21,6 @@ #if HAVE_STDLIB_H #include #endif -#if HAVE_ASSERT_H -#include -#endif #if HAVE_STRING_H #include #endif diff --git a/lib/snmplib/parse.c b/lib/snmplib/parse.c index 339fe960294..b86660497eb 100644 --- a/lib/snmplib/parse.c +++ b/lib/snmplib/parse.c @@ -81,9 +81,6 @@ SOFTWARE. #if HAVE_NETDB_H #include #endif -#if HAVE_ASSERT_H -#include -#endif #if HAVE_ERRNO_H #include #endif diff --git a/lib/snmplib/snmp_msg.c b/lib/snmplib/snmp_msg.c index 652a936ffcf..6af11206376 100644 --- a/lib/snmplib/snmp_msg.c +++ b/lib/snmplib/snmp_msg.c @@ -87,9 +87,6 @@ #if HAVE_NETDB_H #include #endif -#if HAVE_ASSERT_H -#include -#endif #include "asn1.h" #include "snmp.h" diff --git a/test-suite/waiter.c b/test-suite/waiter.c index bf7a92a7f10..09430ffaff6 100644 --- a/test-suite/waiter.c +++ b/test-suite/waiter.c @@ -8,10 +8,6 @@ #include "squid.h" -#if HAVE_ASSERT_H -#include -#endif - int main(int argc, char *argv[]) { From 956fa7a149b4d9e781da57f1c7dc50582f92c3cb Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 11 Aug 2026 21:40:56 +0000 Subject: [PATCH 6/6] no need to include compat/assert.g in debug/Stream.g --- src/debug/Stream.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/debug/Stream.h b/src/debug/Stream.h index 314a4bfe128..04a4292a4df 100644 --- a/src/debug/Stream.h +++ b/src/debug/Stream.h @@ -12,7 +12,6 @@ #define SQUID_SRC_DEBUG_STREAM_H #include "base/Here.h" -#include "compat/assert.h" // XXX should be mem/forward.h once it removes dependencies on typedefs.h #include "mem/AllocatorProxy.h"