libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit 6429e7a384b340e634656536bd2bfe0259118e3c
parent 5917d37919d8067618e450aef292ece377040bdc
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Tue,  3 Jun 2025 14:13:55 +0200

Unified debug macro checks

Diffstat:
Msrc/incl_priv/mhd_sys_options.h | 2+-
Msrc/mhd2/auth_digest.c | 44++++++++++++++++++++++----------------------
Msrc/mhd2/daemon_add_conn.c | 4++--
Msrc/mhd2/mhd_mempool.c | 4++--
Msrc/mhd2/mhd_reply.h | 2+-
Msrc/mhd2/stream_process_reply.c | 2+-
Msrc/tools/perf_replies.c | 2+-
7 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/incl_priv/mhd_sys_options.h b/src/incl_priv/mhd_sys_options.h @@ -507,7 +507,7 @@ # define mhd_SEND_SPIPE_SUPPRESS_NEEDED 1 #endif -#ifdef _DEBUG +#ifndef NDEBUG # ifndef MHD_NO_TLS_DEBUG_MESSAGES # ifndef mhd_USE_TLS_DEBUG_MESSAGES /** diff --git a/src/mhd2/auth_digest.c b/src/mhd2/auth_digest.c @@ -1430,12 +1430,12 @@ struct DigestAlgorithm /** * Buffer for hex-print of the final digest. */ -#ifdef _DEBUG +#ifndef NDEBUG bool uninitialised; /**< The structure has been not set-up */ bool algo_selected; /**< The algorithm has been selected */ bool ready_for_hashing; /**< The structure is ready to hash data */ bool hashing; /**< Some data has been hashed, but the digest has not finalised yet */ -#endif /* _DEBUG */ +#endif /* NDEBUG */ }; @@ -1486,7 +1486,7 @@ digest_get_size (struct DigestAlgorithm *da) MHD_static_inline_ void digest_setup_zero (struct DigestAlgorithm *da) { -#ifdef _DEBUG +#ifndef NDEBUG da->uninitialised = false; da->algo_selected = false; da->ready_for_hashing = false; @@ -1552,7 +1552,7 @@ MHD_static_inline_ MHD_FN_MUST_CHECK_RESULT_ MHD_FN_PAR_NONNULL_ALL_ bool digest_init_one_time (struct DigestAlgorithm *da, enum MHD_DigestBaseAlgo algo) { -#ifdef _DEBUG +#ifndef NDEBUG da->uninitialised = false; da->algo_selected = false; da->ready_for_hashing = false; @@ -1563,11 +1563,11 @@ digest_init_one_time (struct DigestAlgorithm *da, case MHD_DIGEST_BASE_ALGO_MD5: #ifdef MHD_SUPPORT_MD5 da->algo = MHD_DIGEST_BASE_ALGO_MD5; -# ifdef _DEBUG +# ifndef NDEBUG da->algo_selected = true; # endif mhd_MD5_init_one_time (&(da->ctx.md5_ctx)); -# ifdef _DEBUG +# ifndef NDEBUG da->ready_for_hashing = true; # endif return true; @@ -1577,11 +1577,11 @@ digest_init_one_time (struct DigestAlgorithm *da, case MHD_DIGEST_BASE_ALGO_SHA256: #ifdef MHD_SUPPORT_SHA256 da->algo = MHD_DIGEST_BASE_ALGO_SHA256; -# ifdef _DEBUG +# ifndef NDEBUG da->algo_selected = true; # endif mhd_SHA256_init_one_time (&(da->ctx.sha256_ctx)); -# ifdef _DEBUG +# ifndef NDEBUG da->ready_for_hashing = true; # endif return true; @@ -1591,11 +1591,11 @@ digest_init_one_time (struct DigestAlgorithm *da, case MHD_DIGEST_BASE_ALGO_SHA512_256: #ifdef MHD_SUPPORT_SHA512_256 da->algo = MHD_DIGEST_BASE_ALGO_SHA512_256; -# ifdef _DEBUG +# ifndef NDEBUG da->algo_selected = true; # endif mhd_SHA512_256_init_one_time (&(da->ctx.sha512_256_ctx)); -# ifdef _DEBUG +# ifndef NDEBUG da->ready_for_hashing = true; # endif return true; @@ -1661,7 +1661,7 @@ digest_update (struct DigestAlgorithm *restrict da, mhd_UNREACHABLE (); break; } -#ifdef _DEBUG +#ifndef NDEBUG da->hashing = true; #endif } @@ -1749,12 +1749,12 @@ digest_calc_hash (struct DigestAlgorithm *da, #ifdef MHD_SUPPORT_MD5 # ifdef mhd_MD5_HAS_FINISH mhd_MD5_finish (&da->ctx.md5_ctx, digest); -# ifdef _DEBUG +# ifndef NDEBUG da->ready_for_hashing = false; # endif /* _DEBUG */ # else /* ! mhd_MD5_HAS_FINISH */ mhd_MD5_finish_reset (&da->ctx.md5_ctx, digest); -# ifdef _DEBUG +# ifndef NDEBUG da->ready_for_hashing = true; # endif /* _DEBUG */ # endif /* ! mhd_MD5_HAS_FINISH */ @@ -1767,12 +1767,12 @@ digest_calc_hash (struct DigestAlgorithm *da, #ifdef MHD_SUPPORT_SHA256 # ifdef mhd_SHA256_HAS_FINISH mhd_SHA256_finish (&da->ctx.sha256_ctx, digest); -# ifdef _DEBUG +# ifndef NDEBUG da->ready_for_hashing = false; # endif /* _DEBUG */ # else /* ! mhd_SHA256_HAS_FINISH */ mhd_SHA256_finish_reset (&da->ctx.sha256_ctx, digest); -# ifdef _DEBUG +# ifndef NDEBUG da->ready_for_hashing = true; # endif /* _DEBUG */ # endif /* ! mhd_SHA256_HAS_FINISH */ @@ -1785,12 +1785,12 @@ digest_calc_hash (struct DigestAlgorithm *da, #ifdef MHD_SUPPORT_SHA512_256 #ifdef mhd_SHA512_256_HAS_FINISH mhd_SHA512_256_finish (&da->ctx.sha512_256_ctx, digest); -#ifdef _DEBUG +#ifndef NDEBUG da->ready_for_hashing = false; #endif /* _DEBUG */ #else /* ! mhd_SHA512_256_HAS_FINISH */ mhd_SHA512_256_finish_reset (&da->ctx.sha512_256_ctx, digest); -#ifdef _DEBUG +#ifndef NDEBUG da->ready_for_hashing = true; #endif /* _DEBUG */ #endif /* ! mhd_SHA512_256_HAS_FINISH */ @@ -1804,7 +1804,7 @@ digest_calc_hash (struct DigestAlgorithm *da, mhd_UNREACHABLE (); break; } -#ifdef _DEBUG +#ifndef NDEBUG da->hashing = false; #endif /* _DEBUG */ } @@ -1831,7 +1831,7 @@ digest_reset (struct DigestAlgorithm *da) mhd_assert (da->ready_for_hashing); # endif /* ! mhd_MD5_HAS_FINISH */ mhd_MD5_reset (&(da->ctx.md5_ctx)); -# ifdef _DEBUG +# ifndef NDEBUG da->ready_for_hashing = true; # endif /* _DEBUG */ #else /* ! MHD_SUPPORT_MD5 */ @@ -1847,7 +1847,7 @@ digest_reset (struct DigestAlgorithm *da) mhd_assert (da->ready_for_hashing); #endif /* ! mhd_SHA256_HAS_FINISH */ mhd_SHA256_reset (&(da->ctx.sha256_ctx)); -#ifdef _DEBUG +#ifndef NDEBUG da->ready_for_hashing = true; #endif /* _DEBUG */ #else /* ! MHD_SUPPORT_SHA256 */ @@ -1863,7 +1863,7 @@ digest_reset (struct DigestAlgorithm *da) mhd_assert (da->ready_for_hashing); # endif /* ! mhd_SHA512_256_HAS_FINISH */ mhd_SHA512_256_reset (&(da->ctx.sha512_256_ctx)); -# ifdef _DEBUG +# ifndef NDEBUG da->ready_for_hashing = true; # endif /* _DEBUG */ #else /* ! MHD_SUPPORT_SHA512_256 */ @@ -1873,7 +1873,7 @@ digest_reset (struct DigestAlgorithm *da) case MHD_DIGEST_BASE_ALGO_INVALID: default: -#ifdef _DEBUG +#ifndef NDEBUG da->ready_for_hashing = false; #endif mhd_UNREACHABLE (); diff --git a/src/mhd2/daemon_add_conn.c b/src/mhd2/daemon_add_conn.c @@ -860,7 +860,7 @@ mhd_daemon_accept_connection (struct MHD_Daemon *restrict daemon) bool sk_spipe_supprs; bool sk_cloexec; enum mhd_Tristate sk_non_ip; -#if defined(_DEBUG) && defined (mhd_USE_ACCEPT4) +#if !defined(NDEBUG) && defined (mhd_USE_ACCEPT4) const bool use_accept4 = ! daemon->dbg.avoid_accept4; #elif defined (mhd_USE_ACCEPT4) static const bool use_accept4 = true; @@ -911,7 +911,7 @@ mhd_daemon_accept_connection (struct MHD_Daemon *restrict daemon) } } #endif /* mhd_USE_ACCEPT4 */ -#if ! defined(mhd_USE_ACCEPT4) || defined(_DEBUG) +#if ! defined(mhd_USE_ACCEPT4) || !defined(NDEBUG) if (! use_accept4) { s = accept (fd, diff --git a/src/mhd2/mhd_mempool.c b/src/mhd2/mhd_mempool.c @@ -147,7 +147,7 @@ ((uintptr_t) ((const uint8_t*) (p2))))) #elif defined(FUNC_ATTR_PTRCOMPARE_WORKS) && \ defined(FUNC_ATTR_PTRSUBTRACT_WORKS) -# ifdef _DEBUG +# ifndef NDEBUG /** * Boolean 'true' if the first pointer is less or equal the second pointer */ @@ -173,7 +173,7 @@ mp_ptr_diff_ (const void *p1, const void *p2) # elif defined(FUNC_ATTR_NOSANITIZE_WORKS) -# ifdef _DEBUG +# ifndef NDEBUG /** * Boolean 'true' if the first pointer is less or equal the second pointer */ diff --git a/src/mhd2/mhd_reply.h b/src/mhd2/mhd_reply.h @@ -49,7 +49,7 @@ struct MHD_Response; /* forward declaration */ */ struct MHD_Reply_Properties { -#ifdef _DEBUG +#ifndef NDEBUG bool set; /**< Indicates that other members are set and valid */ #endif /* _DEBUG */ bool use_reply_body_headers; /**< Use reply body-specific headers */ diff --git a/src/mhd2/stream_process_reply.c b/src/mhd2/stream_process_reply.c @@ -335,7 +335,7 @@ setup_reply_properties (struct MHD_Connection *restrict c) } } -#ifdef _DEBUG +#ifndef NDEBUG c->rp.props.set = true; #endif /* _DEBUG */ } diff --git a/src/tools/perf_replies.c b/src/tools/perf_replies.c @@ -1596,7 +1596,7 @@ static void print_perf_warnings (void) { int newline_needed = 0; -#if defined (_DEBUG) +#if !defined(NDEBUG) || defined(_DEBUG) fprintf (stderr, "WARNING: Running with debug asserts enabled, " "the performance is suboptimal.\n"); newline_needed |= ! 0;