From b6ef978cc4fd57307e2186e0cc178e8725159e0e Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Sun, 23 Jun 2013 15:36:32 +0800 Subject: [PATCH] Fix build failure if tests enabled but asserts disabled Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66069 Signed-off-by: Chengwei Yang --- dbus/dbus-internals.h | 13 ++++++++++++- dbus/dbus-marshal-recursive.c | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index ca011a5..b395e59 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -125,7 +125,18 @@ void _dbus_trace_ref (const char *obj_name, const char* _dbus_strerror (int error_number); #ifdef DBUS_DISABLE_ASSERT -#define _dbus_assert(condition) do { } while (0) +/* dbus embedded tests use _dbus_assert heavily, this is a simple fix + * (workaround?) for build failure if asserts disabled but tests enabled. + * Without this fix, we need encolse many slices in tests with + * #ifndef DBUS_DISABLE_ASSERT + * ... + * #endif + */ +# if defined (DBUS_BUILD_TESTS) || defined (DBUS_ENABLE_EMBEDDED_TESTS) +# define _dbus_assert(condition) do { if (1 || (condition)) { } } while (0) +# else +# define _dbus_assert(condition) do { } while (0) +# endif #else void _dbus_real_assert (dbus_bool_t condition, const char *condition_text, diff --git a/dbus/dbus-marshal-recursive.c b/dbus/dbus-marshal-recursive.c index 4adfd2e..94e2f05 100644 --- a/dbus/dbus-marshal-recursive.c +++ b/dbus/dbus-marshal-recursive.c @@ -1028,7 +1028,9 @@ _dbus_type_reader_recurse (DBusTypeReader *reader, _dbus_assert_not_reached ("don't yet handle recursing into this type"); } +#ifndef DBUS_DISABLE_ASSERT _dbus_assert (sub->klass == all_reader_classes[sub->klass->id]); +#endif (* sub->klass->recurse) (sub, reader); -- 1.7.9.5