From ab78407fb7f7c46dc058add82a63d4626597141a Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 11 Feb 2014 13:02:46 +0800 Subject: [PATCH] Mac: do not warn and ignore error for init session bus address This is not a major bug but does cause some inconveniences for lib users, it's better we can return an error rather than print to stderr and ignore the error. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=74029 --- dbus/dbus-bus.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index 0fd4831..88772b9 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -136,10 +136,12 @@ get_from_env (char **connection_p, } static dbus_bool_t -init_session_address (void) +init_session_address (DBusError *error) { dbus_bool_t retval; + _dbus_return_val_if_error_is_set (error, FALSE); + retval = FALSE; /* First, look in the environment. This is the normal case on @@ -150,7 +152,6 @@ init_session_address (void) { dbus_bool_t supported; DBusString addr; - DBusError error = DBUS_ERROR_INIT; if (!_dbus_string_init (&addr)) return FALSE; @@ -159,19 +160,12 @@ init_session_address (void) /* So it's not in the environment - let's try a platform-specific method. * On MacOS, this involves asking launchd. On Windows (not specified yet) * we might do a COM lookup. - * Ignore errors - if we failed, fall back to autolaunch. */ - retval = _dbus_lookup_session_address (&supported, &addr, &error); + */ + retval = _dbus_lookup_session_address (&supported, &addr, error); if (supported && retval) { retval =_dbus_string_steal_data (&addr, &bus_connection_addresses[DBUS_BUS_SESSION]); } - else if (supported && !retval) - { - if (dbus_error_is_set(&error)) - _dbus_warn ("Dynamic session lookup supported but failed: %s\n", error.message); - else - _dbus_warn ("Dynamic session lookup supported but failed silently\n"); - } _dbus_string_free (&addr); } else @@ -193,8 +187,10 @@ init_session_address (void) } static dbus_bool_t -init_connections_unlocked (void) +init_connections_unlocked (DBusError *error) { + _dbus_return_val_if_error_is_set (error, FALSE); + if (!initialized) { const char *s; @@ -244,7 +240,7 @@ init_connections_unlocked (void) { _dbus_verbose ("Filling in session bus address...\n"); - if (!init_session_address ()) + if (!init_session_address (error)) return FALSE; _dbus_verbose (" \"%s\"\n", bus_connection_addresses[DBUS_BUS_SESSION] ? @@ -434,9 +430,10 @@ internal_bus_get (DBusBusType type, return NULL; } - if (!init_connections_unlocked ()) + if (!init_connections_unlocked (error)) { - _DBUS_SET_OOM (error); + if (!dbus_error_is_set (error)) + _DBUS_SET_OOM (error); goto out; } -- 1.7.9.5