cinterion: 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
b44f1b6da0
commit
344d96af44
@@ -85,10 +85,15 @@ load_connection_status_finish (MMBaseBearer *bearer,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
GError *inner_error = NULL;
|
||||
gssize aux;
|
||||
|
||||
aux = g_task_propagate_int (G_TASK (res), error);
|
||||
return (aux < 0 ? MM_BEARER_CONNECTION_STATUS_UNKNOWN : (MMBearerConnectionStatus) aux);
|
||||
aux = g_task_propagate_int (G_TASK (res), &inner_error);
|
||||
if (inner_error) {
|
||||
g_propagate_error (error, inner_error);
|
||||
return MM_BEARER_CONNECTION_STATUS_UNKNOWN;
|
||||
}
|
||||
return (MMBearerConnectionStatus) aux;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -582,10 +582,14 @@ load_access_technologies_finish (MMIfaceModem *self,
|
||||
guint *mask,
|
||||
GError **error)
|
||||
{
|
||||
GError *inner_error = NULL;
|
||||
gssize val;
|
||||
|
||||
if ((val = g_task_propagate_int (G_TASK (res), error)) < 0)
|
||||
val = g_task_propagate_int (G_TASK (res), &inner_error);
|
||||
if (inner_error) {
|
||||
g_propagate_error (error, inner_error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*access_technologies = (MMModemAccessTechnology) val;
|
||||
*mask = MM_MODEM_ACCESS_TECHNOLOGY_ANY;
|
||||
|
||||
@@ -122,11 +122,14 @@ mm_common_cinterion_location_load_capabilities_finish (MMIfaceModemLocation *se
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
GError *inner_error = NULL;
|
||||
gssize aux;
|
||||
|
||||
if ((aux = g_task_propagate_int (G_TASK (res), error)) < 0)
|
||||
aux = g_task_propagate_int (G_TASK (res), &inner_error);
|
||||
if (inner_error) {
|
||||
g_propagate_error (error, inner_error);
|
||||
return MM_MODEM_LOCATION_SOURCE_NONE;
|
||||
|
||||
}
|
||||
return (MMModemLocationSource) aux;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user