1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-30 05:39:12 +02:00

Add CHECK() macro for production assertions.

CHECK() works just like ASSERT() but is kept in production builds.
This commit is contained in:
David Steele 2019-04-18 13:21:24 -04:00
parent b258aec0ad
commit 670fa88a98
2 changed files with 14 additions and 0 deletions

View File

@ -29,6 +29,10 @@
<p>Move <code>lockRelease()</code> to the end of <code>exitSafe()</code>.</p>
</release-item>
<release-item>
<p>Add <code>CHECK()</code> macro for production assertions.</p>
</release-item>
<release-item>
<p>Automatically generate constants for command and option names.</p>
</release-item>

View File

@ -21,5 +21,15 @@ Asserts are used in test code to ensure that certain conditions are true. They
#define ASSERT(condition)
#endif
/***********************************************************************************************************************************
Checks are used in production builds to test very important conditions. Be sure to limit use to the most critical cases.
***********************************************************************************************************************************/
#define CHECK(condition) \
do \
{ \
if (!(condition)) \
THROW_FMT(AssertError, "check '%s' failed", #condition); \
} \
while (0)
#endif