all: use nm_clear_g_free() instead of g_clear_pointer()

I think it's preferable to use nm_clear_g_free() instead of
g_clear_pointer(, g_free). The reasons are not very strong,
but I think it is overall preferable to have a shorthand for this
frequently used functionality.

   sed 's/\<g_clear_pointer *(\([^;]*\), *\(g_free\) *)/nm_clear_g_free (\1)/g' $(git grep -l g_clear_pointer) -i
This commit is contained in:
Thomas Haller 2020-03-23 11:00:43 +01:00
parent c50b4621d4
commit 073994ca42
44 changed files with 123 additions and 123 deletions

View file

@ -78,10 +78,10 @@ nmt_newt_grid_finalize (GObject *object)
NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE (object);
g_array_unref (priv->children);
g_clear_pointer (&priv->row_heights, g_free);
g_clear_pointer (&priv->col_widths, g_free);
g_clear_pointer (&priv->expand_rows, g_free);
g_clear_pointer (&priv->expand_cols, g_free);
nm_clear_g_free (&priv->row_heights);
nm_clear_g_free (&priv->col_widths);
nm_clear_g_free (&priv->expand_rows);
nm_clear_g_free (&priv->expand_cols);
G_OBJECT_CLASS (nmt_newt_grid_parent_class)->finalize (object);
}

View file

@ -80,7 +80,7 @@ nmt_connect_connection_free (NmtConnectConnection *nmtconn)
static void
nmt_connect_device_free (NmtConnectDevice *nmtdev)
{
g_clear_pointer (&nmtdev->name, g_free);
nm_clear_g_free (&nmtdev->name);
g_clear_object (&nmtdev->device);
g_slist_free_full (nmtdev->conns, (GDestroyNotify) nmt_connect_connection_free);

View file

@ -299,7 +299,7 @@ nmt_device_entry_set_mac_address (NmtDeviceEntry *deventry,
priv->mac_address = g_strdup (mac_address);
changed = TRUE;
} else if (!mac_address && priv->mac_address) {
g_clear_pointer (&priv->mac_address, g_free);
nm_clear_g_free (&priv->mac_address);
changed = TRUE;
} else if ( mac_address && priv->mac_address
&& !nm_utils_hwaddr_matches (mac_address, -1, priv->mac_address, -1)) {

View file

@ -77,7 +77,7 @@ nmt_editor_grid_finalize (GObject *object)
NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE (object);
g_array_unref (priv->rows);
g_clear_pointer (&priv->row_heights, g_free);
nm_clear_g_free (&priv->row_heights);
G_OBJECT_CLASS (nmt_editor_grid_parent_class)->finalize (object);
}

View file

@ -50,7 +50,7 @@ edit_clicked (NmtNewtButton *button,
new_config = nmt_newt_edit_string (config);
if (new_config && !*new_config)
g_clear_pointer (&new_config, g_free);
nm_clear_g_free (&new_config);
g_object_set (G_OBJECT (priv->s_port),
NM_SETTING_TEAM_PORT_CONFIG, new_config,
NULL);

View file

@ -103,7 +103,7 @@ edit_clicked (NmtNewtButton *button,
new_config = nmt_newt_edit_string (config);
if (new_config && !*new_config)
g_clear_pointer (&new_config, g_free);
nm_clear_g_free (&new_config);
g_object_set (G_OBJECT (priv->s_team),
NM_SETTING_TEAM_CONFIG, new_config,
NULL);

View file

@ -307,12 +307,12 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_P_KEY:
priv->p_key = g_value_get_int (value);
g_clear_pointer (&priv->virtual_iface_name, g_free);
nm_clear_g_free (&priv->virtual_iface_name);
break;
case PROP_PARENT:
g_free (priv->parent);
priv->parent = g_value_dup_string (value);
g_clear_pointer (&priv->virtual_iface_name, g_free);
nm_clear_g_free (&priv->virtual_iface_name);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View file

@ -234,7 +234,7 @@ vf_add_vlan (NMSriovVF *vf,
vf->vlans = _vf_vlan_create_hash ();
g_hash_table_add (vf->vlans, vlan);
g_clear_pointer (&vf->vlan_ids, g_free);
nm_clear_g_free (&vf->vlan_ids);
}
/**
@ -530,7 +530,7 @@ nm_sriov_vf_remove_vlan (NMSriovVF *vf, guint vlan_id)
|| !g_hash_table_remove (vf->vlans, &vlan_id))
return FALSE;
g_clear_pointer (&vf->vlan_ids, g_free);
nm_clear_g_free (&vf->vlan_ids);
return TRUE;
}

View file

@ -1155,7 +1155,7 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
priv->aliases = g_key_file_get_string_list (priv->keyfile, NM_VPN_PLUGIN_INFO_KF_GROUP_CONNECTION, "aliases", NULL, NULL);
if (priv->aliases && !priv->aliases[0])
g_clear_pointer (&priv->aliases, g_free);
nm_clear_g_free (&priv->aliases);
priv->keys = g_hash_table_new_full (_nm_utils_strstrdictkey_hash,
_nm_utils_strstrdictkey_equal,

View file

@ -3550,7 +3550,7 @@ test_setting_compare_wired_cloned_mac_address (void)
g_assert_cmpstr ("stable", ==, nm_setting_wired_get_cloned_mac_address ((NMSettingWired *) old));
g_object_get (old, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, &str1, NULL);
g_assert_cmpstr ("stable", ==, str1);
g_clear_pointer (&str1, g_free);
nm_clear_g_free (&str1);
new = nm_setting_duplicate (old);
g_object_set (new, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "11:22:33:44:55:66", NULL);
@ -3558,7 +3558,7 @@ test_setting_compare_wired_cloned_mac_address (void)
g_assert_cmpstr ("11:22:33:44:55:66", ==, nm_setting_wired_get_cloned_mac_address ((NMSettingWired *) new));
g_object_get (new, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, &str1, NULL);
g_assert_cmpstr ("11:22:33:44:55:66", ==, str1);
g_clear_pointer (&str1, g_free);
nm_clear_g_free (&str1);
success = nm_setting_compare (old, new, NM_SETTING_COMPARE_FLAG_EXACT);
g_assert (!success);
@ -3570,7 +3570,7 @@ test_setting_compare_wired_cloned_mac_address (void)
g_assert_cmpstr ("stable-bia", ==, nm_setting_wired_get_cloned_mac_address ((NMSettingWired *) new));
g_object_get (new, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, &str1, NULL);
g_assert_cmpstr ("stable-bia", ==, str1);
g_clear_pointer (&str1, g_free);
nm_clear_g_free (&str1);
success = nm_setting_compare (old, new, NM_SETTING_COMPARE_FLAG_EXACT);
g_assert (!success);
@ -3592,7 +3592,7 @@ test_setting_compare_wireless_cloned_mac_address (void)
g_assert_cmpstr ("stable", ==, nm_setting_wireless_get_cloned_mac_address ((NMSettingWireless *) old));
g_object_get (old, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, &str1, NULL);
g_assert_cmpstr ("stable", ==, str1);
g_clear_pointer (&str1, g_free);
nm_clear_g_free (&str1);
new = nm_setting_duplicate (old);
g_object_set (new, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, "11:22:33:44:55:66", NULL);
@ -3600,7 +3600,7 @@ test_setting_compare_wireless_cloned_mac_address (void)
g_assert_cmpstr ("11:22:33:44:55:66", ==, nm_setting_wireless_get_cloned_mac_address ((NMSettingWireless *) new));
g_object_get (new, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, &str1, NULL);
g_assert_cmpstr ("11:22:33:44:55:66", ==, str1);
g_clear_pointer (&str1, g_free);
nm_clear_g_free (&str1);
success = nm_setting_compare (old, new, NM_SETTING_COMPARE_FLAG_EXACT);
g_assert (!success);

View file

@ -1852,7 +1852,7 @@ test_bridge_vlans (void)
str = nm_bridge_vlan_to_str (v1, &error);
nmtst_assert_success (str, error);
g_assert_cmpstr (str, ==, "10 pvid");
g_clear_pointer (&str, g_free);
nm_clear_g_free (&str);
v2 = nm_bridge_vlan_from_str (" 10 pvid ", &error);
nmtst_assert_success (v2, error);

View file

@ -1795,7 +1795,7 @@ ensure_description (NMDevice *device)
g_object_get (device, "name", &priv->description, NULL);
if (priv->description && priv->description[0])
return;
g_clear_pointer (&priv->description, g_free);
nm_clear_g_free (&priv->description);
}
if (!priv->short_vendor) {

View file

@ -966,10 +966,10 @@ mac_address_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *key
buf_len = i + 1;
buf_arr = g_new (guint8, buf_len);
if (!nm_utils_hwaddr_aton (tmp_string, buf_arr, buf_len))
g_clear_pointer (&buf_arr, g_free);
nm_clear_g_free (&buf_arr);
}
}
g_clear_pointer (&tmp_string, g_free);
nm_clear_g_free (&tmp_string);
if (!buf_arr) {
gs_free int *tmp_list = NULL;
@ -2407,7 +2407,7 @@ cert_writer_default (NMConnection *connection,
* for example if the path is longer then 500 chars. */
tmp = nm_keyfile_detect_unqualified_path_scheme (base_dir, path, -1, FALSE, NULL);
if (tmp)
g_clear_pointer (&tmp, g_free);
nm_clear_g_free (&tmp);
else {
tmp = g_strconcat (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH, path, NULL);
path = tmp;

View file

@ -64,7 +64,7 @@ realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
NM_DEVICE_CLASS (nm_device_generic_parent_class)->realize_start_notify (device, plink);
g_clear_pointer (&priv->type_description, g_free);
nm_clear_g_free (&priv->type_description);
ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self));
if (ifindex > 0)
priv->type_description = g_strdup (nm_platform_link_get_type_name (nm_device_get_platform (device), ifindex));
@ -181,7 +181,7 @@ dispose (GObject *object)
NMDeviceGeneric *self = NM_DEVICE_GENERIC (object);
NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self);
g_clear_pointer (&priv->type_description, g_free);
nm_clear_g_free (&priv->type_description);
G_OBJECT_CLASS (nm_device_generic_parent_class)->dispose (object);
}

View file

@ -175,19 +175,19 @@ update_properties_from_ifindex (NMDevice *device, int ifindex)
clear:
nm_device_parent_set_ifindex (device, 0);
if (priv->local) {
g_clear_pointer (&priv->local, g_free);
nm_clear_g_free (&priv->local);
_notify (self, PROP_LOCAL);
}
if (priv->remote) {
g_clear_pointer (&priv->remote, g_free);
nm_clear_g_free (&priv->remote);
_notify (self, PROP_REMOTE);
}
if (priv->input_key) {
g_clear_pointer (&priv->input_key, g_free);
nm_clear_g_free (&priv->input_key);
_notify (self, PROP_INPUT_KEY);
}
if (priv->output_key) {
g_clear_pointer (&priv->output_key, g_free);
nm_clear_g_free (&priv->output_key);
_notify (self, PROP_OUTPUT_KEY);
}
@ -223,7 +223,7 @@ clear:
g_free (key);
} else {
if (priv->input_key) {
g_clear_pointer (&priv->input_key, g_free);
nm_clear_g_free (&priv->input_key);
_notify (self, PROP_INPUT_KEY);
}
}
@ -238,7 +238,7 @@ clear:
g_free (key);
} else {
if (priv->output_key) {
g_clear_pointer (&priv->output_key, g_free);
nm_clear_g_free (&priv->output_key);
_notify (self, PROP_OUTPUT_KEY);
}
}
@ -314,7 +314,7 @@ clear:
g_free (key);
} else {
if (priv->input_key) {
g_clear_pointer (&priv->input_key, g_free);
nm_clear_g_free (&priv->input_key);
_notify (self, PROP_INPUT_KEY);
}
}
@ -329,7 +329,7 @@ clear:
g_free (key);
} else {
if (priv->output_key) {
g_clear_pointer (&priv->output_key, g_free);
nm_clear_g_free (&priv->output_key);
_notify (self, PROP_OUTPUT_KEY);
}
}
@ -1022,10 +1022,10 @@ dispose (GObject *object)
NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL (object);
NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (self);
g_clear_pointer (&priv->local, g_free);
g_clear_pointer (&priv->remote, g_free);
g_clear_pointer (&priv->input_key, g_free);
g_clear_pointer (&priv->output_key, g_free);
nm_clear_g_free (&priv->local);
nm_clear_g_free (&priv->remote);
nm_clear_g_free (&priv->input_key);
nm_clear_g_free (&priv->output_key);
G_OBJECT_CLASS (nm_device_ip_tunnel_parent_class)->dispose (object);
}

View file

@ -4855,19 +4855,19 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error)
_set_mtu (self, 0);
if (priv->driver_version) {
g_clear_pointer (&priv->driver_version, g_free);
nm_clear_g_free (&priv->driver_version);
_notify (self, PROP_DRIVER_VERSION);
}
if (priv->firmware_version) {
g_clear_pointer (&priv->firmware_version, g_free);
nm_clear_g_free (&priv->firmware_version);
_notify (self, PROP_FIRMWARE_VERSION);
}
if (priv->udi) {
g_clear_pointer (&priv->udi, g_free);
nm_clear_g_free (&priv->udi);
_notify (self, PROP_UDI);
}
if (priv->physical_port_id) {
g_clear_pointer (&priv->physical_port_id, g_free);
nm_clear_g_free (&priv->physical_port_id);
_notify (self, PROP_PHYSICAL_PORT_ID);
}
@ -4880,7 +4880,7 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error)
priv->hw_addr_type = HW_ADDR_TYPE_UNSET;
if (nm_clear_g_free (&priv->hw_addr_perm))
_notify (self, PROP_PERM_HW_ADDRESS);
g_clear_pointer (&priv->hw_addr_initial, g_free);
nm_clear_g_free (&priv->hw_addr_initial);
priv->capabilities = NM_DEVICE_CAP_NM_SUPPORTED;
if (NM_DEVICE_GET_CLASS (self)->get_generic_capabilities)
@ -7604,8 +7604,8 @@ dhcp4_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release)
priv->dhcp_data_4.was_active = FALSE;
nm_clear_g_source (&priv->dhcp_data_4.grace_id);
priv->dhcp_data_4.grace_pending = FALSE;
g_clear_pointer (&priv->dhcp4.pac_url, g_free);
g_clear_pointer (&priv->dhcp4.root_path, g_free);
nm_clear_g_free (&priv->dhcp4.pac_url);
nm_clear_g_free (&priv->dhcp4.root_path);
if (priv->dhcp_data_4.client) {
/* Stop any ongoing DHCP transaction on this device */
@ -8667,7 +8667,7 @@ dhcp6_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release)
priv->dhcp_data_6.was_active = FALSE;
priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_NONE;
applied_config_clear (&priv->dhcp6.ip6_config);
g_clear_pointer (&priv->dhcp6.event_id, g_free);
nm_clear_g_free (&priv->dhcp6.event_id);
nm_clear_g_source (&priv->dhcp_data_6.grace_id);
priv->dhcp_data_6.grace_pending = FALSE;
@ -8811,7 +8811,7 @@ dhcp6_state_changed (NMDhcpClient *client,
nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, ip6_config, &a)
applied_config_add_address (&priv->dhcp6.ip6_config, NM_PLATFORM_IP_ADDRESS_CAST (a));
} else {
g_clear_pointer (&priv->dhcp6.event_id, g_free);
nm_clear_g_free (&priv->dhcp6.event_id);
if (ip6_config) {
applied_config_init (&priv->dhcp6.ip6_config, ip6_config);
priv->dhcp6.event_id = g_strdup (event_id);
@ -9295,7 +9295,7 @@ dhcp6_start (NMDevice *self, gboolean wait_for_ll)
nm_assert (!applied_config_get_current (&priv->dhcp6.ip6_config));
applied_config_clear (&priv->dhcp6.ip6_config);
g_clear_pointer (&priv->dhcp6.event_id, g_free);
nm_clear_g_free (&priv->dhcp6.event_id);
connection = nm_device_get_applied_connection (self);
g_return_val_if_fail (connection, FALSE);
@ -13157,8 +13157,8 @@ ip_check_gw_ping_cleanup (NMDevice *self)
priv->gw_ping.pid = 0;
}
g_clear_pointer (&priv->gw_ping.binary, g_free);
g_clear_pointer (&priv->gw_ping.address, g_free);
nm_clear_g_free (&priv->gw_ping.binary);
nm_clear_g_free (&priv->gw_ping.address);
}
static gboolean
@ -17352,7 +17352,7 @@ constructor (GType type,
gsize l;
if (!_nm_utils_hwaddr_aton (priv->hw_addr_perm, buf, sizeof (buf), &l)) {
g_clear_pointer (&priv->hw_addr_perm, g_free);
nm_clear_g_free (&priv->hw_addr_perm);
g_return_val_if_reached (object);
}
@ -17518,7 +17518,7 @@ finalize (GObject *object)
g_free (priv->hw_addr_initial);
g_slist_free (priv->pending_actions);
g_slist_free_full (priv->dad6_failed_addrs, (GDestroyNotify) nmp_object_unref);
g_clear_pointer (&priv->physical_port_id, g_free);
nm_clear_g_free (&priv->physical_port_id);
g_free (priv->udi);
g_free (priv->iface);
g_free (priv->ip_iface);

View file

@ -1386,7 +1386,7 @@ ovsdb_disconnect (NMOvsdb *self, gboolean is_disposing)
g_string_truncate (priv->output, 0);
g_clear_object (&priv->client);
g_clear_object (&priv->conn);
g_clear_pointer (&priv->db_uuid, g_free);
nm_clear_g_free (&priv->db_uuid);
nm_clear_g_cancellable (&priv->cancellable);
}
@ -1549,7 +1549,7 @@ _clear_call (gpointer data)
g_clear_object (&call->interface_device);
break;
case OVSDB_DEL_INTERFACE:
g_clear_pointer (&call->ifname, g_free);
nm_clear_g_free (&call->ifname);
break;
}
}

View file

@ -932,7 +932,7 @@ dispose (GObject *object)
}
teamd_cleanup (self, TRUE);
g_clear_pointer (&priv->config, g_free);
nm_clear_g_free (&priv->config);
G_OBJECT_CLASS (nm_device_team_parent_class)->dispose (object);
}

View file

@ -842,9 +842,9 @@ dispose (GObject *object)
nm_clear_pointer (&priv->modem, nm_modem_unclaim);
}
g_clear_pointer (&priv->device_id, g_free);
g_clear_pointer (&priv->operator_code, g_free);
g_clear_pointer (&priv->apn, g_free);
nm_clear_g_free (&priv->device_id);
nm_clear_g_free (&priv->operator_code);
nm_clear_g_free (&priv->apn);
G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object);
}

View file

@ -449,7 +449,7 @@ handle_sim_iface (NMModemOfono *self, gboolean found)
g_signal_handlers_disconnect_by_data (priv->sim_proxy, self);
g_clear_object (&priv->sim_proxy);
}
g_clear_pointer (&priv->imsi, g_free);
nm_clear_g_free (&priv->imsi);
update_modem_state (self);
} else if (found && (!priv->sim_proxy && !priv->sim_proxy_cancellable)) {
_LOGI ("found new SimManager interface");

View file

@ -1747,7 +1747,7 @@ set_property (GObject *object, guint prop_id,
priv->ip_types = g_value_get_uint (value);
break;
case PROP_SIM_OPERATOR_ID:
g_clear_pointer (&priv->sim_operator_id, g_free);
nm_clear_g_free (&priv->sim_operator_id);
s = g_value_get_string (value);
if (s && s[0])
priv->sim_operator_id = g_strdup (s);

View file

@ -118,11 +118,11 @@ parser_gsm_start (ParseContext *parse_context,
}
} else if (strcmp (name, "apn") == 0) {
parse_context->found_internet_apn = FALSE;
g_clear_pointer (&parse_context->apn, g_free);
g_clear_pointer (&parse_context->username, g_free);
g_clear_pointer (&parse_context->password, g_free);
g_clear_pointer (&parse_context->gateway, g_free);
g_clear_pointer (&parse_context->auth_method, g_free);
nm_clear_g_free (&parse_context->apn);
nm_clear_g_free (&parse_context->username);
nm_clear_g_free (&parse_context->password);
nm_clear_g_free (&parse_context->gateway);
nm_clear_g_free (&parse_context->auth_method);
g_slist_free_full (parse_context->dns, g_free);
parse_context->dns = NULL;
@ -155,7 +155,7 @@ parser_gsm_apn_start (ParseContext *parse_context,
} else if (strcmp (name, "authentication") == 0) {
for (i = 0; attribute_names && attribute_names[i]; i++) {
if (strcmp (attribute_names[i], "method") == 0) {
g_clear_pointer (&parse_context->auth_method, g_free);
nm_clear_g_free (&parse_context->auth_method);
parse_context->auth_method = g_strstrip (g_strdup (attribute_values[i]));
break;
}
@ -173,7 +173,7 @@ parser_start_element (GMarkupParseContext *context,
{
ParseContext *parse_context = user_data;
g_clear_pointer (&parse_context->text_buffer, g_free);
nm_clear_g_free (&parse_context->text_buffer);
switch (parse_context->state) {
case PARSER_TOPLEVEL:
@ -205,7 +205,7 @@ parser_country_end (ParseContext *parse_context,
const char *name)
{
if (strcmp (name, "country") == 0) {
g_clear_pointer (&parse_context->text_buffer, g_free);
nm_clear_g_free (&parse_context->text_buffer);
parse_context->state = PARSER_TOPLEVEL;
}
}
@ -215,7 +215,7 @@ parser_provider_end (ParseContext *parse_context,
const char *name)
{
if (strcmp (name, "provider") == 0) {
g_clear_pointer (&parse_context->text_buffer, g_free);
nm_clear_g_free (&parse_context->text_buffer);
parse_context->state = PARSER_COUNTRY;
}
}
@ -225,7 +225,7 @@ parser_gsm_end (ParseContext *parse_context,
const char *name)
{
if (strcmp (name, "gsm") == 0) {
g_clear_pointer (&parse_context->text_buffer, g_free);
nm_clear_g_free (&parse_context->text_buffer);
parse_context->state = PARSER_PROVIDER;
}
}
@ -235,19 +235,19 @@ parser_gsm_apn_end (ParseContext *parse_context,
const char *name)
{
if (strcmp (name, "username") == 0) {
g_clear_pointer (&parse_context->username, g_free);
nm_clear_g_free (&parse_context->username);
parse_context->username = g_steal_pointer (&parse_context->text_buffer);
} else if (strcmp (name, "password") == 0) {
g_clear_pointer (&parse_context->password, g_free);
nm_clear_g_free (&parse_context->password);
parse_context->password = g_steal_pointer (&parse_context->text_buffer);
} else if (strcmp (name, "dns") == 0) {
parse_context->dns = g_slist_prepend (parse_context->dns,
g_steal_pointer (&parse_context->text_buffer));
} else if (strcmp (name, "gateway") == 0) {
g_clear_pointer (&parse_context->gateway, g_free);
nm_clear_g_free (&parse_context->gateway);
parse_context->gateway = g_steal_pointer (&parse_context->text_buffer);
} else if (strcmp (name, "apn") == 0) {
g_clear_pointer (&parse_context->text_buffer, g_free);
nm_clear_g_free (&parse_context->text_buffer);
if (parse_context->mccmnc_matched && parse_context->found_internet_apn)
parse_context->state = PARSER_DONE;
@ -262,7 +262,7 @@ parser_cdma_end (ParseContext *parse_context,
const char *name)
{
if (strcmp (name, "cdma") == 0) {
g_clear_pointer (&parse_context->text_buffer, g_free);
nm_clear_g_free (&parse_context->text_buffer);
parse_context->state = PARSER_PROVIDER;
}
}

View file

@ -1099,9 +1099,9 @@ dispose (GObject *object)
watch_cleanup (self);
timeout_cleanup (self);
g_clear_pointer (&priv->iface, g_free);
g_clear_pointer (&priv->hostname, g_free);
g_clear_pointer (&priv->uuid, g_free);
nm_clear_g_free (&priv->iface);
nm_clear_g_free (&priv->hostname);
nm_clear_g_free (&priv->uuid);
g_clear_pointer (&priv->client_id, g_bytes_unref);
g_clear_pointer (&priv->hwaddr, g_bytes_unref);
g_clear_pointer (&priv->bcast_hwaddr, g_bytes_unref);

View file

@ -515,7 +515,7 @@ nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, const char *hostna
{
NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (manager);
g_clear_pointer (&priv->default_hostname, g_free);
nm_clear_g_free (&priv->default_hostname);
/* Never send 'localhost'-type names to the DHCP server */
if (!nm_utils_is_specific_hostname (hostname))

View file

@ -1058,7 +1058,7 @@ dispose (GObject *object)
{
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (object);
g_clear_pointer (&priv->lease_file, g_free);
nm_clear_g_free (&priv->lease_file);
if (priv->client4) {
sd_dhcp_client_stop (priv->client4);

View file

@ -1367,7 +1367,7 @@ clear_domain_lists (NMDnsManager *self)
head = _ip_config_lst_head (self);
c_list_for_each_entry (ip_data, head, ip_config_lst) {
g_clear_pointer (&ip_data->domains.search, g_free);
nm_clear_g_free (&ip_data->domains.search);
g_clear_pointer (&ip_data->domains.reverse, g_strfreev);
}
}

View file

@ -109,7 +109,7 @@ main (int argc, char *argv[])
if (!sysfs_dir)
sysfs_dir = g_strdup (DEFAULT_SYSFS_DIR);
if (dump_to_stdout)
g_clear_pointer (&connections_dir, g_free);
nm_clear_g_free (&connections_dir);
if (connections_dir && g_mkdir_with_parents (connections_dir, 0755) != 0) {
errsv = errno;

View file

@ -157,7 +157,7 @@ nmi_dt_reader_parse (const char *sysfs_dir)
local_hwaddr = dt_get_hwaddr_property (base, bootpath, "local-mac-address");
hwaddr = dt_get_hwaddr_property (base, bootpath, "mac-address");
if (g_strcmp0 (local_hwaddr, hwaddr) == 0)
g_clear_pointer (&local_hwaddr, g_free);
nm_clear_g_free (&local_hwaddr);
tokens = g_strsplit (path, ",", 0);

View file

@ -185,7 +185,7 @@ nm_main_utils_ensure_not_running_pidfile (const char *pidfile)
if (pid <= 0 || pid > 65536 || errno)
return;
g_clear_pointer (&contents, g_free);
nm_clear_g_free (&contents);
proc_cmdline = g_strdup_printf ("/proc/%ld/cmdline", pid);
if (!g_file_get_contents (proc_cmdline, &contents, &len, NULL))
return;

View file

@ -676,7 +676,7 @@ nm_ndisc_add_dns_domain (NMNDisc *ndisc, const NMNDiscDNSDomain *new)
_different_message = g_strcmp0 (priv->last_error, error->message) != 0; \
_NMLOG (_different_message ? LOGL_WARN : LOGL_DEBUG, __VA_ARGS__); \
if (_different_message) { \
g_clear_pointer (&priv->last_error, g_free); \
nm_clear_g_free (&priv->last_error); \
priv->last_error = g_strdup (error->message); \
} \
} G_STMT_END
@ -697,7 +697,7 @@ send_rs_timeout (NMNDisc *ndisc)
if (klass->send_rs (ndisc, &error)) {
_LOGD ("router solicitation sent");
priv->solicitations_left--;
g_clear_pointer (&priv->last_error, g_free);
nm_clear_g_free (&priv->last_error);
} else {
_MAYBE_WARN ("failure sending router solicitation: %s", error->message);
g_clear_error (&error);
@ -751,7 +751,7 @@ announce_router (NMNDisc *ndisc)
priv->last_ra = nm_utils_get_monotonic_timestamp_sec ();
if (klass->send_ra (ndisc, &error)) {
_LOGD ("router advertisement sent");
g_clear_pointer (&priv->last_error, g_free);
nm_clear_g_free (&priv->last_error);
} else {
_MAYBE_WARN ("failure sending router advertisement: %s", error->message);
g_clear_error (&error);
@ -1256,7 +1256,7 @@ nm_ndisc_ra_received (NMNDisc *ndisc, gint32 now, NMNDiscConfigMap changed)
nm_clear_g_source (&priv->ra_timeout_id);
nm_clear_g_source (&priv->send_rs_id);
g_clear_pointer (&priv->last_error, g_free);
nm_clear_g_free (&priv->last_error);
check_timestamps (ndisc, now, changed);
}
@ -1265,7 +1265,7 @@ nm_ndisc_rs_received (NMNDisc *ndisc)
{
NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc);
g_clear_pointer (&priv->last_error, g_free);
nm_clear_g_free (&priv->last_error);
announce_router_solicited (ndisc);
}
@ -1384,7 +1384,7 @@ dispose (GObject *object)
nm_clear_g_source (&priv->ra_timeout_id);
nm_clear_g_source (&priv->send_rs_id);
nm_clear_g_source (&priv->send_ra_id);
g_clear_pointer (&priv->last_error, g_free);
nm_clear_g_free (&priv->last_error);
nm_clear_g_source (&priv->timeout_id);

View file

@ -281,7 +281,7 @@ nm_active_connection_set_state (NMActiveConnection *self,
priv->pending_activation_id)
{
nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE);
g_clear_pointer (&priv->pending_activation_id, g_free);
nm_clear_g_free (&priv->pending_activation_id);
}
}
@ -1234,7 +1234,7 @@ _device_cleanup (NMActiveConnection *self)
if (priv->pending_activation_id) {
nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE);
g_clear_pointer (&priv->pending_activation_id, g_free);
nm_clear_g_free (&priv->pending_activation_id);
}
g_clear_object (&priv->device);

View file

@ -481,17 +481,17 @@ nm_config_set_no_auto_default_for_device (NMConfig *self, NMDevice *device)
static void
_nm_config_cmd_line_options_clear (NMConfigCmdLineOptions *cli)
{
g_clear_pointer (&cli->config_main_file, g_free);
g_clear_pointer (&cli->config_dir, g_free);
g_clear_pointer (&cli->system_config_dir, g_free);
g_clear_pointer (&cli->no_auto_default_file, g_free);
g_clear_pointer (&cli->intern_config_file, g_free);
g_clear_pointer (&cli->state_file, g_free);
g_clear_pointer (&cli->plugins, g_free);
nm_clear_g_free (&cli->config_main_file);
nm_clear_g_free (&cli->config_dir);
nm_clear_g_free (&cli->system_config_dir);
nm_clear_g_free (&cli->no_auto_default_file);
nm_clear_g_free (&cli->intern_config_file);
nm_clear_g_free (&cli->state_file);
nm_clear_g_free (&cli->plugins);
cli->configure_and_quit = NM_CONFIG_CONFIGURE_AND_QUIT_DISABLED;
cli->is_debug = FALSE;
g_clear_pointer (&cli->connectivity_uri, g_free);
g_clear_pointer (&cli->connectivity_response, g_free);
nm_clear_g_free (&cli->connectivity_uri);
nm_clear_g_free (&cli->connectivity_response);
cli->connectivity_interval = -1;
cli->first_start = FALSE;
}

View file

@ -138,7 +138,7 @@ nm_dbus_object_unexport (NMDBusObject *self)
_nm_dbus_manager_obj_unexport (self);
g_clear_pointer (&self->internal.path, g_free);
nm_clear_g_free (&self->internal.path);
self->internal.export_version_id = 0;
self->internal.is_unexporting = FALSE;

View file

@ -448,7 +448,7 @@ main (int argc, char *argv[])
fprintf (stderr,
_("Ignoring unrecognized log domain(s) '%s' passed on command line.\n"),
bad_domains);
g_clear_pointer (&bad_domains, g_free);
nm_clear_g_free (&bad_domains);
}
if (global_opt.become_daemon && !global_opt.debug) {

View file

@ -390,7 +390,7 @@ nm_logging_setup (const char *level,
}
}
g_clear_pointer (&gl_main.logging_domains_to_string, g_free);
nm_clear_g_free (&gl_main.logging_domains_to_string);
had_platform_debug = _nm_logging_enabled_lockfree (LOGL_DEBUG, LOGD_PLATFORM);

View file

@ -2706,9 +2706,9 @@ dispose (GObject *object)
nm_clear_g_source (&priv->reset_retries_id);
nm_clear_g_source (&priv->schedule_activate_all_id);
g_clear_pointer (&priv->orig_hostname, g_free);
g_clear_pointer (&priv->cur_hostname, g_free);
g_clear_pointer (&priv->last_hostname, g_free);
nm_clear_g_free (&priv->orig_hostname);
nm_clear_g_free (&priv->cur_hostname);
nm_clear_g_free (&priv->last_hostname);
if (priv->hostname_manager) {
g_signal_handlers_disconnect_by_data (priv->hostname_manager, priv);

View file

@ -65,7 +65,7 @@ nm_proxy_config_merge_setting (NMProxyConfig *config, NMSettingProxy *setting)
priv = NM_PROXY_CONFIG_GET_PRIVATE (config);
g_clear_pointer (&priv->pac_script, g_free);
nm_clear_g_free (&priv->pac_script);
method = nm_setting_proxy_get_method (setting);
switch (method) {

View file

@ -420,7 +420,7 @@ link_delete (NMPlatform *platform, int ifindex)
return FALSE;
obj_old = g_steal_pointer (&device->obj);
g_clear_pointer (&device->udi, g_free);
nm_clear_g_free (&device->udi);
cache_op = nmp_cache_remove (nm_platform_get_cache (platform),
obj_old,

View file

@ -525,11 +525,11 @@ _vlan_xgress_qos_mappings_cpy (guint *dst_n_map,
const NMVlanQosMapping *src_map)
{
if (src_n_map == 0) {
g_clear_pointer (dst_map, g_free);
nm_clear_g_free (dst_map);
*dst_n_map = 0;
} else if ( src_n_map != *dst_n_map
|| _vlan_xgress_qos_mappings_cmp (src_n_map, *dst_map, src_map) != 0) {
g_clear_pointer (dst_map, g_free);
nm_clear_g_free (dst_map);
*dst_n_map = src_n_map;
if (src_n_map > 0)
*dst_map = nm_memdup (src_map, sizeof (*src_map) * src_n_map);

View file

@ -152,7 +152,7 @@ dispose (GObject *object)
{
NMWifiUtilsNl80211 *self = NM_WIFI_UTILS_NL80211 (object);
g_clear_pointer (&self->freqs, g_free);
nm_clear_g_free (&self->freqs);
}
struct nl80211_iface_info {

View file

@ -4390,7 +4390,7 @@ parse_ethtool_option (const char *value,
i++;
if (nm_utils_hwaddr_valid (opt_val, ETH_ALEN)) {
g_clear_pointer (out_password, g_free);
nm_clear_g_free (out_password);
*out_password = g_strdup (opt_val);
} else
PARSE_WARNING ("Wake-on-LAN password '%s' is invalid", opt_val);

View file

@ -60,7 +60,7 @@ cert_writer (NMConnection *connection,
* that would be interpreted as legacy binary format by reader. */
tmp = nm_keyfile_detect_unqualified_path_scheme (info->keyfile_dir, p, -1, FALSE, NULL);
if (tmp) {
g_clear_pointer (&tmp, g_free);
nm_clear_g_free (&tmp);
accepted_path = p;
}
}
@ -71,7 +71,7 @@ cert_writer (NMConnection *connection,
* Otherwise, add a file:// prefix */
tmp = nm_keyfile_detect_unqualified_path_scheme (info->keyfile_dir, path, -1, FALSE, NULL);
if (tmp) {
g_clear_pointer (&tmp, g_free);
nm_clear_g_free (&tmp);
accepted_path = path;
}
}

View file

@ -978,7 +978,7 @@ test_config_enable (void)
guint match_nm_version = _nm_config_match_nm_version;
char *match_env = g_strdup (_nm_config_match_env);
g_clear_pointer (&_nm_config_match_env, g_free);
nm_clear_g_free (&_nm_config_match_env);
_nm_config_match_env = g_strdup ("something-else");
_nm_config_match_nm_version = nm_encode_version (1, 3, 4);
@ -992,14 +992,14 @@ test_config_enable (void)
g_clear_object (&config);
_nm_config_match_nm_version = nm_encode_version (1, 5, 3);
g_clear_pointer (&_nm_config_match_env, g_free);
nm_clear_g_free (&_nm_config_match_env);
_nm_config_match_env = g_strdup ("test-match-env-1");
config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL);
assert_config_value (nm_config_get_data_orig (config), "test-group-config-enable-1", "key1", "enabled");
g_clear_object (&config);
_nm_config_match_nm_version = match_nm_version;
g_clear_pointer (&_nm_config_match_env, g_free);
nm_clear_g_free (&_nm_config_match_env);
_nm_config_match_env = match_env;
}

View file

@ -1303,7 +1303,7 @@ process_generic_config (NMVpnConnection *self, GVariant *dict)
priv->service_can_persist = TRUE;
}
g_clear_pointer (&priv->ip_iface, g_free);
nm_clear_g_free (&priv->ip_iface);
priv->ip_ifindex = 0;
if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_TUNDEV, "&s", &str)) {
@ -1321,14 +1321,14 @@ process_generic_config (NMVpnConnection *self, GVariant *dict)
}
if (priv->ip_ifindex <= 0) {
_LOGE ("failed to look up VPN interface index for \"%s\"", priv->ip_iface);
g_clear_pointer (&priv->ip_iface, g_free);
nm_clear_g_free (&priv->ip_iface);
priv->ip_ifindex = 0;
nm_vpn_connection_config_maybe_complete (self, FALSE);
return FALSE;
}
}
g_clear_pointer (&priv->banner, g_free);
nm_clear_g_free (&priv->banner);
if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_BANNER, "&s", &str)) {
priv->banner = g_strdup (str);
_notify (self, PROP_BANNER);
@ -1350,7 +1350,7 @@ process_generic_config (NMVpnConnection *self, GVariant *dict)
/* External world-visible address of the VPN server */
priv->ip4_external_gw = 0;
g_clear_pointer (&priv->ip6_external_gw, g_free);
nm_clear_g_free (&priv->ip6_external_gw);
if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, "u", &u32)) {
priv->ip4_external_gw = u32;
@ -1702,7 +1702,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
address.plen = 128;
/* Internal address of the VPN subnet's gateway */
g_clear_pointer (&priv->ip6_internal_gw, g_free);
nm_clear_g_free (&priv->ip6_internal_gw);
if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_INT_GATEWAY, "@ay", &v)) {
priv->ip6_internal_gw = ip6_addr_dup_from_variant (v);
g_variant_unref (v);