broadband-modem-qmi: avoid NULL success return in firmware_load_current
Instead of assuming that NULL is a valid return, make sure we return an error instead. This also makes it sure that if the GTask gets cancelled, the result we set is always a valid GObject, so that the g_object_unref passed as GDestroyNotify can be safely called always. Not a big deal anyway, as the GTask cannot be currently cancelled.
This commit is contained in:
@@ -10383,10 +10383,13 @@ firmware_load_current (MMIfaceModemFirmware *_self,
|
|||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
task = g_task_new (self, NULL, callback, user_data);
|
task = g_task_new (self, NULL, callback, user_data);
|
||||||
g_task_return_pointer (
|
if (self->priv->current_firmware)
|
||||||
task,
|
g_task_return_pointer (task,
|
||||||
self->priv->current_firmware ? g_object_ref (self->priv->current_firmware) : NULL,
|
g_object_ref (self->priv->current_firmware),
|
||||||
g_object_unref);
|
g_object_unref);
|
||||||
|
else
|
||||||
|
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND,
|
||||||
|
"current firmware unknown");
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -68,12 +68,16 @@ load_current_ready (MMIfaceModemFirmware *self,
|
|||||||
GList *l;
|
GList *l;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
/* reported current may be NULL and we don't treat it as error */
|
|
||||||
ctx->current = MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_current_finish (self, res, &error);
|
ctx->current = MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_current_finish (self, res, &error);
|
||||||
if (error) {
|
if (!ctx->current) {
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
/* Not found isn't fatal */
|
||||||
handle_list_context_free (ctx);
|
if (!g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND)) {
|
||||||
return;
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_list_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mm_dbg ("Couldn't load current firmware image: %s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build array of dicts */
|
/* Build array of dicts */
|
||||||
|
Reference in New Issue
Block a user