foxconn: switch to use autoptr() in firmware info loading

This commit is contained in:
Aleksander Morgado
2022-03-25 14:01:50 +01:00
parent b81680a3fd
commit 4efb5f61cf

View File

@@ -86,7 +86,7 @@ foxconn_get_firmware_version_over_dms_service_ready (QmiClientDms *client,
GAsyncResult *res,
GTask *task)
{
QmiMessageDmsFoxconnGetFirmwareVersionOutput *output;
g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionOutput) output = NULL;
GError *error = NULL;
MMFirmwareUpdateSettings *update_settings = NULL;
const gchar *str;
@@ -95,8 +95,11 @@ foxconn_get_firmware_version_over_dms_service_ready (QmiClientDms *client,
guint product_id;
output = qmi_client_dms_foxconn_get_firmware_version_finish (client, res, &error);
if (!output || !qmi_message_dms_foxconn_get_firmware_version_output_get_result (output, &error))
goto out;
if (!output || !qmi_message_dms_foxconn_get_firmware_version_output_get_result (output, &error)) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
/* Create update settings now:
* 0x105b is the T99W175 module, T99W175 supports QDU,
@@ -113,20 +116,11 @@ foxconn_get_firmware_version_over_dms_service_ready (QmiClientDms *client,
MM_MODEM_FIRMWARE_UPDATE_METHOD_QMI_PDC);
mm_firmware_update_settings_set_fastboot_at (update_settings, "AT^FASTBOOT");
}
qmi_message_dms_foxconn_get_firmware_version_output_get_version (output, &str, NULL);
mm_firmware_update_settings_set_version (update_settings, str);
out:
if (error)
g_task_return_error (task, error);
else {
g_assert (update_settings);
g_task_return_pointer (task, update_settings, g_object_unref);
}
g_object_unref (task);
if (output)
qmi_message_dms_foxconn_get_firmware_version_output_unref (output);
}
static void
@@ -134,7 +128,7 @@ foxconn_get_firmware_version_over_fox_service_ready (QmiClientFox *client,
GAsyncResult *res,
GTask *task)
{
QmiMessageFoxGetFirmwareVersionOutput *output;
g_autoptr(QmiMessageFoxGetFirmwareVersionOutput) output = NULL;
GError *error = NULL;
MMFirmwareUpdateSettings *update_settings = NULL;
const gchar *str;
@@ -143,8 +137,11 @@ foxconn_get_firmware_version_over_fox_service_ready (QmiClientFox *client,
guint product_id;
output = qmi_client_fox_get_firmware_version_finish (client, res, &error);
if (!output || !qmi_message_fox_get_firmware_version_output_get_result (output, &error))
goto out;
if (!output || !qmi_message_fox_get_firmware_version_output_get_result (output, &error)) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
/* Create update settings now:
* 0x105b is the T99W175 module, T99W175 supports QDU,
@@ -165,23 +162,15 @@ foxconn_get_firmware_version_over_fox_service_ready (QmiClientFox *client,
qmi_message_fox_get_firmware_version_output_get_version (output, &str, NULL);
mm_firmware_update_settings_set_version (update_settings, str);
out:
if (error)
g_task_return_error (task, error);
else {
g_assert (update_settings);
g_task_return_pointer (task, update_settings, g_object_unref);
}
g_object_unref (task);
if (output)
qmi_message_fox_get_firmware_version_output_unref (output);
}
static void
firmware_load_update_settings_over_dms_service (MMIfaceModemFirmware *self,
GTask *task)
{
QmiMessageDmsFoxconnGetFirmwareVersionInput *input = NULL;
g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionInput) input = NULL;
QmiClient *client = NULL;
guint vendor_id;
guint product_id;
@@ -218,7 +207,6 @@ firmware_load_update_settings_over_dms_service (MMIfaceModemFirmware *self,
NULL,
(GAsyncReadyCallback)foxconn_get_firmware_version_over_dms_service_ready,
task);
qmi_message_dms_foxconn_get_firmware_version_input_unref (input);
}
static void
@@ -227,7 +215,7 @@ firmware_load_update_settings (MMIfaceModemFirmware *self,
gpointer user_data)
{
GTask *task;
QmiMessageFoxGetFirmwareVersionInput *input = NULL;
g_autoptr(QmiMessageFoxGetFirmwareVersionInput) input = NULL;
QmiClient *client = NULL;
guint vendor_id;
guint product_id;
@@ -265,7 +253,6 @@ firmware_load_update_settings (MMIfaceModemFirmware *self,
NULL,
(GAsyncReadyCallback)foxconn_get_firmware_version_over_fox_service_ready,
task);
qmi_message_fox_get_firmware_version_input_unref (input);
}
#endif