mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 06:00:32 +01:00
libnm,client: use nm_g_task_new() to set source-tag and check it
Public API should validate input arguments with g_return_*(). Tag the task with the source function (using nm_g_task_new()) and check it in the corresponding _finish() function.
This commit is contained in:
parent
03633fef42
commit
ba2e1d52ad
2 changed files with 9 additions and 4 deletions
|
|
@ -1296,8 +1296,7 @@ nmc_do_cmd (NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, char
|
|||
const NMCCommand *c;
|
||||
gs_unref_object GTask *task = NULL;
|
||||
|
||||
task = g_task_new (NULL, NULL, command_done, nmc);
|
||||
g_task_set_source_tag (task, nmc_do_cmd);
|
||||
task = nm_g_task_new (NULL, NULL, nmc_do_cmd, command_done, nmc);
|
||||
g_task_set_task_data (task, nmc, NULL);
|
||||
|
||||
if (argc == 0 && nmc->complete) {
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ nm_device_wifi_p2p_start_find (NMDeviceWifiP2P *device,
|
|||
|
||||
g_return_if_fail (NM_IS_DEVICE_WIFI_P2P (device));
|
||||
|
||||
task = g_task_new (device, cancellable, callback, user_data);
|
||||
task = nm_g_task_new (device, cancellable, nm_device_wifi_p2p_start_find, callback, user_data);
|
||||
|
||||
if (!options)
|
||||
options = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0);
|
||||
|
|
@ -211,6 +211,9 @@ nm_device_wifi_p2p_start_find_finish (NMDeviceWifiP2P *device,
|
|||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIFI_P2P (device), FALSE);
|
||||
g_return_val_if_fail (nm_g_task_is_valid (result, device, nm_device_wifi_p2p_start_find), FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +256,7 @@ nm_device_wifi_p2p_stop_find (NMDeviceWifiP2P *device,
|
|||
|
||||
g_return_if_fail (NM_IS_DEVICE_WIFI_P2P (device));
|
||||
|
||||
task = g_task_new (device, cancellable, callback, user_data);
|
||||
task = nm_g_task_new (device, cancellable, nm_device_wifi_p2p_stop_find, callback, user_data);
|
||||
|
||||
nmdbus_device_wifi_p2p_call_stop_find (priv->proxy,
|
||||
cancellable,
|
||||
|
|
@ -278,6 +281,9 @@ nm_device_wifi_p2p_stop_find_finish (NMDeviceWifiP2P *device,
|
|||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIFI_P2P (device), FALSE);
|
||||
g_return_val_if_fail (nm_g_task_is_valid (result, device, nm_device_wifi_p2p_stop_find), FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue