mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
common: Turn assertions into expressions.
* common/logging.h (log_assert): Turn this into an expression so it can be used in expressions. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
6d06519833
commit
a1e0d4a1e7
@ -56,18 +56,18 @@ estream_t log_get_stream (void);
|
|||||||
void _log_assert (const char *expr, const char *file, int line,
|
void _log_assert (const char *expr, const char *file, int line,
|
||||||
const char *func) GPGRT_ATTR_NORETURN;
|
const char *func) GPGRT_ATTR_NORETURN;
|
||||||
# define BUG() bug_at( __FILE__ , __LINE__, __FUNCTION__)
|
# define BUG() bug_at( __FILE__ , __LINE__, __FUNCTION__)
|
||||||
# define log_assert(expr) do { \
|
# define log_assert(expr) \
|
||||||
if (!(expr)) \
|
((expr) \
|
||||||
_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__); \
|
? (void) 0 \
|
||||||
} while (0)
|
: _log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
|
||||||
#else /*!GPGRT_HAVE_MACRO_FUNCTION*/
|
#else /*!GPGRT_HAVE_MACRO_FUNCTION*/
|
||||||
void bug_at (const char *file, int line);
|
void bug_at (const char *file, int line);
|
||||||
void _log_assert (const char *expr, const char *file, int line;
|
void _log_assert (const char *expr, const char *file, int line;
|
||||||
# define BUG() bug_at( __FILE__ , __LINE__ )
|
# define BUG() bug_at( __FILE__ , __LINE__ )
|
||||||
# define log_assert(expr) do { \
|
# define log_assert(expr) \
|
||||||
if (!(expr)) \
|
((expr) \
|
||||||
_log_assert (#expr, __FILE__, __LINE__); \
|
? (void) 0 \
|
||||||
} while (0)
|
: _log_assert (#expr, __FILE__, __LINE__))
|
||||||
#endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
|
#endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
|
||||||
|
|
||||||
/* Flag values for log_set_prefix. */
|
/* Flag values for log_set_prefix. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user