summaryrefslogtreecommitdiff
path: root/libnm-util
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-06-17 11:40:50 +0200
committerThomas Haller <thaller@redhat.com>2016-06-17 12:25:33 +0200
commitbc1014a93df6defd91ee7de37cca4d0c4842d7f1 (patch)
treea7e4e13a7a25ed9c434ff44d38d48db93a53b24c /libnm-util
parentcaeaa789185b78d5fd88b4e7d61e0a517ae97175 (diff)
downloadNetworkManager-bc1014a93df6defd91ee7de37cca4d0c4842d7f1.tar.gz
all: replace _nm_utils_string_in_list() with g_strv_contains()
Diffstat (limited to 'libnm-util')
-rw-r--r--libnm-util/nm-setting-8021x.c10
-rw-r--r--libnm-util/nm-setting-bond.c2
-rw-r--r--libnm-util/nm-setting-wired.c10
-rw-r--r--libnm-util/nm-setting-wireless-security.c6
-rw-r--r--libnm-util/nm-setting-wireless.c4
-rw-r--r--libnm-util/nm-utils-private.h3
-rw-r--r--libnm-util/nm-utils.c14
7 files changed, 17 insertions, 32 deletions
diff --git a/libnm-util/nm-setting-8021x.c b/libnm-util/nm-setting-8021x.c
index 4f974a413a..03165bda37 100644
--- a/libnm-util/nm-setting-8021x.c
+++ b/libnm-util/nm-setting-8021x.c
@@ -2707,7 +2707,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
}
}
- if (priv->phase1_peapver && !_nm_utils_string_in_list (priv->phase1_peapver, valid_phase1_peapver)) {
+ if (priv->phase1_peapver && !g_strv_contains (valid_phase1_peapver, priv->phase1_peapver)) {
g_set_error (error,
NM_SETTING_802_1X_ERROR,
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
@@ -2717,7 +2717,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
- if (priv->phase1_peaplabel && !_nm_utils_string_in_list (priv->phase1_peaplabel, valid_phase1_peaplabel)) {
+ if (priv->phase1_peaplabel && !g_strv_contains (valid_phase1_peaplabel, priv->phase1_peaplabel)) {
g_set_error (error,
NM_SETTING_802_1X_ERROR,
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
@@ -2727,7 +2727,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
- if (priv->phase1_fast_provisioning && !_nm_utils_string_in_list (priv->phase1_fast_provisioning, valid_phase1_fast_pac)) {
+ if (priv->phase1_fast_provisioning && !g_strv_contains (valid_phase1_fast_pac, priv->phase1_fast_provisioning)) {
g_set_error (error,
NM_SETTING_802_1X_ERROR,
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
@@ -2737,7 +2737,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
- if (priv->phase2_auth && !_nm_utils_string_in_list (priv->phase2_auth, valid_phase2_auth)) {
+ if (priv->phase2_auth && !g_strv_contains (valid_phase2_auth, priv->phase2_auth)) {
g_set_error (error,
NM_SETTING_802_1X_ERROR,
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
@@ -2747,7 +2747,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
- if (priv->phase2_autheap && !_nm_utils_string_in_list (priv->phase2_autheap, valid_phase2_autheap)) {
+ if (priv->phase2_autheap && !g_strv_contains (valid_phase2_autheap, priv->phase2_autheap)) {
g_set_error (error,
NM_SETTING_802_1X_ERROR,
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
diff --git a/libnm-util/nm-setting-bond.c b/libnm-util/nm-setting-bond.c
index 29bf6404be..8a11bc23e9 100644
--- a/libnm-util/nm-setting-bond.c
+++ b/libnm-util/nm-setting-bond.c
@@ -534,7 +534,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
return FALSE;
}
- if (!_nm_utils_string_in_list (value, valid_modes)) {
+ if (!g_strv_contains (valid_modes, value)) {
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
diff --git a/libnm-util/nm-setting-wired.c b/libnm-util/nm-setting-wired.c
index 0c3371e7b9..6866d0b1a1 100644
--- a/libnm-util/nm-setting-wired.c
+++ b/libnm-util/nm-setting-wired.c
@@ -539,7 +539,7 @@ nm_setting_wired_add_s390_option (NMSettingWired *setting,
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
g_return_val_if_fail (key != NULL, FALSE);
g_return_val_if_fail (strlen (key), FALSE);
- g_return_val_if_fail (_nm_utils_string_in_list (key, valid_s390_opts), FALSE);
+ g_return_val_if_fail (g_strv_contains (valid_s390_opts, key), FALSE);
g_return_val_if_fail (value != NULL, FALSE);
value_len = strlen (value);
@@ -606,7 +606,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
GSList* mac_blacklist_iter;
const char *key, *value;
- if (priv->port && !_nm_utils_string_in_list (priv->port, valid_ports)) {
+ if (priv->port && !g_strv_contains (valid_ports, priv->port)) {
g_set_error (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
@@ -616,7 +616,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
- if (priv->duplex && !_nm_utils_string_in_list (priv->duplex, valid_duplex)) {
+ if (priv->duplex && !g_strv_contains (valid_duplex, priv->duplex)) {
g_set_error (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
@@ -660,7 +660,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
- if (priv->s390_nettype && !_nm_utils_string_in_list (priv->s390_nettype, valid_nettype)) {
+ if (priv->s390_nettype && !g_strv_contains (valid_nettype, priv->s390_nettype)) {
g_set_error_literal (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
@@ -671,7 +671,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_hash_table_iter_init (&iter, priv->s390_options);
while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) {
- if ( !_nm_utils_string_in_list (key, valid_s390_opts)
+ if ( !g_strv_contains (valid_s390_opts, key)
|| !strlen (value)
|| (strlen (value) > 200)) {
g_set_error (error,
diff --git a/libnm-util/nm-setting-wireless-security.c b/libnm-util/nm-setting-wireless-security.c
index 8749cdfaa6..fd8eb976f1 100644
--- a/libnm-util/nm-setting-wireless-security.c
+++ b/libnm-util/nm-setting-wireless-security.c
@@ -893,7 +893,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
- if (!_nm_utils_string_in_list (priv->key_mgmt, valid_key_mgmt)) {
+ if (!g_strv_contains (valid_key_mgmt, priv->key_mgmt)) {
g_set_error (error,
NM_SETTING_WIRELESS_SECURITY_ERROR,
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
@@ -966,7 +966,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
- if (priv->auth_alg && !_nm_utils_string_in_list (priv->auth_alg, valid_auth_algs)) {
+ if (priv->auth_alg && !g_strv_contains (valid_auth_algs, priv->auth_alg)) {
g_set_error_literal (error,
NM_SETTING_WIRELESS_SECURITY_ERROR,
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
@@ -988,7 +988,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
const char *wpa_none[] = { "wpa-none", NULL };
/* For ad-hoc connections, pairwise must be "none" */
- if (_nm_utils_string_in_list (priv->key_mgmt, wpa_none)) {
+ if (g_strv_contains (wpa_none, priv->key_mgmt)) {
GSList *iter;
gboolean found = FALSE;
diff --git a/libnm-util/nm-setting-wireless.c b/libnm-util/nm-setting-wireless.c
index acb1d457cd..3341fc8bad 100644
--- a/libnm-util/nm-setting-wireless.c
+++ b/libnm-util/nm-setting-wireless.c
@@ -780,7 +780,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
- if (priv->mode && !_nm_utils_string_in_list (priv->mode, valid_modes)) {
+ if (priv->mode && !g_strv_contains (valid_modes, priv->mode)) {
g_set_error (error,
NM_SETTING_WIRELESS_ERROR,
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
@@ -790,7 +790,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
- if (priv->band && !_nm_utils_string_in_list (priv->band, valid_bands)) {
+ if (priv->band && !g_strv_contains (valid_bands, priv->band)) {
g_set_error (error,
NM_SETTING_WIRELESS_ERROR,
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
diff --git a/libnm-util/nm-utils-private.h b/libnm-util/nm-utils-private.h
index 0e7be21e28..2436332a97 100644
--- a/libnm-util/nm-utils-private.h
+++ b/libnm-util/nm-utils-private.h
@@ -23,9 +23,6 @@
#include "nm-setting-private.h"
-gboolean _nm_utils_string_in_list (const char *str,
- const char **valid_strings);
-
gboolean _nm_utils_string_slist_validate (GSList *list,
const char **valid_values);
diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c
index 717260af2c..f22b4f74b8 100644
--- a/libnm-util/nm-utils.c
+++ b/libnm-util/nm-utils.c
@@ -517,24 +517,12 @@ nm_utils_slist_free (GSList *list, GDestroyNotify elem_destroy_fn)
}
gboolean
-_nm_utils_string_in_list (const char *str, const char **valid_strings)
-{
- int i;
-
- for (i = 0; valid_strings[i]; i++)
- if (strcmp (str, valid_strings[i]) == 0)
- break;
-
- return valid_strings[i] != NULL;
-}
-
-gboolean
_nm_utils_string_slist_validate (GSList *list, const char **valid_values)
{
GSList *iter;
for (iter = list; iter; iter = iter->next) {
- if (!_nm_utils_string_in_list ((char *) iter->data, valid_values))
+ if (!g_strv_contains (valid_values, (char *) iter->data))
return FALSE;
}