mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 05:58:01 +02:00
glib-aux/trivial: rename GBytes helper API
Give a consistent name.
A bit odd are now the names nm_g_bytes_hash() and nm_g_bytes_equal()
as they go together with nm_pg_bytes_hash()/nm_pg_bytes_equal().
But here the problem is more with the naming of "nm_p*_{equal,hash}()"
functions, which probably should be renamed to "nm_*_ptr_{equal,hash}()".
This commit is contained in:
parent
9876623363
commit
572ce7b7a7
18 changed files with 42 additions and 43 deletions
|
|
@ -322,7 +322,7 @@ _scan_request_ssids_track(NMDeviceWifiPrivate *priv, const GPtrArray *ssids)
|
|||
now_msec = nm_utils_get_monotonic_timestamp_msec();
|
||||
|
||||
if (!priv->scan_request_ssids_hash)
|
||||
priv->scan_request_ssids_hash = g_hash_table_new(nm_pgbytes_hash, nm_pgbytes_equal);
|
||||
priv->scan_request_ssids_hash = g_hash_table_new(nm_pg_bytes_hash, nm_pg_bytes_equal);
|
||||
|
||||
/* Do a little dance. New elements shall keep their order as in @ssids, but all
|
||||
* new elements should be sorted in the list preexisting elements of the list.
|
||||
|
|
@ -1569,7 +1569,7 @@ _scan_request_ssids_build_hidden(NMDeviceWifi *self,
|
|||
if (ssids) {
|
||||
if (ssids->len < max_scan_ssids) {
|
||||
/* Add wildcard SSID using a static wildcard SSID used for every scan */
|
||||
g_ptr_array_insert(ssids, 0, g_bytes_ref(nm_gbytes_get_empty()));
|
||||
g_ptr_array_insert(ssids, 0, g_bytes_ref(nm_g_bytes_get_empty()));
|
||||
}
|
||||
if (ssids->len >= max_scan_ssids) {
|
||||
/* there is no more space. Use what we have. */
|
||||
|
|
@ -1590,10 +1590,10 @@ _scan_request_ssids_build_hidden(NMDeviceWifi *self,
|
|||
if (!ssids) {
|
||||
ssids = g_ptr_array_new_full(max_scan_ssids, (GDestroyNotify) g_bytes_unref);
|
||||
/* Add wildcard SSID using a static wildcard SSID used for every scan */
|
||||
g_ptr_array_insert(ssids, 0, g_bytes_ref(nm_gbytes_get_empty()));
|
||||
g_ptr_array_insert(ssids, 0, g_bytes_ref(nm_g_bytes_get_empty()));
|
||||
}
|
||||
|
||||
unique_ssids = g_hash_table_new(nm_gbytes_hash, nm_gbytes_equal);
|
||||
unique_ssids = g_hash_table_new(nm_g_bytes_hash, nm_g_bytes_equal);
|
||||
for (i = 1; i < ssids->len; i++) {
|
||||
if (!g_hash_table_add(unique_ssids, ssids->pdata[i]))
|
||||
nm_assert_not_reached();
|
||||
|
|
|
|||
|
|
@ -669,7 +669,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
g_value_set_uint(value, priv->rsn_flags);
|
||||
break;
|
||||
case PROP_SSID:
|
||||
g_value_take_variant(value, nm_utils_gbytes_to_variant_ay(priv->ssid));
|
||||
g_value_take_variant(value, nm_g_bytes_to_variant_ay(priv->ssid));
|
||||
break;
|
||||
case PROP_FREQUENCY:
|
||||
g_value_set_uint(value, priv->freq);
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ nm_wifi_p2p_peer_set_wfd_ies(NMWifiP2PPeer *peer, GBytes *wfd_ies)
|
|||
|
||||
priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer);
|
||||
|
||||
if (nm_gbytes_equal0(priv->wfd_ies, wfd_ies))
|
||||
if (nm_g_bytes_equal0(priv->wfd_ies, wfd_ies))
|
||||
return FALSE;
|
||||
|
||||
wfd_ies_old = g_steal_pointer(&priv->wfd_ies);
|
||||
|
|
@ -509,7 +509,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
g_value_set_string(value, priv->serial);
|
||||
break;
|
||||
case PROP_WFD_IES:
|
||||
g_value_take_variant(value, nm_utils_gbytes_to_variant_ay(priv->wfd_ies));
|
||||
g_value_take_variant(value, nm_g_bytes_to_variant_ay(priv->wfd_ies));
|
||||
break;
|
||||
case PROP_HW_ADDRESS:
|
||||
g_value_set_string(value, priv->address);
|
||||
|
|
|
|||
|
|
@ -1445,7 +1445,7 @@ do_test_ssids_options_to_ptrarray(const char *const *ssids)
|
|||
const char *ssid = ssids[i];
|
||||
GBytes * bytes = ssids_arr->pdata[i];
|
||||
|
||||
g_assert(nm_utils_gbytes_equal_mem(bytes, ssid, strlen(ssid)));
|
||||
g_assert(nm_g_bytes_equal_mem(bytes, ssid, strlen(ssid)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -830,7 +830,7 @@ test_one_duid(const char *escaped, const guint8 *unescaped, guint len)
|
|||
|
||||
t1 = nm_dhcp_dhclient_unescape_duid(escaped);
|
||||
g_assert(t1);
|
||||
g_assert(nm_utils_gbytes_equal_mem(t1, unescaped, len));
|
||||
g_assert(nm_g_bytes_equal_mem(t1, unescaped, len));
|
||||
|
||||
t2 = g_bytes_new(unescaped, len);
|
||||
w = nm_dhcp_dhclient_escape_duid(t2);
|
||||
|
|
@ -879,7 +879,7 @@ test_read_duid_from_leasefile(void)
|
|||
duid = nm_dhcp_dhclient_read_duid(TEST_DIR "/test-dhclient-duid.leases", &error);
|
||||
nmtst_assert_success(duid, error);
|
||||
|
||||
g_assert(nm_utils_gbytes_equal_mem(duid, expected, G_N_ELEMENTS(expected)));
|
||||
g_assert(nm_g_bytes_equal_mem(duid, expected, G_N_ELEMENTS(expected)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -3085,7 +3085,7 @@ test_read_wifi_wpa_psk_hex(void)
|
|||
|
||||
ssid = nm_setting_wireless_get_ssid(s_wifi);
|
||||
g_assert(ssid);
|
||||
g_assert(nm_utils_gbytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid)));
|
||||
g_assert(nm_g_bytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid)));
|
||||
|
||||
s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
|
||||
g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "wpa-psk");
|
||||
|
|
|
|||
|
|
@ -992,7 +992,7 @@ test_read_intlike_ssid(void)
|
|||
|
||||
ssid = nm_setting_wireless_get_ssid(s_wifi);
|
||||
g_assert(ssid);
|
||||
g_assert(nm_utils_gbytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid)));
|
||||
g_assert(nm_g_bytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1010,7 +1010,7 @@ test_read_intlike_ssid_2(void)
|
|||
|
||||
ssid = nm_setting_wireless_get_ssid(s_wifi);
|
||||
g_assert(ssid);
|
||||
g_assert(nm_utils_gbytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid)));
|
||||
g_assert(nm_g_bytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1774,7 +1774,7 @@ test_write_wired_8021x_tls_connection_blob(void)
|
|||
|
||||
password_raw = nm_setting_802_1x_get_password_raw(s_8021x);
|
||||
g_assert(password_raw);
|
||||
g_assert(nm_utils_gbytes_equal_mem(password_raw, PASSWORD_RAW, NM_STRLEN(PASSWORD_RAW)));
|
||||
g_assert(nm_g_bytes_equal_mem(password_raw, PASSWORD_RAW, NM_STRLEN(PASSWORD_RAW)));
|
||||
|
||||
unlink(testfile);
|
||||
|
||||
|
|
@ -2160,7 +2160,7 @@ test_read_new_wireless_group_names(void)
|
|||
|
||||
ssid = nm_setting_wireless_get_ssid(s_wifi);
|
||||
g_assert(ssid);
|
||||
g_assert(nm_utils_gbytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid)));
|
||||
g_assert(nm_g_bytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid)));
|
||||
|
||||
g_assert_cmpstr(nm_setting_wireless_get_mode(s_wifi), ==, NM_SETTING_WIRELESS_MODE_INFRA);
|
||||
|
||||
|
|
|
|||
|
|
@ -696,7 +696,7 @@ _bss_info_properties_changed(NMSupplicantInterface *self,
|
|||
} else
|
||||
arr_len = 0;
|
||||
|
||||
if (!nm_utils_gbytes_equal_mem(bss_info->ssid, arr_data, arr_len)) {
|
||||
if (!nm_g_bytes_equal_mem(bss_info->ssid, arr_data, arr_len)) {
|
||||
_nm_unused gs_unref_bytes GBytes *old_free = g_steal_pointer(&bss_info->ssid);
|
||||
|
||||
bss_info->ssid = (arr_len == 0) ? NULL : g_bytes_new(arr_data, arr_len);
|
||||
|
|
@ -970,7 +970,7 @@ _peer_info_properties_changed(NMSupplicantInterface *self,
|
|||
v_v = nm_g_variant_lookup_value(properties, "IEs", G_VARIANT_TYPE_BYTESTRING);
|
||||
if (v_v) {
|
||||
arr_data = g_variant_get_fixed_array(v_v, &arr_len, 1);
|
||||
if (!nm_utils_gbytes_equal_mem(peer_info->ies, arr_data, arr_len)) {
|
||||
if (!nm_g_bytes_equal_mem(peer_info->ies, arr_data, arr_len)) {
|
||||
_nm_unused gs_unref_bytes GBytes *old_free = g_steal_pointer(&peer_info->ies);
|
||||
|
||||
peer_info->ies = g_bytes_new(arr_data, arr_len);
|
||||
|
|
@ -2308,7 +2308,7 @@ assoc_add_network_cb(GObject *source, GAsyncResult *result, gpointer user_data)
|
|||
self,
|
||||
NM_WPAS_DBUS_IFACE_INTERFACE,
|
||||
"AddBlob",
|
||||
g_variant_new("(s@ay)", blob_name, nm_utils_gbytes_to_variant_ay(blob_data)),
|
||||
g_variant_new("(s@ay)", blob_name, nm_g_bytes_to_variant_ay(blob_data)),
|
||||
G_VARIANT_TYPE("()"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
DBUS_TIMEOUT_MSEC,
|
||||
|
|
@ -2612,7 +2612,7 @@ nm_supplicant_interface_request_scan(NMSupplicantInterface * se
|
|||
g_variant_builder_init(&ssids_builder, G_VARIANT_TYPE_BYTESTRING_ARRAY);
|
||||
for (i = 0; i < ssids_len; i++) {
|
||||
nm_assert(ssids[i]);
|
||||
g_variant_builder_add(&ssids_builder, "@ay", nm_utils_gbytes_to_variant_ay(ssids[i]));
|
||||
g_variant_builder_add(&ssids_builder, "@ay", nm_g_bytes_to_variant_ay(ssids[i]));
|
||||
}
|
||||
g_variant_builder_add(&builder, "{sv}", "SSIDs", g_variant_builder_end(&ssids_builder));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,8 +244,7 @@ nm_supplicant_manager_set_wfd_ies(NMSupplicantManager *self, GBytes *wfd_ies)
|
|||
|
||||
g_variant_builder_add(¶ms, "s", NM_WPAS_DBUS_INTERFACE);
|
||||
g_variant_builder_add(¶ms, "s", "WFDIEs");
|
||||
g_variant_builder_add_value(¶ms,
|
||||
g_variant_new_variant(nm_utils_gbytes_to_variant_ay(wfd_ies)));
|
||||
g_variant_builder_add_value(¶ms, g_variant_new_variant(nm_g_bytes_to_variant_ay(wfd_ies)));
|
||||
|
||||
g_dbus_connection_call(priv->dbus_connection,
|
||||
priv->name_owner->str,
|
||||
|
|
|
|||
|
|
@ -594,13 +594,13 @@ _cert_impl_set(NMSetting8021x * setting,
|
|||
* property to the same PKCS#12 data.
|
||||
*/
|
||||
if (cert && p_client_cert && format == NM_CRYPTO_FILE_FORMAT_PKCS12
|
||||
&& !nm_gbytes_equal0(cert, *p_client_cert)) {
|
||||
&& !nm_g_bytes_equal0(cert, *p_client_cert)) {
|
||||
g_bytes_unref(*p_client_cert);
|
||||
*p_client_cert = g_bytes_ref(cert);
|
||||
} else
|
||||
notify_client_cert = PROP_0;
|
||||
|
||||
if (p_cert && !nm_gbytes_equal0(cert, *p_cert)) {
|
||||
if (p_cert && !nm_g_bytes_equal0(cert, *p_cert)) {
|
||||
g_bytes_unref(*p_cert);
|
||||
*p_cert = g_steal_pointer(&cert);
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -1063,7 +1063,7 @@ _nm_setting_property_to_dbus_fcn_gprop(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_n
|
|||
return g_dbus_gvalue_to_gvariant(&prop_value, property_info->property_type->dbus_type);
|
||||
case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_BYTES:
|
||||
nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_BYTES));
|
||||
return nm_utils_gbytes_to_variant_ay(g_value_get_boxed(&prop_value));
|
||||
return nm_g_bytes_to_variant_ay(g_value_get_boxed(&prop_value));
|
||||
case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM:
|
||||
return g_variant_new_int32(g_value_get_enum(&prop_value));
|
||||
case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS:
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ test_load_private_key(const char *path,
|
|||
/* Compare the crypto decrypted key against a known-good decryption */
|
||||
if (!g_file_get_contents(decrypted_path, &contents, &length, NULL))
|
||||
g_assert_not_reached();
|
||||
g_assert(nm_utils_gbytes_equal_mem(array, contents, length));
|
||||
g_assert(nm_g_bytes_equal_mem(array, contents, length));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7119,7 +7119,7 @@ test_hexstr2bin(void)
|
|||
g_assert(b);
|
||||
else
|
||||
g_assert(!b);
|
||||
g_assert(nm_utils_gbytes_equal_mem(b, items[i].expected, items[i].expected_len));
|
||||
g_assert(nm_g_bytes_equal_mem(b, items[i].expected, items[i].expected_len));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ _assert_gbytes(GBytes *bytes, gconstpointer data, gssize len)
|
|||
if (!len)
|
||||
g_assert(!bytes);
|
||||
|
||||
g_assert(nm_utils_gbytes_equal_mem(bytes, data, len));
|
||||
g_assert(nm_g_bytes_equal_mem(bytes, data, len));
|
||||
}
|
||||
|
||||
static GKeyFile *
|
||||
|
|
@ -350,7 +350,7 @@ _test_8021x_cert_check(NMConnection * con,
|
|||
}
|
||||
|
||||
g_assert(blob);
|
||||
g_assert(nm_utils_gbytes_equal_mem(blob, value, val_len));
|
||||
g_assert(nm_g_bytes_equal_mem(blob, value, val_len));
|
||||
|
||||
kval = g_key_file_get_string(keyfile, "802-1x", "ca-cert", NULL);
|
||||
g_assert(kval);
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ nm_ppdirect_equal(gconstpointer a, gconstpointer b)
|
|||
/*****************************************************************************/
|
||||
|
||||
guint
|
||||
nm_gbytes_hash(gconstpointer p)
|
||||
nm_g_bytes_hash(gconstpointer p)
|
||||
{
|
||||
GBytes * ptr = (GBytes *) p;
|
||||
gconstpointer arr;
|
||||
|
|
@ -266,7 +266,7 @@ nm_gbytes_hash(gconstpointer p)
|
|||
}
|
||||
|
||||
guint
|
||||
nm_pgbytes_hash(gconstpointer p)
|
||||
nm_pg_bytes_hash(gconstpointer p)
|
||||
{
|
||||
GBytes *const *ptr = p;
|
||||
gconstpointer arr;
|
||||
|
|
@ -277,7 +277,7 @@ nm_pgbytes_hash(gconstpointer p)
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_pgbytes_equal(gconstpointer a, gconstpointer b)
|
||||
nm_pg_bytes_equal(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
GBytes *const *ptr_a = a;
|
||||
GBytes *const *ptr_b = b;
|
||||
|
|
|
|||
|
|
@ -267,11 +267,11 @@ gboolean nm_ppdirect_equal(gconstpointer a, gconstpointer b);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
guint nm_gbytes_hash(gconstpointer p);
|
||||
#define nm_gbytes_equal g_bytes_equal
|
||||
guint nm_g_bytes_hash(gconstpointer p);
|
||||
#define nm_g_bytes_equal g_bytes_equal
|
||||
|
||||
guint nm_pgbytes_hash(gconstpointer p);
|
||||
gboolean nm_pgbytes_equal(gconstpointer a, gconstpointer b);
|
||||
guint nm_pg_bytes_hash(gconstpointer p);
|
||||
gboolean nm_pg_bytes_equal(gconstpointer a, gconstpointer b);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ truncate:
|
|||
/*****************************************************************************/
|
||||
|
||||
GBytes *
|
||||
nm_gbytes_get_empty(void)
|
||||
nm_g_bytes_get_empty(void)
|
||||
{
|
||||
static GBytes *bytes = NULL;
|
||||
GBytes * b;
|
||||
|
|
@ -520,7 +520,7 @@ nm_g_bytes_new_from_variant_ay(GVariant *var)
|
|||
}
|
||||
|
||||
/**
|
||||
* nm_utils_gbytes_equal_mem:
|
||||
* nm_g_bytes_equal_mem:
|
||||
* @bytes: (allow-none): a #GBytes array to compare. Note that
|
||||
* %NULL is treated like an #GBytes array of length zero.
|
||||
* @mem_data: the data pointer with @mem_len bytes
|
||||
|
|
@ -530,7 +530,7 @@ nm_g_bytes_new_from_variant_ay(GVariant *var)
|
|||
* special case, a %NULL @bytes is treated like an empty array.
|
||||
*/
|
||||
gboolean
|
||||
nm_utils_gbytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len)
|
||||
nm_g_bytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len)
|
||||
{
|
||||
gconstpointer p;
|
||||
gsize l;
|
||||
|
|
@ -548,7 +548,7 @@ nm_utils_gbytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len)
|
|||
}
|
||||
|
||||
GVariant *
|
||||
nm_utils_gbytes_to_variant_ay(const GBytes *bytes)
|
||||
nm_g_bytes_to_variant_ay(const GBytes *bytes)
|
||||
{
|
||||
const guint8 *p = NULL;
|
||||
gsize l = 0;
|
||||
|
|
|
|||
|
|
@ -599,20 +599,20 @@ nm_utils_is_separator(const char c)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
GBytes *nm_gbytes_get_empty(void);
|
||||
GBytes *nm_g_bytes_get_empty(void);
|
||||
|
||||
GBytes *nm_g_bytes_new_from_str(const char *str);
|
||||
GBytes *nm_g_bytes_new_from_variant_ay(GVariant *var);
|
||||
|
||||
static inline gboolean
|
||||
nm_gbytes_equal0(const GBytes *a, const GBytes *b)
|
||||
nm_g_bytes_equal0(const GBytes *a, const GBytes *b)
|
||||
{
|
||||
return a == b || (a && b && g_bytes_equal(a, b));
|
||||
}
|
||||
|
||||
gboolean nm_utils_gbytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len);
|
||||
gboolean nm_g_bytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len);
|
||||
|
||||
GVariant *nm_utils_gbytes_to_variant_ay(const GBytes *bytes);
|
||||
GVariant *nm_g_bytes_to_variant_ay(const GBytes *bytes);
|
||||
|
||||
GHashTable *nm_strdict_clone(GHashTable *src);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue