diff options
author | Thomas Haller <thaller@redhat.com> | 2020-03-10 20:01:00 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-03-16 13:40:51 +0100 |
commit | 49dacaa34e69ab35f2f2cd508d7c4c52770e4319 (patch) | |
tree | 8eca21696900daae5f7ab2e664c6e74bf12b20eb | |
parent | 30cf1885d4c3f6e348ce6a7d4189cad4c16e4c63 (diff) | |
download | NetworkManager-49dacaa34e69ab35f2f2cd508d7c4c52770e4319.tar.gz |
cli: use slice allocator in do_device_wifi_list() and designated initializers for data
-rw-r--r-- | clients/cli/devices.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/clients/cli/devices.c b/clients/cli/devices.c index 548a381f29..8b58f08c5f 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -2921,14 +2921,14 @@ wifi_list_finish (WifiListData *data) g_signal_handler_disconnect (data->wifi, data->last_scan_id); nm_clear_g_source (&data->timeout_id); nm_clear_g_cancellable (&data->scan_cancellable); - g_slice_free (WifiListData, data); + nm_g_slice_free (data); if (info->nmc->should_wait == 0) { for (i = 0; info->devices[i]; i++) g_object_unref (info->devices[i]); g_free (info->devices); g_array_unref (info->out_indices); - g_free (info); + nm_g_slice_free (info); } } @@ -3149,25 +3149,36 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv) g_object_ref (wifi); if ( rescan_cutoff == 0 - || (rescan_cutoff > 0 && nm_device_wifi_get_last_scan (wifi) >= rescan_cutoff)) + || ( rescan_cutoff > 0 + && nm_device_wifi_get_last_scan (wifi) >= rescan_cutoff)) continue; if (!scan_info) { - scan_info = g_new0 (ScanInfo, 1); - scan_info->out_indices = g_array_ref (out_indices); - scan_info->tmpl = tmpl; - scan_info->bssid_user = bssid_user; - scan_info->nmc = nmc; + scan_info = g_slice_new (ScanInfo); + *scan_info = (ScanInfo) { + .out_indices = g_array_ref (out_indices), + .tmpl = tmpl, + .bssid_user = bssid_user, + .nmc = nmc, + }; } nmc->should_wait++; - data = g_slice_new0 (WifiListData); - data->wifi = wifi; - data->scan_info = scan_info; - data->last_scan_id = g_signal_connect (wifi, "notify::" NM_DEVICE_WIFI_LAST_SCAN, - G_CALLBACK (wifi_last_scan_updated), data); - data->scan_cancellable = g_cancellable_new (); - data->timeout_id = g_timeout_add_seconds (15, wifi_list_scan_timeout, data); + + data = g_slice_new (WifiListData); + *data = (WifiListData) { + .wifi = wifi, + .scan_info = scan_info, + .last_scan_id = g_signal_connect (wifi, + "notify::" NM_DEVICE_WIFI_LAST_SCAN, + G_CALLBACK (wifi_last_scan_updated), + data), + .scan_cancellable = g_cancellable_new (), + .timeout_id = g_timeout_add_seconds (15, + wifi_list_scan_timeout, + data), + }; + nm_device_wifi_request_scan_async (wifi, data->scan_cancellable, wifi_list_rescan_cb, data); } |