dbus/dbus dbus-bus.c, 1.61, 1.62 dbus-connection.c, 1.139,
1.140 dbus-dataslot.c, 1.15, 1.16 dbus-internals.c, 1.50,
1.51 dbus-internals.h, 1.61, 1.62 dbus-marshal-basic.c, 1.30,
1.31 dbus-marshal-recursive.c, 1.52, 1.53 dbus-server.c, 1.50,
1.51 dbus-sysdeps-unix.c, 1.10, 1.11 dbus-transport.c, 1.53,
1.54 dbus-watch.c, 1.19, 1.20
Havoc Pennington
hp at kemper.freedesktop.org
Tue Oct 17 13:52:15 PDT 2006
Update of /cvs/dbus/dbus/dbus
In directory kemper:/tmp/cvs-serv29415/dbus
Modified Files:
dbus-bus.c dbus-connection.c dbus-dataslot.c dbus-internals.c
dbus-internals.h dbus-marshal-basic.c dbus-marshal-recursive.c
dbus-server.c dbus-sysdeps-unix.c dbus-transport.c
dbus-watch.c
Log Message:
2006-10-17 Havoc Pennington <hp at redhat.com>
* dbus/dbus-internals.c (_dbus_warn_check_failed): new function to
be used for return_if_fail type warnings; prefixes the pid, and
fatal by default.
Index: dbus-bus.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-bus.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- dbus-bus.c 1 Oct 2006 17:21:03 -0000 1.61
+++ dbus-bus.c 17 Oct 2006 20:52:13 -0000 1.62
@@ -93,7 +93,7 @@
while (i < N_BUS_TYPES)
{
if (bus_connections[i] != NULL)
- _dbus_warn ("dbus_shutdown() called but connections were still live!");
+ _dbus_warn_check_failed ("dbus_shutdown() called but connections were still live. This probably means the application did not drop all its references to bus connections.\n");
dbus_free (bus_connection_addresses[i]);
bus_connection_addresses[i] = NULL;
@@ -547,10 +547,9 @@
if (bd->unique_name != NULL)
{
- _dbus_warn ("Attempt to register the same DBusConnection with the message bus, but it is already registered\n");
- /* This isn't an error, it's a programming bug. We'll be nice
- * and not _dbus_assert_not_reached()
- */
+ _dbus_warn_check_failed ("Attempt to register the same DBusConnection %s with the message bus a second time.\n",
+ bd->unique_name);
+ /* This isn't an error, it's a programming bug. so return TRUE */
return TRUE;
}
Index: dbus-connection.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -d -r1.139 -r1.140
--- dbus-connection.c 13 Oct 2006 16:26:47 -0000 1.139
+++ dbus-connection.c 17 Oct 2006 20:52:13 -0000 1.140
@@ -2007,11 +2007,10 @@
#ifndef DBUS_DISABLE_CHECKS
if (_dbus_transport_get_is_connected (connection->transport))
{
- _dbus_warn ("The last reference on a connection was dropped without closing the connection. This is a bug. See dbus_connection_unref() documentation for details.\n");
- if (connection->shareable)
- _dbus_warn ("Most likely, the application called unref() too many times and removed a reference belonging to libdbus, since this is a shared connection.\n");
- else
- _dbus_warn ("Most likely, the application was supposed to call dbus_connection_close(), since this is a private connection.\n");
+ _dbus_warn_check_failed ("The last reference on a connection was dropped without closing the connection. This is a bug in an application. See dbus_connection_unref() documentation for details.\n%s",
+ connection->shareable ?
+ "Most likely, the application called unref() too many times and removed a reference belonging to libdbus, since this is a shared connection.\n" :
+ "Most likely, the application was supposed to call dbus_connection_close(), since this is a private connection.\n");
return;
}
#endif
@@ -2128,7 +2127,7 @@
{
CONNECTION_UNLOCK (connection);
- _dbus_warn ("Applications must not close shared connections - see dbus_connection_close() docs. This is a bug in the application.\n");
+ _dbus_warn_check_failed ("Applications must not close shared connections - see dbus_connection_close() docs. This is a bug in the application.\n");
return;
}
#endif
@@ -4378,8 +4377,8 @@
#ifndef DBUS_DISABLE_CHECKS
if (connection->watches == NULL)
{
- _dbus_warn ("Re-entrant call to %s is not allowed\n",
- _DBUS_FUNCTION_NAME);
+ _dbus_warn_check_failed ("Re-entrant call to %s is not allowed\n",
+ _DBUS_FUNCTION_NAME);
return FALSE;
}
#endif
@@ -4460,8 +4459,8 @@
#ifndef DBUS_DISABLE_CHECKS
if (connection->timeouts == NULL)
{
- _dbus_warn ("Re-entrant call to %s is not allowed\n",
- _DBUS_FUNCTION_NAME);
+ _dbus_warn_check_failed ("Re-entrant call to %s is not allowed\n",
+ _DBUS_FUNCTION_NAME);
return FALSE;
}
#endif
@@ -4900,8 +4899,8 @@
#ifndef DBUS_DISABLE_CHECKS
if (filter == NULL)
{
- _dbus_warn ("Attempt to remove filter function %p user data %p, but no such filter has been added\n",
- function, user_data);
+ _dbus_warn_check_failed ("Attempt to remove filter function %p user data %p, but no such filter has been added\n",
+ function, user_data);
return;
}
#endif
Index: dbus-dataslot.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-dataslot.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- dbus-dataslot.c 14 Sep 2006 04:26:00 -0000 1.15
+++ dbus-dataslot.c 17 Oct 2006 20:52:13 -0000 1.16
@@ -79,7 +79,7 @@
}
else if (allocator->lock_loc != mutex_loc)
{
- _dbus_warn ("D-Bus threads were initialized after first using the D-Bus library. If your application does not directly initialize threads or use D-Bus, keep in mind that some library or plugin may have used D-Bus or initialized threads behind your back. You can often fix this problem by calling dbus_init_threads() or dbus_g_threads_init() early in your main() method, before D-Bus is used.");
+ _dbus_warn_check_failed ("D-Bus threads were initialized after first using the D-Bus library. If your application does not directly initialize threads or use D-Bus, keep in mind that some library or plugin may have used D-Bus or initialized threads behind your back. You can often fix this problem by calling dbus_init_threads() or dbus_g_threads_init() early in your main() method, before D-Bus is used.\n");
_dbus_assert_not_reached ("exiting");
}
Index: dbus-internals.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-internals.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- dbus-internals.c 1 Oct 2006 15:36:18 -0000 1.50
+++ dbus-internals.c 17 Oct 2006 20:52:13 -0000 1.51
@@ -192,9 +192,44 @@
static dbus_bool_t warn_initted = FALSE;
static dbus_bool_t fatal_warnings = FALSE;
+static dbus_bool_t fatal_warnings_on_check_failed = TRUE;
+
+static void
+init_warnings(void)
+{
+ if (!warn_initted)
+ {
+ const char *s;
+ s = _dbus_getenv ("DBUS_FATAL_WARNINGS");
+ if (s && *s)
+ {
+ if (*s == '0')
+ {
+ fatal_warnings = FALSE;
+ fatal_warnings_on_check_failed = FALSE;
+ }
+ else if (*s == '1')
+ {
+ fatal_warnings = TRUE;
+ fatal_warnings_on_check_failed = TRUE;
+ }
+ else
+ {
+ fprintf(stderr, "DBUS_FATAL_WARNINGS should be set to 0 or 1 if set, not '%s'",
+ s);
+ }
+ }
+
+ warn_initted = TRUE;
+ }
+}
/**
- * Prints a warning message to stderr.
+ * Prints a warning message to stderr. Can optionally be made to exit
+ * fatally by setting DBUS_FATAL_WARNINGS, but this is rarely
+ * used. This function should be considered pretty much equivalent to
+ * fprintf(stderr). _dbus_warn_check_failed() on the other hand is
+ * suitable for use when a programming mistake has been made.
*
* @param format printf-style format string.
*/
@@ -205,20 +240,43 @@
va_list args;
if (!warn_initted)
- {
- const char *s;
- s = _dbus_getenv ("DBUS_FATAL_WARNINGS");
- if (s && *s)
- fatal_warnings = TRUE;
+ init_warnings ();
+
+ va_start (args, format);
+ vfprintf (stderr, format, args);
+ va_end (args);
- warn_initted = TRUE;
+ if (fatal_warnings)
+ {
+ fflush (stderr);
+ _dbus_abort ();
}
+}
+
+/**
+ * Prints a "critical" warning to stderr when an assertion fails;
+ * differs from _dbus_warn primarily in that it prefixes the pid and
+ * defaults to fatal. This should be used only when a programming
+ * error has been detected. (NOT for unavoidable errors that an app
+ * might handle - those should be returned as DBusError.) Calling this
+ * means "there is a bug"
+ */
+void
+_dbus_warn_check_failed(const char *format,
+ ...)
+{
+ va_list args;
+
+ if (!warn_initted)
+ init_warnings ();
+
+ fprintf (stderr, "process %lu: ", _dbus_getpid ());
va_start (args, format);
vfprintf (stderr, format, args);
va_end (args);
- if (fatal_warnings)
+ if (fatal_warnings_on_check_failed)
{
fflush (stderr);
_dbus_abort ();
@@ -664,10 +722,9 @@
* here. But in a production build, we want to be nice and loud about
* this.
*/
- _dbus_warn ("D-Bus library appears to be incorrectly set up; failed to read machine uuid: %s\n",
- error.message);
- _dbus_warn ("See the manual page for dbus-uuidgen to correct this issue.\n");
- _dbus_warn ("Continuing with a bogus made-up machine UUID, which may cause problems.");
+ _dbus_warn_check_failed ("D-Bus library appears to be incorrectly set up; failed to read machine uuid: %s\n"
+ "See the manual page for dbus-uuidgen to correct this issue.\n",
+ error.message);
#endif
dbus_error_free (&error);
@@ -722,7 +779,7 @@
#ifndef DBUS_DISABLE_CHECKS
/** String used in _dbus_return_if_fail macro */
const char _dbus_return_if_fail_warning_format[] =
-"%lu: arguments to %s() were incorrect, assertion \"%s\" failed in file %s line %d.\n"
+"arguments to %s() were incorrect, assertion \"%s\" failed in file %s line %d.\n"
"This is normally a bug in some application using the D-Bus library.\n";
#endif
Index: dbus-internals.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-internals.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- dbus-internals.h 1 Oct 2006 03:18:47 -0000 1.61
+++ dbus-internals.h 17 Oct 2006 20:52:13 -0000 1.62
@@ -42,6 +42,10 @@
void _dbus_warn (const char *format,
...) _DBUS_GNUC_PRINTF (1, 2);
+void _dbus_warn_check_failed (const char *format,
+ ...) _DBUS_GNUC_PRINTF (1, 2);
+
+
#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
#define _DBUS_FUNCTION_NAME __func__
#elif defined(__GNUC__)
@@ -129,19 +133,19 @@
#else
extern const char _dbus_return_if_fail_warning_format[];
-#define _dbus_return_if_fail(condition) do { \
- _dbus_assert ((*(const char*)_DBUS_FUNCTION_NAME) != '_'); \
- if (!(condition)) { \
- _dbus_warn (_dbus_return_if_fail_warning_format, \
- _dbus_getpid (), _DBUS_FUNCTION_NAME, #condition, __FILE__, __LINE__); \
- return; \
+#define _dbus_return_if_fail(condition) do { \
+ _dbus_assert ((*(const char*)_DBUS_FUNCTION_NAME) != '_'); \
+ if (!(condition)) { \
+ _dbus_warn_check_failed (_dbus_return_if_fail_warning_format, \
+ _DBUS_FUNCTION_NAME, #condition, __FILE__, __LINE__); \
+ return; \
} } while (0)
#define _dbus_return_val_if_fail(condition, val) do { \
_dbus_assert ((*(const char*)_DBUS_FUNCTION_NAME) != '_'); \
if (!(condition)) { \
- _dbus_warn (_dbus_return_if_fail_warning_format, \
- _dbus_getpid (), _DBUS_FUNCTION_NAME, #condition, __FILE__, __LINE__); \
+ _dbus_warn_check_failed (_dbus_return_if_fail_warning_format, \
+ _DBUS_FUNCTION_NAME, #condition, __FILE__, __LINE__); \
return (val); \
} } while (0)
Index: dbus-marshal-basic.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-basic.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- dbus-marshal-basic.c 11 Sep 2006 15:05:21 -0000 1.30
+++ dbus-marshal-basic.c 17 Oct 2006 20:52:13 -0000 1.31
@@ -578,8 +578,8 @@
}
break;
default:
- _dbus_warn ("type %s %d not a basic type\n",
- _dbus_type_to_string (type), type);
+ _dbus_warn_check_failed ("type %s %d not a basic type\n",
+ _dbus_type_to_string (type), type);
_dbus_assert_not_reached ("not a basic type");
break;
}
Index: dbus-marshal-recursive.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-recursive.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- dbus-marshal-recursive.c 11 Sep 2006 14:42:48 -0000 1.52
+++ dbus-marshal-recursive.c 17 Oct 2006 20:52:13 -0000 1.53
@@ -1007,7 +1007,7 @@
_dbus_verbose ("recursing into type %s\n", _dbus_type_to_string (t));
#ifndef DBUS_DISABLE_CHECKS
if (t == DBUS_TYPE_INVALID)
- _dbus_warn ("You can't recurse into an empty array or off the end of a message body\n");
+ _dbus_warn_check_failed ("You can't recurse into an empty array or off the end of a message body\n");
#endif /* DBUS_DISABLE_CHECKS */
_dbus_assert_not_reached ("don't yet handle recursing into this type");
@@ -1645,9 +1645,9 @@
if (expected != sub->container_type)
{
- _dbus_warn ("Writing an element of type %s, but the expected type here is %s\n",
- _dbus_type_to_string (sub->container_type),
- _dbus_type_to_string (expected));
+ _dbus_warn_check_failed ("Writing an element of type %s, but the expected type here is %s\n",
+ _dbus_type_to_string (sub->container_type),
+ _dbus_type_to_string (expected));
_dbus_assert_not_reached ("bad array element or variant content written");
}
}
@@ -1702,8 +1702,8 @@
if (expected != typecode)
{
- _dbus_warn ("Array or variant type requires that type %s be written, but %s was written\n",
- _dbus_type_to_string (expected), _dbus_type_to_string (typecode));
+ _dbus_warn_check_failed ("Array or variant type requires that type %s be written, but %s was written\n",
+ _dbus_type_to_string (expected), _dbus_type_to_string (typecode));
_dbus_assert_not_reached ("bad type inserted somewhere inside an array or variant");
}
}
@@ -1794,10 +1794,10 @@
writer->type_str,
writer->u.array.element_type_pos + 1))
{
- _dbus_warn ("Writing an array of '%s' but this is incompatible with the expected type of elements in the parent array\n",
- _dbus_string_get_const_data_len (contained_type,
- contained_type_start,
- contained_type_len));
+ _dbus_warn_check_failed ("Writing an array of '%s' but this is incompatible with the expected type of elements in the parent array\n",
+ _dbus_string_get_const_data_len (contained_type,
+ contained_type_start,
+ contained_type_len));
_dbus_assert_not_reached ("incompatible type for child array");
}
}
Index: dbus-server.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-server.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- dbus-server.c 1 Oct 2006 15:36:18 -0000 1.50
+++ dbus-server.c 17 Oct 2006 20:52:13 -0000 1.51
@@ -875,7 +875,7 @@
}
else
{
- _dbus_warn ("Re-entrant call to %s\n", _DBUS_FUNCTION_NAME);
+ _dbus_warn_check_failed ("Re-entrant call to %s\n", _DBUS_FUNCTION_NAME);
result = FALSE;
}
server->watches = watches;
@@ -928,7 +928,7 @@
}
else
{
- _dbus_warn ("Re-entrant call to %s\n", _DBUS_FUNCTION_NAME);
+ _dbus_warn_check_failed ("Re-entrant call to %s\n", _DBUS_FUNCTION_NAME);
result = FALSE;
}
server->timeouts = timeouts;
Index: dbus-sysdeps-unix.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-unix.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dbus-sysdeps-unix.c 2 Oct 2006 18:45:27 -0000 1.10
+++ dbus-sysdeps-unix.c 17 Oct 2006 20:52:13 -0000 1.11
@@ -2320,7 +2320,7 @@
++i;
argv[i] = "--autolaunch";
++i;
- argv[i] = _dbus_string_get_const_data (&uuid);
+ argv[i] = /* const cast */ (char*) _dbus_string_get_const_data (&uuid);
++i;
argv[i] = "--binary-syntax";
++i;
Index: dbus-transport.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-transport.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- dbus-transport.c 30 Sep 2006 19:38:34 -0000 1.53
+++ dbus-transport.c 17 Oct 2006 20:52:13 -0000 1.54
@@ -676,7 +676,7 @@
if (dbus_watch_get_fd (watch) < 0)
{
- _dbus_warn ("Tried to handle an invalidated watch; this watch should have been removed\n");
+ _dbus_warn_check_failed ("Tried to handle an invalidated watch; this watch should have been removed\n");
return TRUE;
}
Index: dbus-watch.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-watch.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- dbus-watch.c 3 Aug 2006 20:34:36 -0000 1.19
+++ dbus-watch.c 17 Oct 2006 20:52:13 -0000 1.20
@@ -594,8 +594,8 @@
#ifndef DBUS_DISABLE_CHECKS
if (watch->fd < 0 || watch->flags == 0)
{
- _dbus_warn ("%s: Watch is invalid, it should have been removed\n",
- _DBUS_FUNCTION_NAME);
+ _dbus_warn_check_failed ("%s: Watch is invalid, it should have been removed\n",
+ _DBUS_FUNCTION_NAME);
return TRUE;
}
#endif
More information about the dbus-commit
mailing list