[gnome-initial-setup/82-support-wi-fi-devices-appearing-dynamically: 2/2] 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: 2/2] network: use more autoptrs
- Date: Mon, 20 Jan 2020 11:19:56 +0000 (UTC)
commit 78c5d51d315aa89b55ba95affe071ecef839d6f3
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 6141390..2223766 100644
--- a/gnome-initial-setup/pages/network/gis-network-page.c
+++ b/gnome-initial-setup/pages/network/gis-network-page.c
@@ -467,16 +467,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);
}
}
@@ -486,16 +485,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);
}
}
@@ -755,7 +753,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);
@@ -774,7 +772,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]