From 8203fe35da82cd9d3491ed8ac8a2a37cfa83f4e6 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 23 Aug 2013 16:57:30 +0800 Subject: [PATCH] Cleanup: simplify assertion check Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303 Reviewed-by: Simon McVittie --- bus/driver.c | 17 +++-------------- dbus/dbus-string.c | 7 ++----- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/bus/driver.c b/bus/driver.c index 23197e4..e95a79d 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -885,13 +885,7 @@ bus_driver_handle_update_activation_environment (DBusConnection *connection, /* The message signature has already been checked for us, * so let's just assert it's right. */ -#ifndef DBUS_DISABLE_ASSERT - { - int msg_type = dbus_message_iter_get_arg_type (&iter); - - _dbus_assert (msg_type == DBUS_TYPE_ARRAY); - } -#endif + _dbus_assert (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_ARRAY); dbus_message_iter_recurse (&iter, &dict_iter); @@ -2008,13 +2002,8 @@ bus_driver_handle_message (DBusConnection *connection, _dbus_verbose ("Driver got a method call: %s\n", name); /* security checks should have kept this from getting here */ -#ifndef DBUS_DISABLE_ASSERT - { - const char *sender = dbus_message_get_sender (message); - - _dbus_assert (sender != NULL || strcmp (name, "Hello") == 0); - } -#endif + _dbus_assert (dbus_message_get_sender (message) != NULL || + strcmp (name, "Hello") == 0); for (ih = interface_handlers; ih->name != NULL; ih++) { diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 18e87eb..81140a6 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -335,14 +335,11 @@ reallocate_for_length (DBusRealString *real, * disable asserts to profile, you don't get this destroyer * of profiles. */ -#ifdef DBUS_DISABLE_ASSERT -#else -#ifdef DBUS_ENABLE_EMBEDDED_TESTS +#if defined (DBUS_ENABLE_EMBEDDED_TESTS) && !defined (DBUS_DISABLE_ASSERT) new_allocated = 0; /* ensure a realloc every time so that we go * through all malloc failure codepaths */ -#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ -#endif /* !DBUS_DISABLE_ASSERT */ +#endif /* But be sure we always alloc at least space for the new length */ new_allocated = MAX (new_allocated, -- 2.7.4