From 05d90f4f20c1fbbb6c532b5f62531c97ced7d63e Mon Sep 17 00:00:00 2001 From: "John (J5) Palmieri" Date: Mon, 11 Sep 2006 15:05:21 +0000 Subject: * dbus/dbus-internal.c: Add dbus_is_verbose so we can have more complex debugging code * dbus/dbus-marshal-basic.c (_dbus_marshal_read_fixed_multi): Move between the test suite ifdefs (_dbus_verbose_bytes): return if verbosity is not enabled --- dbus/dbus-internals.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'dbus/dbus-internals.c') diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index e2d01b11..75eb8ced 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -213,12 +213,31 @@ _dbus_warn (const char *format, #ifdef DBUS_ENABLE_VERBOSE_MODE static dbus_bool_t verbose_initted = FALSE; +static dbus_bool_t verbose = TRUE; #define PTHREAD_IN_VERBOSE 0 #if PTHREAD_IN_VERBOSE #include #endif +static inline void +_dbus_verbose_init (void) +{ + if (!verbose_initted) + { + const char *p = _dbus_getenv ("DBUS_VERBOSE"); + verbose = p != NULL && *p == '1'; + verbose_initted = TRUE; + } +} + +dbus_bool_t +_dbus_is_verbose_real (void) +{ + _dbus_verbose_init (); + return verbose; +} + /** * Prints a warning message to stderr * if the user has enabled verbose mode. @@ -232,7 +251,6 @@ _dbus_verbose_real (const char *format, ...) { va_list args; - static dbus_bool_t verbose = TRUE; static dbus_bool_t need_pid = TRUE; int len; @@ -240,17 +258,8 @@ _dbus_verbose_real (const char *format, * in the non-verbose case we just have the one * conditional and return immediately. */ - if (!verbose) + if (!_dbus_is_verbose_real()) return; - - if (!verbose_initted) - { - const char *p = _dbus_getenv ("DBUS_VERBOSE"); - verbose = p != NULL && *p == '1'; - verbose_initted = TRUE; - if (!verbose) - return; - } /* Print out pid before the line */ if (need_pid) -- cgit