summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-05-25 11:03:48 +0200
committerThomas Haller <thaller@redhat.com>2018-05-25 16:11:05 +0200
commitdc7e48b9fdc5a920a559f182a8d97654e31ff4a1 (patch)
tree4ceda30e70412d64893b71eefd915edc1f84b8a5
parent8eb4c78ce3679ba7fef2f85d4b18539a74609192 (diff)
downloadNetworkManager-dc7e48b9fdc5a920a559f182a8d97654e31ff4a1.tar.gz
dhcp: use cleanup attribute in nm_dhcp_client_handle_event()
and use NMIPConfig type.
-rw-r--r--src/dhcp/nm-dhcp-client.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c
index 7d42a786ec..f1a62f2474 100644
--- a/src/dhcp/nm-dhcp-client.c
+++ b/src/dhcp/nm-dhcp-client.c
@@ -770,8 +770,8 @@ nm_dhcp_client_handle_event (gpointer unused,
NMDhcpClientPrivate *priv;
guint32 old_state;
guint32 new_state;
- GHashTable *str_options = NULL;
- GObject *ip_config = NULL;
+ gs_unref_hashtable GHashTable *str_options = NULL;
+ gs_unref_object NMIPConfig *ip_config = NULL;
NMPlatformIP6Address prefix = { 0, };
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE);
@@ -815,24 +815,24 @@ nm_dhcp_client_handle_event (gpointer unused,
}
/* Create the IP config */
- g_warn_if_fail (g_hash_table_size (str_options));
- if (g_hash_table_size (str_options)) {
+ if (g_hash_table_size (str_options) > 0) {
if (priv->addr_family == AF_INET) {
- ip_config = (GObject *) nm_dhcp_utils_ip4_config_from_options (nm_dhcp_client_get_multi_idx (self),
- priv->ifindex,
- priv->iface,
- str_options,
- priv->route_table,
- priv->route_metric);
+ ip_config = NM_IP_CONFIG_CAST (nm_dhcp_utils_ip4_config_from_options (nm_dhcp_client_get_multi_idx (self),
+ priv->ifindex,
+ priv->iface,
+ str_options,
+ priv->route_table,
+ priv->route_metric));
} else {
prefix = nm_dhcp_utils_ip6_prefix_from_options (str_options);
- ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (nm_dhcp_client_get_multi_idx (self),
- priv->ifindex,
- priv->iface,
- str_options,
- priv->info_only);
+ ip_config = NM_IP_CONFIG_CAST (nm_dhcp_utils_ip6_config_from_options (nm_dhcp_client_get_multi_idx (self),
+ priv->ifindex,
+ priv->iface,
+ str_options,
+ priv->info_only));
}
- }
+ } else
+ g_warn_if_reached ();
}
if (!IN6_IS_ADDR_UNSPECIFIED (&prefix.address)) {
@@ -844,19 +844,16 @@ nm_dhcp_client_handle_event (gpointer unused,
&prefix);
} else {
/* Fail if no valid IP config was received */
- if (new_state == NM_DHCP_STATE_BOUND && ip_config == NULL) {
+ if ( new_state == NM_DHCP_STATE_BOUND
+ && !ip_config) {
_LOGW ("client bound but IP config not received");
new_state = NM_DHCP_STATE_FAIL;
g_clear_pointer (&str_options, g_hash_table_unref);
}
- nm_dhcp_client_set_state (self, new_state, ip_config, str_options);
+ nm_dhcp_client_set_state (self, new_state, G_OBJECT (ip_config), str_options);
}
- if (str_options)
- g_hash_table_destroy (str_options);
- g_clear_object (&ip_config);
-
return TRUE;
}