summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-03-23 11:09:24 +0100
committerThomas Haller <thaller@redhat.com>2020-03-23 11:22:38 +0100
commit52dbab7d0703d9f3982fcddd855b92886eaef866 (patch)
treee0d01ed5a80a664f58e287d6252af4c277178170 /clients
parent073994ca4284a5e99314195981aa254f06c3bf69 (diff)
downloadNetworkManager-52dbab7d0703d9f3982fcddd855b92886eaef866.tar.gz
all: use nm_clear_pointer() instead of g_clear_pointer()
g_clear_pointer() would always cast the destroy notify function pointer to GDestroyNotify. That means, it lost some type safety, like GPtrArray *ptr_arr = ... g_clear_pointer (&ptr_arr, g_array_unref); Since glib 2.58 ([1]), g_clear_pointer() is also more type safe. But this is not used by NetworkManager, because we don't set GLIB_VERSION_MIN_REQUIRED to 2.58. [1] https://gitlab.gnome.org/GNOME/glib/-/commit/f9a9902aac826ab4aecc25f6eb533a418a4fa559 We have nm_clear_pointer() to avoid this issue for a long time (pre 1.12.0). Possibly we should redefine in our source tree g_clear_pointer() as nm_clear_pointer(). However, I don't like to patch glib functions with our own variant. Arguably, we do patch g_clear_error() in such a manner. But there the point is to make the function inlinable. Also, nm_clear_pointer() returns a boolean that indicates whether anything was cleared. That is sometimes useful. I think we should just consistently use nm_clear_pointer() instead, which does always the preferable thing. Replace: sed 's/\<g_clear_pointer *(\([^;]*\), *\([a-z_A-Z0-9]\+\) *)/nm_clear_pointer (\1, \2)/g' $(git grep -l g_clear_pointer) -i
Diffstat (limited to 'clients')
-rw-r--r--clients/cli/connections.c6
-rw-r--r--clients/nm-online.c2
-rw-r--r--clients/tui/nmt-password-dialog.c4
-rw-r--r--clients/tui/nmt-route-entry.c2
4 files changed, 7 insertions, 7 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 752e63c4ac..45e7c0042f 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -423,7 +423,7 @@ _metagen_con_show_row_data_init_primary_active (MetagenConShowRowData *row_data)
g_object_unref (row_data->primary_active);
row_data->primary_active = g_object_ref (best_ac);
}
- g_clear_pointer (&row_data->all_active, g_ptr_array_unref);
+ nm_clear_pointer (&row_data->all_active, g_ptr_array_unref);
}
static void
@@ -436,7 +436,7 @@ _metagen_con_show_row_data_destroy (gpointer data)
g_clear_object (&row_data->connection);
g_clear_object (&row_data->primary_active);
- g_clear_pointer (&row_data->all_active, g_ptr_array_unref);
+ nm_clear_pointer (&row_data->all_active, g_ptr_array_unref);
g_slice_free (MetagenConShowRowData, row_data);
}
@@ -9246,7 +9246,7 @@ nmcli_con_tab_completion (const char *text, int start, int end)
if (generator_func)
match_array = rl_completion_matches (text, generator_func);
- g_clear_pointer (&nmc_tab_completion.words, g_strfreev);
+ nm_clear_pointer (&nmc_tab_completion.words, g_strfreev);
return match_array;
}
diff --git a/clients/nm-online.c b/clients/nm-online.c
index 9ea57641cb..5950da568c 100644
--- a/clients/nm-online.c
+++ b/clients/nm-online.c
@@ -303,7 +303,7 @@ main (int argc, char *argv[])
nm_clear_g_signal_handler (data.client, &data.client_notify_id);
g_clear_object (&data.client);
- g_clear_pointer (&data.loop, g_main_loop_unref);
+ nm_clear_pointer (&data.loop, g_main_loop_unref);
if (!data.quiet)
_print_progress (data.wait_startup, -1, NM_MAX (0, data.end_timestamp_ms - _now_ms ()), data.retval);
diff --git a/clients/tui/nmt-password-dialog.c b/clients/tui/nmt-password-dialog.c
index 009ab7ce4c..979a5c6871 100644
--- a/clients/tui/nmt-password-dialog.c
+++ b/clients/tui/nmt-password-dialog.c
@@ -175,8 +175,8 @@ nmt_password_dialog_finalize (GObject *object)
g_free (priv->request_id);
g_free (priv->prompt);
- g_clear_pointer (&priv->entries, g_ptr_array_unref);
- g_clear_pointer (&priv->secrets, g_ptr_array_unref);
+ nm_clear_pointer (&priv->entries, g_ptr_array_unref);
+ nm_clear_pointer (&priv->secrets, g_ptr_array_unref);
G_OBJECT_CLASS (nmt_password_dialog_parent_class)->finalize (object);
}
diff --git a/clients/tui/nmt-route-entry.c b/clients/tui/nmt-route-entry.c
index e0f6df4e4f..88d64fa3e3 100644
--- a/clients/tui/nmt-route-entry.c
+++ b/clients/tui/nmt-route-entry.c
@@ -148,7 +148,7 @@ nmt_route_entry_finalize (GObject *object)
{
NmtRouteEntryPrivate *priv = NMT_ROUTE_ENTRY_GET_PRIVATE (object);
- g_clear_pointer (&priv->route, nm_ip_route_unref);
+ nm_clear_pointer (&priv->route, nm_ip_route_unref);
G_OBJECT_CLASS (nmt_route_entry_parent_class)->finalize (object);
}