mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-02 18:10:26 +01:00
core: re-add assertions to NMIP[4|6]Config objects
They make any problems apparent at the source instead of later where the problem must be more intesively debugged.
This commit is contained in:
parent
17e91fd46a
commit
0f592b40c8
2 changed files with 28 additions and 2 deletions
|
|
@ -330,6 +330,8 @@ nm_ip4_config_add_address (NMIP4Config *config, const NMPlatformIP4Address *new)
|
|||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
|
||||
g_return_if_fail (new != NULL);
|
||||
|
||||
for (i = 0; i < priv->addresses->len; i++ ) {
|
||||
NMPlatformIP4Address *item = &g_array_index (priv->addresses, NMPlatformIP4Address, i);
|
||||
|
||||
|
|
@ -386,6 +388,8 @@ nm_ip4_config_add_route (NMIP4Config *config, NMIP4Route *new)
|
|||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
GSList *iter;
|
||||
|
||||
g_return_if_fail (new != NULL);
|
||||
|
||||
for (iter = priv->routes; iter; iter = g_slist_next (iter)) {
|
||||
NMIP4Route *item = (NMIP4Route *) iter->data;
|
||||
|
||||
|
|
@ -402,6 +406,8 @@ nm_ip4_config_add_route (NMIP4Config *config, NMIP4Route *new)
|
|||
void
|
||||
nm_ip4_config_take_route (NMIP4Config *config, NMIP4Route *route)
|
||||
{
|
||||
g_return_if_fail (route != NULL);
|
||||
|
||||
nm_ip4_config_add_route (config, route);
|
||||
nm_ip4_route_unref (route);
|
||||
}
|
||||
|
|
@ -438,6 +444,8 @@ nm_ip4_config_add_nameserver (NMIP4Config *config, guint32 new)
|
|||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
|
||||
g_return_if_fail (new != 0);
|
||||
|
||||
for (i = 0; i < priv->nameservers->len; i++)
|
||||
if (new == g_array_index (priv->nameservers, guint32, i))
|
||||
return;
|
||||
|
|
@ -477,6 +485,9 @@ nm_ip4_config_add_domain (NMIP4Config *config, const char *domain)
|
|||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
|
||||
g_return_if_fail (domain != NULL);
|
||||
g_return_if_fail (domain[0] != '\0');
|
||||
|
||||
for (i = 0; i < priv->domains->len; i++)
|
||||
if (!g_strcmp0 (g_ptr_array_index (priv->domains, i), domain))
|
||||
return;
|
||||
|
|
@ -516,7 +527,8 @@ nm_ip4_config_add_search (NMIP4Config *config, const char *new)
|
|||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
|
||||
g_return_if_fail (new && strlen (new));
|
||||
g_return_if_fail (new != NULL);
|
||||
g_return_if_fail (new[0] != '\0');
|
||||
|
||||
for (i = 0; i < priv->searches->len; i++)
|
||||
if (!g_strcmp0 (g_ptr_array_index (priv->searches, i), new))
|
||||
|
|
@ -649,6 +661,8 @@ nm_ip4_config_add_wins (NMIP4Config *config, guint32 wins)
|
|||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
|
||||
g_return_if_fail (wins != 0);
|
||||
|
||||
for (i = 0; i < priv->wins->len; i++)
|
||||
if (wins == g_array_index (priv->wins, guint32, i))
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -376,6 +376,8 @@ nm_ip6_config_add_address (NMIP6Config *config, const NMPlatformIP6Address *new)
|
|||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
|
||||
g_return_if_fail (new != NULL);
|
||||
|
||||
for (i = 0; i < priv->addresses->len; i++ ) {
|
||||
NMPlatformIP6Address *item = &g_array_index (priv->addresses, NMPlatformIP6Address, i);
|
||||
|
||||
|
|
@ -432,6 +434,8 @@ nm_ip6_config_add_route (NMIP6Config *config, NMIP6Route *new)
|
|||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
GSList *iter;
|
||||
|
||||
g_return_if_fail (new != NULL);
|
||||
|
||||
for (iter = priv->routes; iter; iter = g_slist_next (iter)) {
|
||||
NMIP6Route *item = (NMIP6Route *) iter->data;
|
||||
|
||||
|
|
@ -448,6 +452,8 @@ nm_ip6_config_add_route (NMIP6Config *config, NMIP6Route *new)
|
|||
void
|
||||
nm_ip6_config_take_route (NMIP6Config *config, NMIP6Route *route)
|
||||
{
|
||||
g_return_if_fail (route != NULL);
|
||||
|
||||
nm_ip6_config_add_route (config, route);
|
||||
nm_ip6_route_unref (route);
|
||||
}
|
||||
|
|
@ -484,6 +490,8 @@ nm_ip6_config_add_nameserver (NMIP6Config *config, const struct in6_addr *new)
|
|||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
|
||||
g_return_if_fail (new != NULL);
|
||||
|
||||
for (i = 0; i < priv->nameservers->len; i++)
|
||||
if (IN6_ARE_ADDR_EQUAL (new, &g_array_index (priv->nameservers, struct in6_addr, i)))
|
||||
return;
|
||||
|
|
@ -523,6 +531,9 @@ nm_ip6_config_add_domain (NMIP6Config *config, const char *domain)
|
|||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
|
||||
g_return_if_fail (domain != NULL);
|
||||
g_return_if_fail (domain[0] != '\0');
|
||||
|
||||
for (i = 0; i < priv->domains->len; i++)
|
||||
if (!g_strcmp0 (g_ptr_array_index (priv->domains, i), domain))
|
||||
return;
|
||||
|
|
@ -562,7 +573,8 @@ nm_ip6_config_add_search (NMIP6Config *config, const char *new)
|
|||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
int i;
|
||||
|
||||
g_return_if_fail (new && strlen (new));
|
||||
g_return_if_fail (new != NULL);
|
||||
g_return_if_fail (new[0] != '\0');
|
||||
|
||||
for (i = 0; i < priv->searches->len; i++)
|
||||
if (!g_strcmp0 (g_ptr_array_index (priv->searches, i), new))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue