From: Simon McVittie Date: Fri, 5 Aug 2011 12:43:12 +0000 (+0100) Subject: dbus-internals: make sure function-like macros expand to something non-empty X-Git-Tag: dbus-1.5.8~5^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2829a59951304d11df0483e74ba1acdf25d50acc;p=thirdparty%2Fdbus.git dbus-internals: make sure function-like macros expand to something non-empty This avoids sometimes-surprising semantics, and also compiler warnings when they're the only statement in an "if" or "else" clause, without {}. --- diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 06e6c16b0..4e383bcaa 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -108,20 +108,20 @@ dbus_bool_t _dbus_is_verbose_real (void); # define _dbus_is_verbose _dbus_is_verbose_real #else # ifdef HAVE_ISO_VARARGS -# define _dbus_verbose(...) +# define _dbus_verbose(...) do { } while (0) # elif defined (HAVE_GNUC_VARARGS) -# define _dbus_verbose(format...) +# define _dbus_verbose(format...) do { } while (0) # else static void _dbus_verbose(const char * x,...) {;} # endif -# define _dbus_verbose_reset() +# define _dbus_verbose_reset() do { } while (0) # define _dbus_is_verbose() FALSE #endif /* !DBUS_ENABLE_VERBOSE_MODE */ const char* _dbus_strerror (int error_number); #ifdef DBUS_DISABLE_ASSERT -#define _dbus_assert(condition) +#define _dbus_assert(condition) do { } while (0) #else void _dbus_real_assert (dbus_bool_t condition, const char *condition_text, @@ -133,7 +133,7 @@ void _dbus_real_assert (dbus_bool_t condition, #endif /* !DBUS_DISABLE_ASSERT */ #ifdef DBUS_DISABLE_ASSERT -#define _dbus_assert_not_reached(explanation) +#define _dbus_assert_not_reached(explanation) do { } while (0) #else void _dbus_real_assert_not_reached (const char *explanation, const char *file, @@ -181,8 +181,8 @@ extern const char *_dbus_return_if_fail_warning_format; /* this is an assert and not an error, but in the typical --disable-checks case (you're trying * to really minimize code size), disabling these assertions makes sense. */ -#define _DBUS_ASSERT_ERROR_IS_SET(error) -#define _DBUS_ASSERT_ERROR_IS_CLEAR(error) +#define _DBUS_ASSERT_ERROR_IS_SET(error) do { } while (0) +#define _DBUS_ASSERT_ERROR_IS_CLEAR(error) do { } while (0) #else #define _DBUS_ASSERT_ERROR_IS_SET(error) _dbus_assert ((error) == NULL || dbus_error_is_set ((error))) #define _DBUS_ASSERT_ERROR_IS_CLEAR(error) _dbus_assert ((error) == NULL || !dbus_error_is_set ((error)))