diff options
author | Dan Winship <danw@gnome.org> | 2014-09-05 13:24:16 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-09-09 12:10:13 -0400 |
commit | a874e0beac9832b7c9df8360b16dba69122765a5 (patch) | |
tree | 28b507fe4db98e3258b54d08bfe7549be18915e9 | |
parent | c6a932a2ce4df6c3ddaae8793862963dd14e2f12 (diff) |
libnm: assert that dbus_connection_allocate_data_slot() doesn't fail
dbus_connection_allocate_data_slot() can only fail on ENOMEM, in which
case the immediately-following call to g_set_error() would also get
ENOMEM and abort. So just simplify and assert that the libdbus call
didn't fail.
-rw-r--r-- | libnm/nm-dbus-helpers.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/libnm/nm-dbus-helpers.c b/libnm/nm-dbus-helpers.c index f80cb375a3..64b708616c 100644 --- a/libnm/nm-dbus-helpers.c +++ b/libnm/nm-dbus-helpers.c @@ -28,17 +28,16 @@ static dbus_int32_t priv_slot = -1; -static gboolean +static void _ensure_dbus_data_slot (void) { static gsize init_value = 0; - gboolean success = TRUE; if (g_once_init_enter (&init_value)) { - success = dbus_connection_allocate_data_slot (&priv_slot); + dbus_connection_allocate_data_slot (&priv_slot); + g_assert (priv_slot != -1); g_once_init_leave (&init_value, 1); } - return success; } DBusGConnection * @@ -46,10 +45,7 @@ _nm_dbus_new_connection (GError **error) { DBusGConnection *connection = NULL; - if (!_ensure_dbus_data_slot ()) { - g_set_error (error, DBUS_GERROR, DBUS_GERROR_FAILED, "failed to allocated data slot"); - return NULL; - } + _ensure_dbus_data_slot (); #if HAVE_DBUS_GLIB_100 /* If running as root try the private bus first */ @@ -77,7 +73,7 @@ _nm_dbus_new_connection (GError **error) gboolean _nm_dbus_is_connection_private (DBusGConnection *connection) { - if (!_ensure_dbus_data_slot ()) + if (priv_slot == -1) return FALSE; return !!dbus_connection_get_data (dbus_g_connection_get_connection (connection), priv_slot); } |