aboutsummaryrefslogtreecommitdiff
path: root/src/mm-plugin.c
diff options
context:
space:
mode:
authorBen Chan <benchan@chromium.org>2017-07-06 11:30:21 -0700
committerAleksander Morgado <aleksander@aleksander.es>2017-07-07 10:23:46 +0200
commit627ef274dff34f8e47425529cb3a7534dd47563f (patch)
tree61680b31c87e13f597ff5c86053a1b8bc15ec0d4 /src/mm-plugin.c
parenta36347eff794bb5d8c1b4e641a56aa70d7a0ef8c (diff)
plugin: check error returned by g_task_propagate_error instead
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.
Diffstat (limited to 'src/mm-plugin.c')
-rw-r--r--src/mm-plugin.c10
1 files changed, 9 insertions, 1 deletions
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