qmicli,dms: plug memleaks when setting firmware preference
Not a big deal, because qmicli exits after the operation, but anyway.
This commit is contained in:
parent
da8ff1ee7e
commit
4231c03a38
|
@ -2991,13 +2991,27 @@ get_stored_image_delete_ready (QmiClientDms *client,
|
||||||
g_array_unref (pri_image_id.unique_id);
|
g_array_unref (pri_image_id.unique_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
QmiMessageDmsSetFirmwarePreferenceInputListImage modem_image_id;
|
||||||
|
QmiMessageDmsSetFirmwarePreferenceInputListImage pri_image_id;
|
||||||
|
} SetFirmwarePreferenceContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_firmware_preference_context_clear (SetFirmwarePreferenceContext *firmware_preference_ctx)
|
||||||
|
{
|
||||||
|
g_clear_pointer (&firmware_preference_ctx->modem_image_id.unique_id, (GDestroyNotify) g_array_unref);
|
||||||
|
g_free (firmware_preference_ctx->modem_image_id.build_id);
|
||||||
|
|
||||||
|
g_clear_pointer (&firmware_preference_ctx->pri_image_id.unique_id, (GDestroyNotify) g_array_unref);
|
||||||
|
g_free (firmware_preference_ctx->pri_image_id.build_id);
|
||||||
|
}
|
||||||
|
|
||||||
static QmiMessageDmsSetFirmwarePreferenceInput *
|
static QmiMessageDmsSetFirmwarePreferenceInput *
|
||||||
set_firmware_preference_input_create (const gchar *str)
|
set_firmware_preference_input_create (const gchar *str,
|
||||||
|
SetFirmwarePreferenceContext *firmware_preference_ctx)
|
||||||
{
|
{
|
||||||
QmiMessageDmsSetFirmwarePreferenceInput *input;
|
QmiMessageDmsSetFirmwarePreferenceInput *input;
|
||||||
GArray *array;
|
GArray *array;
|
||||||
QmiMessageDmsSetFirmwarePreferenceInputListImage modem_image_id;
|
|
||||||
QmiMessageDmsSetFirmwarePreferenceInputListImage pri_image_id;
|
|
||||||
gchar **split;
|
gchar **split;
|
||||||
|
|
||||||
/* Prepare inputs.
|
/* Prepare inputs.
|
||||||
|
@ -3006,31 +3020,34 @@ set_firmware_preference_input_create (const gchar *str)
|
||||||
*/
|
*/
|
||||||
split = g_strsplit (str, ",", -1);
|
split = g_strsplit (str, ",", -1);
|
||||||
|
|
||||||
modem_image_id.type = QMI_DMS_FIRMWARE_IMAGE_TYPE_MODEM;
|
/* modem unique id is the fixed wildcard string '?_?' matching any pri.
|
||||||
pri_image_id.type = QMI_DMS_FIRMWARE_IMAGE_TYPE_PRI;
|
* modem build id format is "(fwver)_?", matching any carrier */
|
||||||
|
firmware_preference_ctx->modem_image_id.type = QMI_DMS_FIRMWARE_IMAGE_TYPE_MODEM;
|
||||||
modem_image_id.unique_id = g_array_sized_new (FALSE, TRUE, 1, 16);
|
firmware_preference_ctx->modem_image_id.unique_id = g_array_sized_new (FALSE, TRUE, 1, 16);
|
||||||
pri_image_id.unique_id = g_array_sized_new (FALSE, TRUE, 1, 16);
|
g_array_insert_vals (firmware_preference_ctx->modem_image_id.unique_id, 0, "?_?", 3);
|
||||||
|
g_array_set_size (firmware_preference_ctx->modem_image_id.unique_id, 16);
|
||||||
/* modem unique id is the fixed wildcard string '?_?' matching any pri */
|
firmware_preference_ctx->modem_image_id.build_id = g_strdup_printf ("%s_?", split[0]);
|
||||||
g_array_insert_vals (modem_image_id.unique_id, 0, "?_?", 3);
|
|
||||||
g_array_set_size (modem_image_id.unique_id, 16);
|
|
||||||
|
|
||||||
/* modem build id format is "(fwver)_?", matching any carrier */
|
|
||||||
modem_image_id.build_id = g_strdup_printf ("%s_?", split[0]);
|
|
||||||
|
|
||||||
/* pri unique id is the "(config)" input */
|
/* pri unique id is the "(config)" input */
|
||||||
g_array_insert_vals (pri_image_id.unique_id, 0, split[1], strlen (split[1]));
|
firmware_preference_ctx->pri_image_id.type = QMI_DMS_FIRMWARE_IMAGE_TYPE_PRI;
|
||||||
g_array_set_size (pri_image_id.unique_id, 16);
|
firmware_preference_ctx->pri_image_id.unique_id = g_array_sized_new (FALSE, TRUE, 1, 16);
|
||||||
|
g_array_insert_vals (firmware_preference_ctx->pri_image_id.unique_id, 0, split[1], strlen (split[1]));
|
||||||
pri_image_id.build_id = g_strdup_printf ("%s_%s", split[0], split[2]);
|
g_array_set_size (firmware_preference_ctx->pri_image_id.unique_id, 16);
|
||||||
|
firmware_preference_ctx->pri_image_id.build_id = g_strdup_printf ("%s_%s", split[0], split[2]);
|
||||||
|
|
||||||
|
/* Create an array with both images, the contents of each image struct,
|
||||||
|
* though, aren't owned by the array (i.e. need to be disposed afterwards
|
||||||
|
* when no longer used). */
|
||||||
array = g_array_sized_new (FALSE, FALSE, sizeof (QmiMessageDmsSetFirmwarePreferenceInputListImage), 2);
|
array = g_array_sized_new (FALSE, FALSE, sizeof (QmiMessageDmsSetFirmwarePreferenceInputListImage), 2);
|
||||||
g_array_append_val (array, modem_image_id);
|
g_array_append_val (array, firmware_preference_ctx->modem_image_id);
|
||||||
g_array_append_val (array, pri_image_id);
|
g_array_append_val (array, firmware_preference_ctx->pri_image_id);
|
||||||
|
|
||||||
|
/* The input bundle takes a reference to the array itself */
|
||||||
input = qmi_message_dms_set_firmware_preference_input_new ();
|
input = qmi_message_dms_set_firmware_preference_input_new ();
|
||||||
qmi_message_dms_set_firmware_preference_input_set_list (input, array, NULL);
|
qmi_message_dms_set_firmware_preference_input_set_list (input, array, NULL);
|
||||||
|
g_array_unref (array);
|
||||||
|
|
||||||
|
g_strfreev (split);
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
@ -3790,9 +3807,12 @@ qmicli_dms_run (QmiDevice *device,
|
||||||
/* Set firmware preference? */
|
/* Set firmware preference? */
|
||||||
if (set_firmware_preference_str) {
|
if (set_firmware_preference_str) {
|
||||||
QmiMessageDmsSetFirmwarePreferenceInput *input;
|
QmiMessageDmsSetFirmwarePreferenceInput *input;
|
||||||
|
SetFirmwarePreferenceContext firmware_preference_ctx;
|
||||||
|
|
||||||
|
memset (&firmware_preference_ctx, 0, sizeof (firmware_preference_ctx));
|
||||||
|
|
||||||
g_debug ("Asynchronously setting firmware preference...");
|
g_debug ("Asynchronously setting firmware preference...");
|
||||||
input = set_firmware_preference_input_create (set_firmware_preference_str);
|
input = set_firmware_preference_input_create (set_firmware_preference_str, &firmware_preference_ctx);
|
||||||
if (!input) {
|
if (!input) {
|
||||||
operation_shutdown (FALSE);
|
operation_shutdown (FALSE);
|
||||||
return;
|
return;
|
||||||
|
@ -3805,6 +3825,7 @@ qmicli_dms_run (QmiDevice *device,
|
||||||
NULL,
|
NULL,
|
||||||
(GAsyncReadyCallback)select_stored_image_ready,
|
(GAsyncReadyCallback)select_stored_image_ready,
|
||||||
NULL);
|
NULL);
|
||||||
|
set_firmware_preference_context_clear (&firmware_preference_ctx);
|
||||||
qmi_message_dms_set_firmware_preference_input_unref (input);
|
qmi_message_dms_set_firmware_preference_input_unref (input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue