diff --git a/libnm/nm-client.c b/libnm/nm-client.c index 17c31bf04..ccc96e947 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -2525,10 +2525,7 @@ dispose (GObject *object) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); - if (priv->new_object_manager_cancellable) { - g_cancellable_cancel (priv->new_object_manager_cancellable); - g_clear_object (&priv->new_object_manager_cancellable); - } + nm_clear_g_cancellable (&priv->new_object_manager_cancellable); if (priv->manager) { g_signal_handlers_disconnect_by_data (priv->manager, object); diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 5520b580d..d3df73375 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -1274,11 +1274,7 @@ dispose (GObject *object) NMManager *manager = NM_MANAGER (object); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (object); - if (priv->perm_call_cancellable) { - g_cancellable_cancel (priv->perm_call_cancellable); - g_clear_object (&priv->perm_call_cancellable); - } - + nm_clear_g_cancellable (&priv->perm_call_cancellable); if (priv->devices) { g_ptr_array_unref (priv->devices); diff --git a/src/devices/bluetooth/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c index 58fa9b016..2f0afa168 100644 --- a/src/devices/bluetooth/nm-bluez-manager.c +++ b/src/devices/bluetooth/nm-bluez-manager.c @@ -134,10 +134,7 @@ cleanup_checking (NMBluezManager *self, gboolean do_unwatch_name) { NMBluezManagerPrivate *priv = NM_BLUEZ_MANAGER_GET_PRIVATE (self); - if (priv->async_cancellable) { - g_cancellable_cancel (priv->async_cancellable); - g_clear_object (&priv->async_cancellable); - } + nm_clear_g_cancellable (&priv->async_cancellable); g_clear_object (&priv->introspect_proxy); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 9ad016d7d..51e97a6a8 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -11860,9 +11860,8 @@ deactivate_async_ready (NMDevice *self, if ( g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || (priv->deactivating_cancellable && g_cancellable_is_cancelled (priv->deactivating_cancellable))) { _LOGW (LOGD_DEVICE, "Deactivation cancelled"); - } - /* In every other case, transition to the DISCONNECTED state */ - else { + } else { + /* In every other case, transition to the DISCONNECTED state */ if (error) { _LOGW (LOGD_DEVICE, "Deactivation failed: %s", error->message); @@ -11890,11 +11889,8 @@ deactivate_dispatcher_complete (guint call_id, gpointer user_data) priv->dispatcher.post_state = NM_DEVICE_STATE_UNKNOWN; priv->dispatcher.post_state_reason = NM_DEVICE_STATE_REASON_NONE; - if (priv->deactivating_cancellable) { + if (nm_clear_g_cancellable (&priv->deactivating_cancellable)) g_warn_if_reached (); - g_cancellable_cancel (priv->deactivating_cancellable); - g_clear_object (&priv->deactivating_cancellable); - } if ( NM_DEVICE_GET_CLASS (self)->deactivate_async && NM_DEVICE_GET_CLASS (self)->deactivate_async_finish) { diff --git a/src/nm-auth-manager.c b/src/nm-auth-manager.c index 4359d8f18..b848e2e35 100644 --- a/src/nm-auth-manager.c +++ b/src/nm-auth-manager.c @@ -595,10 +595,7 @@ dispose (GObject *object) /* since we take a reference for each queued call, we don't expect to have any queued calls in dispose() */ g_assert (!priv->queued_calls); - if (priv->new_proxy_cancellable) { - g_cancellable_cancel (priv->new_proxy_cancellable); - g_clear_object (&priv->new_proxy_cancellable); - } + nm_clear_g_cancellable (&priv->new_proxy_cancellable); if (priv->proxy) { g_signal_handlers_disconnect_by_data (priv->proxy, self); diff --git a/src/nm-auth-utils.c b/src/nm-auth-utils.c index 930f6d0ff..f9c958e91 100644 --- a/src/nm-auth-utils.c +++ b/src/nm-auth-utils.c @@ -301,12 +301,10 @@ auth_call_cancel (gpointer user_data) { AuthCall *call = user_data; - if (call->cancellable) { + if (nm_clear_g_cancellable (&call->cancellable)) { /* we don't free call immediately. Instead we cancel the async operation * and set cancellable to NULL. pk_call_cb() will check for this and * do the final cleanup. */ - g_cancellable_cancel (call->cancellable); - g_clear_object (&call->cancellable); } else { g_source_remove (call->call_idle_id); auth_call_free (call); diff --git a/src/nm-policy.c b/src/nm-policy.c index bc602db72..a8682d5df 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -523,10 +523,7 @@ update_system_hostname (NMPolicy *self, NMDevice *best4, NMDevice *best6) g_return_if_fail (self != NULL); - if (priv->lookup_cancellable) { - g_cancellable_cancel (priv->lookup_cancellable); - g_clear_object (&priv->lookup_cancellable); - } + nm_clear_g_cancellable (&priv->lookup_cancellable); /* Hostname precedence order: * @@ -1953,11 +1950,7 @@ dns_config_changed (NMDnsManager *dns_manager, gpointer user_data) * (race in updating DNS and doing the reverse lookup). */ - /* Stop a lookup thread if any. */ - if (priv->lookup_cancellable) { - g_cancellable_cancel (priv->lookup_cancellable); - g_clear_object (&priv->lookup_cancellable); - } + nm_clear_g_cancellable (&priv->lookup_cancellable); /* Re-start the hostname lookup thread if we don't have hostname yet. */ if (priv->lookup_addr) { diff --git a/src/supplicant/nm-supplicant-manager.c b/src/supplicant/nm-supplicant-manager.c index 0a7b4c620..49650ab71 100644 --- a/src/supplicant/nm-supplicant-manager.c +++ b/src/supplicant/nm-supplicant-manager.c @@ -398,10 +398,7 @@ dispose (GObject *object) nm_clear_g_source (&priv->die_count_reset_id); - if (priv->cancellable) { - g_cancellable_cancel (priv->cancellable); - g_clear_object (&priv->cancellable); - } + nm_clear_g_cancellable (&priv->cancellable); if (priv->ifaces) { for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) diff --git a/src/vpn/nm-vpn-connection.c b/src/vpn/nm-vpn-connection.c index 3d4536e70..2120bbe37 100644 --- a/src/vpn/nm-vpn-connection.c +++ b/src/vpn/nm-vpn-connection.c @@ -2647,10 +2647,8 @@ dispose (GObject *object) cancel_get_secrets (self); - if (priv->cancellable) { - g_cancellable_cancel (priv->cancellable); - g_clear_object (&priv->cancellable); - } + nm_clear_g_cancellable (&priv->cancellable); + g_clear_object (&priv->proxy_config); nm_exported_object_clear_and_unexport (&priv->ip4_config); nm_exported_object_clear_and_unexport (&priv->ip6_config);