From 2f3fbd451d2bed1737052c672974e3dc31ad015f Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 5 Apr 2003 20:38:01 +0000 Subject: 2003-04-05 Havoc Pennington * doc/config-file.txt (Elements): fix docs of to reflect reality; in fact multiple mechanisms are allowed. * dbus/dbus-internals.c (_dbus_real_assert) (_dbus_real_assert_not_reached): move guts of _dbus_assert() and _dbus_assert_not_reached() into functions, so that they don't show up in basic block counts for test coverage, and don't use up as much disk space. Does mean slower execution speed though, so assumes --disable-asserts is the normal production case. --- dbus/dbus-internals.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'dbus/dbus-internals.c') diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index f1fbf963..8d803977 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -345,6 +345,53 @@ _dbus_type_to_string (int type) } } +#ifndef DBUS_DISABLE_ASSERT +/** + * Internals of _dbus_assert(); it's a function + * rather than a macro with the inline code so + * that the assertion failure blocks don't show up + * in test suite coverage, and to shrink code size. + * + * @param condition TRUE if assertion succeeded + * @param condition_text condition as a string + * @param file file the assertion is in + * @param line line the assertion is in + */ +void +_dbus_real_assert (dbus_bool_t condition, + const char *condition_text, + const char *file, + int line) +{ + if (!condition) + { + _dbus_warn ("Assertion failed \"%s\" file \"%s\" line %d\n", + condition_text, file, line); + _dbus_abort (); + } +} + +/** + * Internals of _dbus_assert_not_reached(); it's a function + * rather than a macro with the inline code so + * that the assertion failure blocks don't show up + * in test suite coverage, and to shrink code size. + * + * @param explanation what was reached that shouldn't have been + * @param file file the assertion is in + * @param line line the assertion is in + */ +void +_dbus_real_assert_not_reached (const char *explanation, + const char *file, + int line) +{ + _dbus_warn ("File \"%s\" line %d should not have been reached: %s\n", + file, line, explanation); + _dbus_abort (); +} +#endif /* DBUS_DISABLE_ASSERT */ + #ifdef DBUS_BUILD_TESTS static dbus_bool_t run_failing_each_malloc (int n_mallocs, -- cgit