[gnome-initial-setup/82-support-wi-fi-devices-appearing-dynamically: 5/5] network: use more autoptrs
- From: Will Thompson <wjt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/82-support-wi-fi-devices-appearing-dynamically: 5/5] network: use more autoptrs
- Date: Mon, 20 Jan 2020 11:18:07 +0000 (UTC)
commit b347ec3122f705396eb0420f2b56ac00edd644d2
Author: Will Thompson <will willthompson co uk>
Date: Mon Jan 20 11:08:57 2020 +0000
network: use more autoptrs
No functional change, just a bit of clean-up.
.../pages/network/gis-network-page.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/gnome-initial-setup/pages/network/gis-network-page.c
b/gnome-initial-setup/pages/network/gis-network-page.c
index e4d5165..4836964 100644
--- a/gnome-initial-setup/pages/network/gis-network-page.c
+++ b/gnome-initial-setup/pages/network/gis-network-page.c
@@ -470,16 +470,15 @@ connection_activate_cb (GObject *object,
gpointer user_data)
{
NMClient *client = NM_CLIENT (object);
- NMActiveConnection *connection;
- GError *error = NULL;
+ NMActiveConnection *connection = NULL;
+ g_autoptr(GError) error = NULL;
connection = nm_client_activate_connection_finish (client, result, &error);
- if (connection) {
- g_object_unref (connection);
+ if (connection != NULL) {
+ g_clear_object (&connection);
} else {
/* failed to activate */
g_warning ("Failed to activate a connection: %s", error->message);
- g_error_free (error);
}
}
@@ -489,16 +488,15 @@ connection_add_activate_cb (GObject *object,
gpointer user_data)
{
NMClient *client = NM_CLIENT (object);
- NMActiveConnection *connection;
- GError *error = NULL;
+ NMActiveConnection *connection = NULL;
+ g_autoptr(GError) error = NULL;
connection = nm_client_add_and_activate_connection_finish (client, result, &error);
- if (connection) {
- g_object_unref (connection);
+ if (connection != NULL) {
+ g_clear_object (&connection);
} else {
/* failed to activate */
g_warning ("Failed to add and activate a connection: %s", error->message);
- g_error_free (error);
}
}
@@ -758,7 +756,7 @@ gis_network_page_constructed (GObject *object)
{
GisNetworkPage *page = GIS_NETWORK_PAGE (object);
GisNetworkPagePrivate *priv = gis_network_page_get_instance_private (page);
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
G_OBJECT_CLASS (gis_network_page_parent_class)->constructed (object);
@@ -777,7 +775,6 @@ gis_network_page_constructed (GObject *object)
if (!priv->nm_client) {
g_warning ("Can't create NetworkManager client, hiding network page: %s",
error->message);
- g_error_free (error);
sync_complete (page);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]