Commit 15f3d9a7 authored by Thomas Haller's avatar Thomas Haller

libnm: fix return value for nm_remote_settings_load_connections() to ignore server result

nm_remote_settings_load_connections() and nm_remote_settings_load_connections_async()
behave inconsistently.

It's unexpected, that a FALSE return value may leave @Error unset.

Note that before commit 22e830f0 ('settings/d-bus: fix boolean
return value of "LoadConnections"'), the server boolean response
would have been bogus anyway (at least for some versions).

Unify the behavior, and ignore the boolean return value.
parent 77620aff
......@@ -1896,8 +1896,16 @@ nm_client_add_connection2_finish (NMClient *client,
* then @failures will be set to a %NULL-terminated array of the
* filenames that failed to load.
*
* Returns: %TRUE if NetworkManager at least tried to load @filenames,
* %FALSE if an error occurred (eg, permission denied).
* Returns: %TRUE on success.
*
* Warning: before libnm 1.22, the boolean return value was inconsistent.
* That is made worse, because before 1.20, the server would wrongly return
* a boolean value that indicates success/failure. This means, if you use
* this function before 1.22, you are advised to ignore the boolean return
* value and only look at @failures and @error.
* With libnm >= 1.22, the boolean value corresponds to whether @error was
* set. Note that in that case, you still can have @failures.
* With 1.22, the return value is also consistent with nm_client_load_connections_finish().
*
* Deprecated: 1.22, use nm_client_load_connections_async() or GDBusConnection
**/
......@@ -1988,8 +1996,9 @@ nm_client_load_connections_async (NMClient *client,
* See nm_client_load_connections() for more details.
*
* Returns: %TRUE if NetworkManager at least tried to load @filenames,
* %FALSE if an error occurred (eg, permission denied).
* Returns: %TRUE on success.
* The boolean value corresponds to whether @error was
* set. Note that in that case, you still can have @failures.
**/
gboolean
nm_client_load_connections_finish (NMClient *client,
......@@ -2005,11 +2014,9 @@ nm_client_load_connections_finish (NMClient *client,
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else {
if (failures)
*failures = g_strdupv (g_simple_async_result_get_op_res_gpointer (simple));
return TRUE;
}
if (failures)
*failures = g_strdupv (g_simple_async_result_get_op_res_gpointer (simple));
return TRUE;
}
/**
......
......@@ -416,9 +416,10 @@ nm_remote_settings_load_connections (NMRemoteSettings *settings,
cancellable, error)) {
if (error && *error)
g_dbus_error_strip_remote_error (*error);
success = FALSE;
return FALSE;
}
return success;
return TRUE;
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment