diff options
author | Thomas Haller <thaller@redhat.com> | 2020-01-04 11:44:47 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-01-08 11:23:24 +0100 |
commit | e6d256fe817293c82cfae60f9e7dc74db791a241 (patch) | |
tree | a38d2da1a3a74d568c2f82dd1827030d8c91e8a5 | |
parent | 023dc9646c468d276aac78bf4249a9dd80da6772 (diff) | |
download | NetworkManager-e6d256fe817293c82cfae60f9e7dc74db791a241.tar.gz |
device/wifi: cleanup ssids_options_to_ptrarray()th/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
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index f4413029ec..f334858cb4 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -1074,10 +1074,9 @@ _hw_addr_set_scanning (NMDeviceWifi *self, gboolean do_reset) static GPtrArray * ssids_options_to_ptrarray (GVariant *value, GError **error) { - GPtrArray *ssids = NULL; - const guint8 *bytes; - gsize len; - int num_ssids, i; + gs_unref_ptrarray GPtrArray *ssids = NULL; + gsize num_ssids; + gsize i; 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); for (i = 0; i < num_ssids; i++) { gs_unref_variant GVariant *v = NULL; + gsize len; + const guint8 *bytes; v = g_variant_get_child_value (value, i); 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, NM_DEVICE_ERROR, NM_DEVICE_ERROR_NOT_ALLOWED, - "SSID at index %d more than 32 bytes", i); - g_ptr_array_unref (ssids); + "SSID at index %d more than 32 bytes", (int) i); return NULL; } g_ptr_array_add (ssids, g_bytes_new (bytes, len)); } } - return ssids; + + return g_steal_pointer (&ssids); } GPtrArray * |