mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 02:28:18 +02:00
device/wifi: cleanup ssids_options_to_ptrarray()
- use proper gsize type to hold g_variant_n_children() - use cleanup attribute for GPtrArray - move variables inside nested scope where they are used
This commit is contained in:
parent
023dc9646c
commit
e6d256fe81
1 changed files with 8 additions and 7 deletions
|
|
@ -1074,10 +1074,9 @@ _hw_addr_set_scanning (NMDeviceWifi *self, gboolean do_reset)
|
||||||
static GPtrArray *
|
static GPtrArray *
|
||||||
ssids_options_to_ptrarray (GVariant *value, GError **error)
|
ssids_options_to_ptrarray (GVariant *value, GError **error)
|
||||||
{
|
{
|
||||||
GPtrArray *ssids = NULL;
|
gs_unref_ptrarray GPtrArray *ssids = NULL;
|
||||||
const guint8 *bytes;
|
gsize num_ssids;
|
||||||
gsize len;
|
gsize i;
|
||||||
int num_ssids, i;
|
|
||||||
|
|
||||||
nm_assert (g_variant_is_of_type (value, G_VARIANT_TYPE ("aay")));
|
nm_assert (g_variant_is_of_type (value, G_VARIANT_TYPE ("aay")));
|
||||||
|
|
||||||
|
|
@ -1094,6 +1093,8 @@ ssids_options_to_ptrarray (GVariant *value, GError **error)
|
||||||
ssids = g_ptr_array_new_full (num_ssids, (GDestroyNotify) g_bytes_unref);
|
ssids = g_ptr_array_new_full (num_ssids, (GDestroyNotify) g_bytes_unref);
|
||||||
for (i = 0; i < num_ssids; i++) {
|
for (i = 0; i < num_ssids; i++) {
|
||||||
gs_unref_variant GVariant *v = NULL;
|
gs_unref_variant GVariant *v = NULL;
|
||||||
|
gsize len;
|
||||||
|
const guint8 *bytes;
|
||||||
|
|
||||||
v = g_variant_get_child_value (value, i);
|
v = g_variant_get_child_value (value, i);
|
||||||
bytes = g_variant_get_fixed_array (v, &len, sizeof (guint8));
|
bytes = g_variant_get_fixed_array (v, &len, sizeof (guint8));
|
||||||
|
|
@ -1101,15 +1102,15 @@ ssids_options_to_ptrarray (GVariant *value, GError **error)
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
NM_DEVICE_ERROR,
|
NM_DEVICE_ERROR,
|
||||||
NM_DEVICE_ERROR_NOT_ALLOWED,
|
NM_DEVICE_ERROR_NOT_ALLOWED,
|
||||||
"SSID at index %d more than 32 bytes", i);
|
"SSID at index %d more than 32 bytes", (int) i);
|
||||||
g_ptr_array_unref (ssids);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ptr_array_add (ssids, g_bytes_new (bytes, len));
|
g_ptr_array_add (ssids, g_bytes_new (bytes, len));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ssids;
|
|
||||||
|
return g_steal_pointer (&ssids);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPtrArray *
|
GPtrArray *
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue