summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-09-27 09:14:30 +0200
committerThomas Haller <thaller@redhat.com>2022-09-28 13:30:44 +0200
commitf786b054799c6bf8cd349f0780e9775e50ad4690 (patch)
treef426524a72a700a07d7fc38aa2ac7021a2956426
parent2953ebccba8af26c718deab89bc438870f4cfca8 (diff)
glib-aux: swap arguments for nm_array_find_bsearch()
Have "len" before "elem_size". That is consistent with g_qsort_with_data() and bsearch(), and is also what I would expect. Note that the previous commit just renamed the function. If a user of the new, changed API gets backported to an older branch, we will get a compilation error and note that the arguments need to be adjusted.
-rw-r--r--src/core/nm-manager.c2
-rw-r--r--src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c2
-rw-r--r--src/core/supplicant/nm-supplicant-settings-verify.c2
-rw-r--r--src/libnm-base/nm-ethtool-base.c2
-rw-r--r--src/libnm-client-impl/nm-libnm-utils.c2
-rw-r--r--src/libnm-core-aux-intern/nm-libnm-core-utils.c2
-rw-r--r--src/libnm-core-impl/nm-meta-setting-base-impl.c2
-rw-r--r--src/libnm-core-impl/nm-setting-ip-config.c2
-rw-r--r--src/libnm-core-impl/nm-setting.c2
-rw-r--r--src/libnm-core-impl/tests/test-general.c4
-rw-r--r--src/libnm-glib-aux/nm-shared-utils.c6
-rw-r--r--src/libnm-glib-aux/nm-shared-utils.h2
-rw-r--r--src/libnmc-setting/nm-meta-setting-base-impl.c2
13 files changed, 16 insertions, 16 deletions
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c
index d9bc28e55e..1197e2c98c 100644
--- a/src/core/nm-manager.c
+++ b/src/core/nm-manager.c
@@ -7905,8 +7905,8 @@ nm_manager_set_capability(NMManager *self, NMCapability cap)
priv = NM_MANAGER_GET_PRIVATE(self);
idx = nm_array_find_bsearch(nm_g_array_index_p(priv->capabilities, guint32, 0),
- sizeof(guint32),
priv->capabilities->len,
+ sizeof(guint32),
&cap_i,
nm_cmp_uint32_p_with_data,
NULL);
diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
index 4d650021c4..3bf9f7df47 100644
--- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
+++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
@@ -1081,8 +1081,8 @@ nms_ifcfg_well_known_key_find_info(const char *key, gssize *out_idx)
G_STATIC_ASSERT(G_STRUCT_OFFSET(NMSIfcfgKeyTypeInfo, key_name) == 0);
idx = nm_array_find_bsearch(nms_ifcfg_well_known_keys,
- sizeof(nms_ifcfg_well_known_keys[0]),
G_N_ELEMENTS(nms_ifcfg_well_known_keys),
+ sizeof(nms_ifcfg_well_known_keys[0]),
&key,
nm_strcmp_p_with_data,
NULL);
diff --git a/src/core/supplicant/nm-supplicant-settings-verify.c b/src/core/supplicant/nm-supplicant-settings-verify.c
index aa85ba9984..08a3553fc7 100644
--- a/src/core/supplicant/nm-supplicant-settings-verify.c
+++ b/src/core/supplicant/nm-supplicant-settings-verify.c
@@ -280,8 +280,8 @@ nm_supplicant_settings_verify_setting(const char *key, const char *value, const
}
opt_idx = nm_array_find_bsearch(opt_table,
- sizeof(opt_table[0]),
G_N_ELEMENTS(opt_table),
+ sizeof(opt_table[0]),
&key,
nm_strcmp_p_with_data,
NULL);
diff --git a/src/libnm-base/nm-ethtool-base.c b/src/libnm-base/nm-ethtool-base.c
index 50cb78f6b5..db77651ac5 100644
--- a/src/libnm-base/nm-ethtool-base.c
+++ b/src/libnm-base/nm-ethtool-base.c
@@ -272,8 +272,8 @@ nm_ethtool_data_get_by_optname(const char *optname)
_ASSERT_data();
idx = nm_array_find_bsearch((gconstpointer *) _by_name,
- sizeof(_by_name[0]),
_NM_ETHTOOL_ID_NUM,
+ sizeof(_by_name[0]),
optname,
_by_name_cmp,
NULL);
diff --git a/src/libnm-client-impl/nm-libnm-utils.c b/src/libnm-client-impl/nm-libnm-utils.c
index e67f4c1b6b..f773c7f81d 100644
--- a/src/libnm-client-impl/nm-libnm-utils.c
+++ b/src/libnm-client-impl/nm-libnm-utils.c
@@ -776,8 +776,8 @@ nml_dbus_meta_property_get(const NMLDBusMetaIface *meta_iface,
nm_assert(dbus_property_name);
idx = nm_array_find_bsearch(meta_iface->dbus_properties,
- sizeof(meta_iface->dbus_properties[0]),
meta_iface->n_dbus_properties,
+ sizeof(meta_iface->dbus_properties[0]),
&dbus_property_name,
nm_strcmp_p_with_data,
NULL);
diff --git a/src/libnm-core-aux-intern/nm-libnm-core-utils.c b/src/libnm-core-aux-intern/nm-libnm-core-utils.c
index 92e84182e4..b76ff0fa3d 100644
--- a/src/libnm-core-aux-intern/nm-libnm-core-utils.c
+++ b/src/libnm-core-aux-intern/nm-libnm-core-utils.c
@@ -350,8 +350,8 @@ nm_auth_permission_from_string(const char *str)
if (!NM_STR_HAS_PREFIX(str, AUTH_PERMISSION_PREFIX))
return NM_CLIENT_PERMISSION_NONE;
idx = nm_array_find_bsearch(nm_auth_permission_sorted,
- sizeof(nm_auth_permission_sorted[0]),
G_N_ELEMENTS(nm_auth_permission_sorted),
+ sizeof(nm_auth_permission_sorted[0]),
&str[NM_STRLEN(AUTH_PERMISSION_PREFIX)],
_nm_auth_permission_from_string_cmp,
NULL);
diff --git a/src/libnm-core-impl/nm-meta-setting-base-impl.c b/src/libnm-core-impl/nm-meta-setting-base-impl.c
index f361854dbe..ebc04556a7 100644
--- a/src/libnm-core-impl/nm-meta-setting-base-impl.c
+++ b/src/libnm-core-impl/nm-meta-setting-base-impl.c
@@ -694,8 +694,8 @@ nm_meta_setting_infos_by_name(const char *name)
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(NMMetaSettingInfo, setting_name) == 0);
idx = nm_array_find_bsearch(nm_meta_setting_infos,
- sizeof(NMMetaSettingInfo),
_NM_META_SETTING_TYPE_NUM,
+ sizeof(NMMetaSettingInfo),
&name,
nm_strcmp_p_with_data,
NULL);
diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c
index b6738189d7..a1bdbe364b 100644
--- a/src/libnm-core-impl/nm-setting-ip-config.c
+++ b/src/libnm-core-impl/nm-setting-ip-config.c
@@ -2935,8 +2935,8 @@ _rr_dbus_attr_from_name(const char *name)
}
idx = nm_array_find_bsearch(rr_dbus_data,
- sizeof(rr_dbus_data[0]),
_RR_DBUS_ATTR_NUM,
+ sizeof(rr_dbus_data[0]),
&name,
nm_strcmp_p_with_data,
NULL);
diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c
index ff07811d8b..7086a60bc0 100644
--- a/src/libnm-core-impl/nm-setting.c
+++ b/src/libnm-core-impl/nm-setting.c
@@ -478,8 +478,8 @@ _nm_sett_info_setting_get_property_info(const NMSettInfoSetting *sett_info,
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(NMSettInfoProperty, name) == 0);
idx = nm_array_find_bsearch(sett_info->property_infos,
- sizeof(NMSettInfoProperty),
sett_info->property_infos_len,
+ sizeof(NMSettInfoProperty),
&property_name,
nm_strcmp_p_with_data,
NULL);
diff --git a/src/libnm-core-impl/tests/test-general.c b/src/libnm-core-impl/tests/test-general.c
index e8767bba05..0a47890f1f 100644
--- a/src/libnm-core-impl/tests/test-general.c
+++ b/src/libnm-core-impl/tests/test-general.c
@@ -8858,8 +8858,8 @@ _test_find_binary_search_do_uint32(const int *int_array, gsize len)
}
idx = nm_array_find_bsearch(array,
- sizeof(guint32),
len,
+ sizeof(guint32),
&NEEDLE,
nm_cmp_uint32_p_with_data,
NULL);
@@ -8967,8 +8967,8 @@ test_nm_utils_ptrarray_find_binary_search_with_duplicates(void)
idx_first2 = nm_utils_ptrarray_find_first(arr, i_len, p);
idx2 = nm_array_find_bsearch(arr,
- sizeof(gpointer),
i_len,
+ sizeof(gpointer),
&p,
_test_bin_search2_cmp_p,
NULL);
diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c
index d98489f18c..6f56a4fe95 100644
--- a/src/libnm-glib-aux/nm-shared-utils.c
+++ b/src/libnm-glib-aux/nm-shared-utils.c
@@ -3094,8 +3094,8 @@ nm_utils_named_value_list_find(const NMUtilsNamedValue *arr,
if (sorted) {
return nm_array_find_bsearch(arr,
- sizeof(NMUtilsNamedValue),
len,
+ sizeof(NMUtilsNamedValue),
&name,
nm_strcmp_p_with_data,
NULL);
@@ -3906,8 +3906,8 @@ nm_ptrarray_find_bsearch_range(gconstpointer *list,
/**
* nm_array_find_bsearch:
* @list: the list to search. It must be sorted according to @cmpfcn ordering.
- * @elem_size: the size in bytes of each element in the list
* @len: the number of elements in @list
+ * @elem_size: the size in bytes of each element in the list
* @needle: the value that is searched
* @cmpfcn: the compare function. The elements @list are passed as first
* argument to @cmpfcn, while @needle is passed as second. Usually, the
@@ -3929,8 +3929,8 @@ nm_ptrarray_find_bsearch_range(gconstpointer *list,
*/
gssize
nm_array_find_bsearch(gconstpointer list,
- gsize elem_size,
gsize len,
+ gsize elem_size,
gconstpointer needle,
GCompareDataFunc cmpfcn,
gpointer user_data)
diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h
index cb2c9d8557..3d32f0d21a 100644
--- a/src/libnm-glib-aux/nm-shared-utils.h
+++ b/src/libnm-glib-aux/nm-shared-utils.h
@@ -2134,8 +2134,8 @@ gssize nm_ptrarray_find_bsearch_range(gconstpointer *list,
})
gssize nm_array_find_bsearch(gconstpointer list,
- gsize elem_size,
gsize len,
+ gsize elem_size,
gconstpointer needle,
GCompareDataFunc cmpfcn,
gpointer user_data);
diff --git a/src/libnmc-setting/nm-meta-setting-base-impl.c b/src/libnmc-setting/nm-meta-setting-base-impl.c
index f361854dbe..ebc04556a7 100644
--- a/src/libnmc-setting/nm-meta-setting-base-impl.c
+++ b/src/libnmc-setting/nm-meta-setting-base-impl.c
@@ -694,8 +694,8 @@ nm_meta_setting_infos_by_name(const char *name)
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(NMMetaSettingInfo, setting_name) == 0);
idx = nm_array_find_bsearch(nm_meta_setting_infos,
- sizeof(NMMetaSettingInfo),
_NM_META_SETTING_TYPE_NUM,
+ sizeof(NMMetaSettingInfo),
&name,
nm_strcmp_p_with_data,
NULL);