broadband-bearer: check error returned by g_task_propagate_error instead
When returning an enum value via g_task_return_int, some code assumes the enum value is always non-negative and thus considers that a negative value implies an error. This assumption could be invalidated if a negative value is later added to the enum. To make it less error prone to future changes, this patch modifies the code to check if the GError argument to g_task_propagate_error is populated instead.
This commit is contained in:

committed by
Aleksander Morgado

parent
22e5b216cb
commit
a36347eff7
@@ -1995,10 +1995,15 @@ load_connection_status_finish (MMBaseBearer *bearer,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
GError *inner_error = NULL;
|
||||||
gssize value;
|
gssize value;
|
||||||
|
|
||||||
value = g_task_propagate_int (G_TASK (res), error);
|
value = g_task_propagate_int (G_TASK (res), &inner_error);
|
||||||
return (value < 0 ? MM_BEARER_CONNECTION_STATUS_UNKNOWN : (MMBearerConnectionStatus) value);
|
if (inner_error) {
|
||||||
|
g_propagate_error (error, inner_error);
|
||||||
|
return MM_BEARER_CONNECTION_STATUS_UNKNOWN;
|
||||||
|
}
|
||||||
|
return (MMBearerConnectionStatus)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user