[PATCH 2/2] plugin: check error returned by g_task_propagate_error instead
Aleksander Morgado
aleksander at aleksander.es
Fri Jul 7 08:24:44 UTC 2017
On 06/07/17 20:30, Ben Chan wrote:
> mm_plugin_supports_port_finish directly casts the value returned by
> g_task_propagate_int to MMPluginSupportsResult enum value, which
> implicitly assumes MM_PLUGIN_SUPPORTS_PORT_UNKNOWN equals to -1.
> Instead of relying on such an implicit assumption, this patch modifies
> the code to check if the GError argument to g_task_propagate_error is
> populated instead.
> ---
> src/mm-plugin.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
Pushed to git master, thanks!
> diff --git a/src/mm-plugin.c b/src/mm-plugin.c
> index af4bc739..d2fa4a11 100644
> --- a/src/mm-plugin.c
> +++ b/src/mm-plugin.c
> @@ -666,10 +666,18 @@ mm_plugin_supports_port_finish (MMPlugin *self,
> GAsyncResult *result,
> GError **error)
> {
> + GError *inner_error = NULL;
> + gssize value;
> +
> g_return_val_if_fail (MM_IS_PLUGIN (self), MM_PLUGIN_SUPPORTS_PORT_UNKNOWN);
> g_return_val_if_fail (G_IS_TASK (result), MM_PLUGIN_SUPPORTS_PORT_UNKNOWN);
>
> - return (MMPluginSupportsResult) g_task_propagate_int (G_TASK (result), error);
> + value = g_task_propagate_int (G_TASK (result), &inner_error);
> + if (inner_error) {
> + g_propagate_error (error, inner_error);
> + return MM_PLUGIN_SUPPORTS_PORT_UNKNOWN;
> + }
> + return (MMPluginSupportsResult)value;
> }
>
> void
>
--
Aleksander
https://aleksander.es
More information about the ModemManager-devel
mailing list