diff options
author | Thomas Haller <thaller@redhat.com> | 2019-09-04 14:17:17 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-09-21 14:58:26 +0200 |
commit | 7db00be6b783d2435217a0fcef5c8159cfd1ce4c (patch) | |
tree | 576f37dbb081a3f64929cdb34a2d35fa7bd78c9b | |
parent | 0f9157f07b93e51dd6d71d99817b668494996944 (diff) | |
download | NetworkManager-7db00be6b783d2435217a0fcef5c8159cfd1ce4c.tar.gz |
libnm: inline NMManager's get_permissions_sync()
Synchrnous initialization is problmatic and needs cleanup.
get_permissions_sync() is an internal function, that has only one
caller. We need to keep track of functions that make synchronous D-Bus
calls. Move the synchronous call into the caller, so that it's clearer
who calls such API.
-rw-r--r-- | libnm/nm-manager.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index b4111cd040..00ecdccbef 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -369,26 +369,6 @@ update_permissions (NMManager *self, GVariant *permissions) g_list_free (keys); } -static gboolean -get_permissions_sync (NMManager *self, GError **error) -{ - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); - GVariant *permissions; - - if (nmdbus_manager_call_get_permissions_sync (priv->proxy, - &permissions, - NULL, error)) { - update_permissions (self, permissions); - g_variant_unref (permissions); - return TRUE; - } else { - if (error && *error) - g_dbus_error_strip_remote_error (*error); - update_permissions (self, NULL); - return FALSE; - } -} - static void get_permissions_reply (GObject *object, GAsyncResult *result, @@ -1756,19 +1736,25 @@ constructed (GObject *object) static gboolean init_sync (GInitable *initable, GCancellable *cancellable, GError **error) { - NMManager *manager = NM_MANAGER (initable); - GError *local_error = NULL; + NMManager *self = NM_MANAGER (initable); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + gs_free_error GError *local_error = NULL; + gs_unref_variant GVariant *permissions = NULL; if (!nm_manager_parent_initable_iface->init (initable, cancellable, error)) { /* Never happens. */ g_return_val_if_reached (FALSE); } - if (!get_permissions_sync (manager, &local_error)) { + if (!nmdbus_manager_call_get_permissions_sync (priv->proxy, + &permissions, + NULL, + &local_error)) { + g_dbus_error_strip_remote_error (local_error); g_warning ("Unable to get permissions: %s\n", local_error->message); - g_error_free (local_error); } + update_permissions (self, permissions); return TRUE; } |