diff options
author | Thomas Haller <thaller@redhat.com> | 2016-06-17 12:26:57 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-06-17 12:26:57 +0200 |
commit | 062fccf46f8e9c765a20616c905dd0173017f4ef (patch) | |
tree | a7e4e13a7a25ed9c434ff44d38d48db93a53b24c | |
parent | f90abce4d55c37955dcef8b50867bbfec33ad06b (diff) | |
parent | bc1014a93df6defd91ee7de37cca4d0c4842d7f1 (diff) | |
download | NetworkManager-062fccf46f8e9c765a20616c905dd0173017f4ef.tar.gz |
all: merge branch 'th/g_strv_contrains'
-rw-r--r-- | libnm-core/nm-core-internal.h | 3 | ||||
-rw-r--r-- | libnm-core/nm-setting-8021x.c | 10 | ||||
-rw-r--r-- | libnm-core/nm-setting-wired.c | 10 | ||||
-rw-r--r-- | libnm-core/nm-setting-wireless-security.c | 6 | ||||
-rw-r--r-- | libnm-core/nm-setting-wireless.c | 4 | ||||
-rw-r--r-- | libnm-core/nm-utils.c | 8 | ||||
-rw-r--r-- | libnm-util/nm-gvaluearray-compat.h | 22 | ||||
-rw-r--r-- | libnm-util/nm-setting-8021x.c | 10 | ||||
-rw-r--r-- | libnm-util/nm-setting-bond.c | 2 | ||||
-rw-r--r-- | libnm-util/nm-setting-wired.c | 10 | ||||
-rw-r--r-- | libnm-util/nm-setting-wireless-security.c | 6 | ||||
-rw-r--r-- | libnm-util/nm-setting-wireless.c | 4 | ||||
-rw-r--r-- | libnm-util/nm-utils-private.h | 3 | ||||
-rw-r--r-- | libnm-util/nm-utils.c | 14 | ||||
-rw-r--r-- | shared/nm-utils/nm-glib.h | 31 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez5-manager.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device.c | 8 | ||||
-rw-r--r-- | src/devices/wifi/nm-wifi-ap.c | 14 | ||||
-rw-r--r-- | src/supplicant-manager/nm-supplicant-interface.c | 7 | ||||
-rw-r--r-- | src/supplicant-manager/nm-supplicant-manager.c | 16 |
20 files changed, 98 insertions, 92 deletions
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index a09ee26c48..7ae126c1bc 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -145,9 +145,6 @@ gssize _nm_utils_ptrarray_find_first (gpointer *list, gssize len, gconstpointer gssize _nm_utils_ptrarray_find_binary_search (gpointer *list, gsize len, gpointer needle, GCompareDataFunc cmpfcn, gpointer user_data); -gboolean _nm_utils_string_in_list (const char *str, - const char **valid_strings); - gssize _nm_utils_strv_find_first (char **list, gssize len, const char *needle); char **_nm_utils_strv_cleanup (char **strv, diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c index 4db420de05..aa9d461969 100644 --- a/libnm-core/nm-setting-8021x.c +++ b/libnm-core/nm-setting-8021x.c @@ -2776,7 +2776,7 @@ verify (NMSetting *setting, NMConnection *connection, 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -2786,7 +2786,7 @@ verify (NMSetting *setting, NMConnection *connection, 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -2796,7 +2796,7 @@ verify (NMSetting *setting, NMConnection *connection, 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -2806,7 +2806,7 @@ verify (NMSetting *setting, NMConnection *connection, 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -2816,7 +2816,7 @@ verify (NMSetting *setting, NMConnection *connection, 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index 132f8e05ae..a76218fd24 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -504,7 +504,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); @@ -612,7 +612,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) const char *key, *value; int i; - 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -622,7 +622,7 @@ verify (NMSetting *setting, NMConnection *connection, 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -668,7 +668,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } } - 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -679,7 +679,7 @@ verify (NMSetting *setting, NMConnection *connection, 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-core/nm-setting-wireless-security.c b/libnm-core/nm-setting-wireless-security.c index 64e2aa4502..f98e9e57ec 100644 --- a/libnm-core/nm-setting-wireless-security.c +++ b/libnm-core/nm-setting-wireless-security.c @@ -863,7 +863,7 @@ verify (NMSetting *setting, NMConnection *connection, 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -936,7 +936,7 @@ verify (NMSetting *setting, NMConnection *connection, 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -958,7 +958,7 @@ verify (NMSetting *setting, NMConnection *connection, 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-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c index ee4ac6f261..6074959349 100644 --- a/libnm-core/nm-setting-wireless.c +++ b/libnm-core/nm-setting-wireless.c @@ -741,7 +741,7 @@ verify (NMSetting *setting, NMConnection *connection, 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -751,7 +751,7 @@ verify (NMSetting *setting, NMConnection *connection, 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_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 7a87dc18c4..4bcde68474 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -442,12 +442,6 @@ nm_utils_same_ssid (const guint8 *ssid1, gsize len1, return memcmp (ssid1, ssid2, len1) == 0 ? TRUE : FALSE; } -gboolean -_nm_utils_string_in_list (const char *str, const char **valid_strings) -{ - return _nm_utils_strv_find_first ((char **) valid_strings, -1, str) >= 0; -} - /** * _nm_utils_strv_find_first: * @list: the strv list to search @@ -530,7 +524,7 @@ _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; } diff --git a/libnm-util/nm-gvaluearray-compat.h b/libnm-util/nm-gvaluearray-compat.h index 424e6be78d..91f4f243a6 100644 --- a/libnm-util/nm-gvaluearray-compat.h +++ b/libnm-util/nm-gvaluearray-compat.h @@ -21,21 +21,21 @@ #define __NM_GVALUEARRAY_COMPAT_H__ #define g_value_array_get_type() \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ g_value_array_get_type (); \ G_GNUC_END_IGNORE_DEPRECATIONS \ }) #define g_value_array_get_nth(value_array, index_) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ g_value_array_get_nth (value_array, index_); \ G_GNUC_END_IGNORE_DEPRECATIONS \ }) #define g_value_array_new(n_prealloced) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ g_value_array_new (n_prealloced); \ G_GNUC_END_IGNORE_DEPRECATIONS \ @@ -44,7 +44,7 @@ static inline void __g_value_array_free (GValueArray *value_array) { - G_GNUC_EXTENSION ({ + ({ G_GNUC_BEGIN_IGNORE_DEPRECATIONS g_value_array_free (value_array); G_GNUC_END_IGNORE_DEPRECATIONS @@ -53,49 +53,49 @@ __g_value_array_free (GValueArray *value_array) #define g_value_array_free __g_value_array_free #define g_value_array_copy(value_array) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ g_value_array_copy (value_array); \ G_GNUC_END_IGNORE_DEPRECATIONS \ }) #define g_value_array_prepend(value_array, value) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ g_value_array_prepend (value_array, value); \ G_GNUC_END_IGNORE_DEPRECATIONS \ }) #define g_value_array_append(value_array, value) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ g_value_array_append (value_array, value); \ G_GNUC_END_IGNORE_DEPRECATIONS \ }) #define g_value_array_insert(value_array, index_, value) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ g_value_array_insert (value_array, index_, value); \ G_GNUC_END_IGNORE_DEPRECATIONS \ }) #define g_value_array_remove(value_array, index_) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ g_value_array_remove (value_array, index_); \ G_GNUC_END_IGNORE_DEPRECATIONS \ }) #define g_value_array_sort(value_array, compare_func) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ g_value_array_sort (value_array, compare_func); \ G_GNUC_END_IGNORE_DEPRECATIONS \ }) #define g_value_array_sort_with_data(value_array, compare_func, user_data) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ g_value_array_sort_with_data (value_array, compare_func, user_data); \ G_GNUC_END_IGNORE_DEPRECATIONS \ 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; } diff --git a/shared/nm-utils/nm-glib.h b/shared/nm-utils/nm-glib.h index 46a8bb2d9a..2818074d68 100644 --- a/shared/nm-utils/nm-glib.h +++ b/shared/nm-utils/nm-glib.h @@ -313,14 +313,14 @@ _g_key_file_save_to_file (GKeyFile *key_file, #if GLIB_CHECK_VERSION (2, 36, 0) #define g_credentials_get_unix_pid(creds, error) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ (g_credentials_get_unix_pid) ((creds), (error)); \ G_GNUC_END_IGNORE_DEPRECATIONS \ }) #else #define g_credentials_get_unix_pid(creds, error) \ - G_GNUC_EXTENSION ({ \ + ({ \ struct ucred *native_creds; \ \ native_creds = g_credentials_get_native ((creds), G_CREDENTIALS_TYPE_LINUX_UCRED); \ @@ -357,12 +357,12 @@ _nm_g_hash_table_get_keys_as_array (GHashTable *hash_table, #endif #if !GLIB_CHECK_VERSION(2, 40, 0) #define g_hash_table_get_keys_as_array(hash_table, length) \ - G_GNUC_EXTENSION ({ \ + ({ \ _nm_g_hash_table_get_keys_as_array (hash_table, length); \ }) #else #define g_hash_table_get_keys_as_array(hash_table, length) \ - G_GNUC_EXTENSION ({ \ + ({ \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ (g_hash_table_get_keys_as_array) ((hash_table), (length)); \ G_GNUC_END_IGNORE_DEPRECATIONS \ @@ -394,4 +394,27 @@ g_steal_pointer (gpointer pp) (0 ? (*(pp)) : (g_steal_pointer) (pp)) #endif + +static inline gboolean +_nm_g_strv_contains (const gchar * const *strv, + const gchar *str) +{ +#if !GLIB_CHECK_VERSION(2, 44, 0) + g_return_val_if_fail (strv != NULL, FALSE); + g_return_val_if_fail (str != NULL, FALSE); + + for (; *strv != NULL; strv++) { + if (g_str_equal (str, *strv)) + return TRUE; + } + + return FALSE; +#else + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + return g_strv_contains (strv, str); + G_GNUC_END_IGNORE_DEPRECATIONS +#endif +} +#define g_strv_contains _nm_g_strv_contains + #endif /* __NM_GLIB_H__ */ diff --git a/src/devices/bluetooth/nm-bluez5-manager.c b/src/devices/bluetooth/nm-bluez5-manager.c index 183f23c1e4..a014d0c124 100644 --- a/src/devices/bluetooth/nm-bluez5-manager.c +++ b/src/devices/bluetooth/nm-bluez5-manager.c @@ -182,7 +182,7 @@ object_manager_interfaces_removed (GDBusProxy *proxy, const char **ifaces, NMBluez5Manager *self) { - if (_nm_utils_string_in_list (BLUEZ5_DEVICE_INTERFACE, ifaces)) + if (ifaces && g_strv_contains (ifaces, BLUEZ5_DEVICE_INTERFACE)) device_removed (proxy, path, self); } diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index b9ea7551e3..c4579c69c3 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -3361,11 +3361,11 @@ nm_device_can_assume_active_connection (NMDevice *self) return FALSE; method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG); - if (!_nm_utils_string_in_list (method, assumable_ip6_methods)) + if (!g_strv_contains (assumable_ip6_methods, method)) return FALSE; method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG); - if (!_nm_utils_string_in_list (method, assumable_ip4_methods)) + if (!g_strv_contains (assumable_ip4_methods, method)) return FALSE; return TRUE; @@ -5021,7 +5021,7 @@ connection_ip4_method_requires_carrier (NMConnection *connection, if (out_ip4_enabled) *out_ip4_enabled = !!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); - return _nm_utils_string_in_list (method, ip4_carrier_methods); + return g_strv_contains (ip4_carrier_methods, method); } static gboolean @@ -5038,7 +5038,7 @@ connection_ip6_method_requires_carrier (NMConnection *connection, if (out_ip6_enabled) *out_ip6_enabled = !!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); - return _nm_utils_string_in_list (method, ip6_carrier_methods); + return g_strv_contains (ip6_carrier_methods, method); } static gboolean diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c index d0704b4ea9..e1beb85b09 100644 --- a/src/devices/wifi/nm-wifi-ap.c +++ b/src/devices/wifi/nm-wifi-ap.c @@ -365,18 +365,20 @@ security_from_vardict (GVariant *security) g_return_val_if_fail (g_variant_is_of_type (security, G_VARIANT_TYPE_VARDICT), NM_802_11_AP_SEC_NONE); - if (g_variant_lookup (security, "KeyMgmt", "^a&s", &array)) { - if (_nm_utils_string_in_list ("wpa-psk", array)) + if ( g_variant_lookup (security, "KeyMgmt", "^a&s", &array) + && array) { + if (g_strv_contains (array, "wpa-psk")) flags |= NM_802_11_AP_SEC_KEY_MGMT_PSK; - if (_nm_utils_string_in_list ("wpa-eap", array)) + if (g_strv_contains (array, "wpa-eap")) flags |= NM_802_11_AP_SEC_KEY_MGMT_802_1X; g_free (array); } - if (g_variant_lookup (security, "Pairwise", "^a&s", &array)) { - if (_nm_utils_string_in_list ("tkip", array)) + if ( g_variant_lookup (security, "Pairwise", "^a&s", &array) + && array) { + if (g_strv_contains (array, "tkip")) flags |= NM_802_11_AP_SEC_PAIR_TKIP; - if (_nm_utils_string_in_list ("ccmp", array)) + if (g_strv_contains (array, "ccmp")) flags |= NM_802_11_AP_SEC_PAIR_CCMP; g_free (array); } diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c index ce7a2a2c98..59e0ef3905 100644 --- a/src/supplicant-manager/nm-supplicant-interface.c +++ b/src/supplicant-manager/nm-supplicant-interface.c @@ -385,10 +385,11 @@ parse_capabilities (NMSupplicantInterface *self, GVariant *capabilities) g_return_if_fail (capabilities && g_variant_is_of_type (capabilities, G_VARIANT_TYPE_VARDICT)); - if (g_variant_lookup (capabilities, "Scan", "^a&s", &array)) { - if (_nm_utils_string_in_list ("active", array)) + if ( g_variant_lookup (capabilities, "Scan", "^a&s", &array) + && array) { + if (g_strv_contains (array, "active")) have_active = TRUE; - if (_nm_utils_string_in_list ("ssid", array)) + if (g_strv_contains (array, "ssid")) have_ssid = TRUE; g_free (array); } diff --git a/src/supplicant-manager/nm-supplicant-manager.c b/src/supplicant-manager/nm-supplicant-manager.c index f2c63364f3..57cd57131d 100644 --- a/src/supplicant-manager/nm-supplicant-manager.c +++ b/src/supplicant-manager/nm-supplicant-manager.c @@ -194,9 +194,11 @@ update_capabilities (NMSupplicantManager *self) if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY)) { array = g_variant_get_strv (value, NULL); priv->ap_support = NM_SUPPLICANT_FEATURE_NO; - if (_nm_utils_string_in_list ("ap", array)) - priv->ap_support = NM_SUPPLICANT_FEATURE_YES; - g_free (array); + if (array) { + if (g_strv_contains (array, "ap")) + priv->ap_support = NM_SUPPLICANT_FEATURE_YES; + g_free (array); + } } g_variant_unref (value); } @@ -215,9 +217,11 @@ update_capabilities (NMSupplicantManager *self) if (value) { if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY)) { array = g_variant_get_strv (value, NULL); - if (_nm_utils_string_in_list ("fast", array)) - priv->fast_supported = TRUE; - g_free (array); + if (array) { + if (g_strv_contains (array, "fast")) + priv->fast_supported = TRUE; + g_free (array); + } } g_variant_unref (value); } |