diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2022-02-22 22:33:47 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2022-02-26 22:23:54 +0100 |
commit | fae9829477adbbce1b42c438a8c233990ee385e3 (patch) | |
tree | 55e3924f88a252d507deaaacb4d75502d55e1f0b /src | |
parent | dfab19fdec8d2bf84bdd9975618750330b0bf6d3 (diff) | |
download | libqmi-fae9829477adbbce1b42c438a8c233990ee385e3.tar.gz |
qmicli,pdc: port to use autoptr()
Diffstat (limited to 'src')
-rw-r--r-- | src/qmicli/qmicli-pdc.c | 267 |
1 files changed, 93 insertions, 174 deletions
diff --git a/src/qmicli/qmicli-pdc.c b/src/qmicli/qmicli-pdc.c index 76bba66d..3cb77a99 100644 --- a/src/qmicli/qmicli-pdc.c +++ b/src/qmicli/qmicli-pdc.c @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * Copyright (C) 2013-2020 Aleksander Morgado <aleksander@aleksander.es> + * Copyright (C) 2013-2022 Aleksander Morgado <aleksander@aleksander.es> */ #include "config.h" @@ -395,56 +395,48 @@ static void get_config_info_ready (QmiClientPdc *client, GAsyncResult *res) { - GError *error = NULL; - QmiMessagePdcGetConfigInfoOutput *output; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcGetConfigInfoOutput) output = NULL; output = qmi_client_pdc_get_config_info_finish (client, res, &error); if (!output) { g_printerr ("error: operation failed: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (!qmi_message_pdc_get_config_info_output_get_result (output, &error)) { g_printerr ("error: couldn't get config info: %s\n", error->message); - g_error_free (error); - qmi_message_pdc_get_config_info_output_unref (output); operation_shutdown (FALSE); return; } - - qmi_message_pdc_get_config_info_output_unref (output); } static void -get_config_info_ready_indication (QmiClientPdc *client, +get_config_info_ready_indication (QmiClientPdc *client, QmiIndicationPdcGetConfigInfoOutput *output) { - GError *error = NULL; - ConfigInfo *current_config = NULL; - guint32 token; - const gchar *description; - guint i; - guint16 error_code = 0; + g_autoptr(GError) error = NULL; + ConfigInfo *current_config = NULL; + guint32 token; + const gchar *description; + guint i; + guint16 error_code = 0; if (!qmi_indication_pdc_get_config_info_output_get_indication_result (output, &error_code, &error)) { g_printerr ("error: couldn't get config info: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (error_code != 0) { - g_printerr ("error: couldn't get config info: %s\n", - qmi_protocol_error_get_string ((QmiProtocolError) error_code)); + g_printerr ("error: couldn't get config info: %s\n", qmi_protocol_error_get_string ((QmiProtocolError) error_code)); operation_shutdown (FALSE); return; } if (!qmi_indication_pdc_get_config_info_output_get_token (output, &token, &error)) { g_printerr ("error: couldn't get config info token: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } @@ -465,7 +457,6 @@ get_config_info_ready_indication (QmiClientPdc *client, &error) || !qmi_indication_pdc_get_config_info_output_get_description (output, &description, &error)) { g_printerr ("error: couldn't get config info details: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } @@ -489,7 +480,7 @@ list_configs_timeout (void) } static void -list_configs_ready_indication (QmiClientPdc *client, +list_configs_ready_indication (QmiClientPdc *client, QmiIndicationPdcListConfigsOutput *output) { g_autoptr(GError) error = NULL; @@ -570,34 +561,29 @@ static void list_configs_ready (QmiClientPdc *client, GAsyncResult *res) { - GError *error = NULL; - QmiMessagePdcListConfigsOutput *output; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcListConfigsOutput) output = NULL; output = qmi_client_pdc_list_configs_finish (client, res, &error); if (!output) { g_printerr ("error: operation failed: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (!qmi_message_pdc_list_configs_output_get_result (output, &error)) { g_printerr ("error: couldn't list configs: %s\n", error->message); - g_error_free (error); - qmi_message_pdc_list_configs_output_unref (output); operation_shutdown (FALSE); return; } - - qmi_message_pdc_list_configs_output_unref (output); } static QmiMessagePdcListConfigsInput * list_configs_input_create (const gchar *str) { - QmiMessagePdcListConfigsInput *input = NULL; - QmiPdcConfigurationType config_type; - GError *error = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcListConfigsInput) input = NULL; + QmiPdcConfigurationType config_type; if (!qmicli_read_pdc_configuration_type_from_string (str, &config_type)) return NULL; @@ -606,32 +592,28 @@ list_configs_input_create (const gchar *str) if (!qmi_message_pdc_list_configs_input_set_config_type (input, config_type, &error) || !qmi_message_pdc_list_configs_input_set_token (input, ctx->token++, &error)) { g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message); - g_error_free (error); - qmi_message_pdc_list_configs_input_unref (input); return NULL; } - return input; + return g_steal_pointer (&input); } static void -get_selected_config_ready_indication (QmiClientPdc *client, +get_selected_config_ready_indication (QmiClientPdc *client, QmiIndicationPdcGetSelectedConfigOutput *output) { - GArray *pending_id = NULL; - GArray *active_id = NULL; - GError *error = NULL; - guint16 error_code = 0; + g_autoptr(GError) error = NULL; + GArray *pending_id = NULL; + GArray *active_id = NULL; + guint16 error_code = 0; if (!qmi_indication_pdc_get_selected_config_output_get_indication_result (output, &error_code, &error)) { g_printerr ("error: couldn't get selected config: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } - if (error_code != 0 && - error_code != QMI_PROTOCOL_ERROR_NOT_PROVISIONED) { /* No configs active */ + if (error_code != 0 && error_code != QMI_PROTOCOL_ERROR_NOT_PROVISIONED) { /* No configs active */ g_printerr ("error: couldn't get selected config: %s\n", qmi_protocol_error_get_string ((QmiProtocolError) error_code)); operation_shutdown (FALSE); @@ -654,27 +636,23 @@ static void get_selected_config_ready (QmiClientPdc *client, GAsyncResult *res) { - GError *error = NULL; - QmiMessagePdcGetSelectedConfigOutput *output; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcGetSelectedConfigOutput) output = NULL; output = qmi_client_pdc_get_selected_config_finish (client, res, &error); if (!qmi_message_pdc_get_selected_config_output_get_result (output, &error)) { g_printerr ("error: couldn't get selected config: %s\n", error->message); - g_error_free (error); - qmi_message_pdc_get_selected_config_output_unref (output); operation_shutdown (FALSE); return; } - - qmi_message_pdc_get_selected_config_output_unref (output); } static QmiMessagePdcGetSelectedConfigInput * get_selected_config_input_create (const gchar *str) { - QmiMessagePdcGetSelectedConfigInput *input = NULL; - QmiPdcConfigurationType config_type; - GError *error = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcGetSelectedConfigInput) input = NULL; + QmiPdcConfigurationType config_type; if (!qmicli_read_pdc_configuration_type_from_string (str, &config_type)) return NULL; @@ -683,19 +661,17 @@ get_selected_config_input_create (const gchar *str) if (!qmi_message_pdc_get_selected_config_input_set_config_type (input, config_type, &error) || !qmi_message_pdc_get_selected_config_input_set_token (input, ctx->token++, &error)) { g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message); - g_error_free (error); - qmi_message_pdc_get_selected_config_input_unref (input); return NULL; } - return input; + return g_steal_pointer (&input); } static void run_list_configs (void) { - QmiMessagePdcListConfigsInput *input; - QmiMessagePdcGetSelectedConfigInput *get_selected_config_input; + g_autoptr(QmiMessagePdcListConfigsInput) input = NULL; + g_autoptr(QmiMessagePdcGetSelectedConfigInput) get_selected_config_input = NULL; g_debug ("Listing configs asynchronously..."); @@ -736,7 +712,6 @@ run_list_configs (void) ctx->cancellable, (GAsyncReadyCallback) list_configs_ready, NULL); - qmi_message_pdc_list_configs_input_unref (input); qmi_client_pdc_get_selected_config (ctx->client, get_selected_config_input, @@ -744,7 +719,6 @@ run_list_configs (void) ctx->cancellable, (GAsyncReadyCallback) get_selected_config_ready, NULL); - qmi_message_pdc_get_selected_config_input_unref (get_selected_config_input); } #endif /* HAVE_QMI_ACTION_PDC_LIST_CONFIGS */ @@ -769,22 +743,20 @@ device_removed_indication (QmiDevice *device) } static void -activate_config_ready_indication (QmiClientPdc *client, +activate_config_ready_indication (QmiClientPdc *client, QmiIndicationPdcActivateConfigOutput *output) { - GError *error = NULL; - guint16 error_code = 0; + g_autoptr(GError) error = NULL; + guint16 error_code = 0; if (!qmi_indication_pdc_activate_config_output_get_indication_result (output, &error_code, &error)) { g_printerr ("error: couldn't activate config: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (error_code != 0) { - g_printerr ("error: couldn't activate config: %s\n", - qmi_protocol_error_get_string ((QmiProtocolError) error_code)); + g_printerr ("error: couldn't activate config: %s\n", qmi_protocol_error_get_string ((QmiProtocolError) error_code)); operation_shutdown (FALSE); return; } @@ -802,26 +774,21 @@ static void activate_config_ready (QmiClientPdc *client, GAsyncResult *res) { - GError *error = NULL; - QmiMessagePdcActivateConfigOutput *output; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcActivateConfigOutput) output = NULL; output = qmi_client_pdc_activate_config_finish (client, res, &error); if (!output) { g_printerr ("error: operation failed: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (!qmi_message_pdc_activate_config_output_get_result (output, &error)) { g_printerr ("error: couldn't activate config: %s\n", error->message); - g_error_free (error); - qmi_message_pdc_activate_config_output_unref (output); operation_shutdown (FALSE); return; } - - qmi_message_pdc_activate_config_output_unref (output); } static QmiMessagePdcActivateConfigInput * @@ -847,16 +814,15 @@ activate_config_input_create (const gchar *str) } static void -set_selected_config_ready_indication (QmiClientPdc *client, +set_selected_config_ready_indication (QmiClientPdc *client, QmiIndicationPdcSetSelectedConfigOutput *output) { - GError *error = NULL; - QmiMessagePdcActivateConfigInput *input; - guint16 error_code = 0; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcActivateConfigInput) input = NULL; + guint16 error_code = 0; if (!qmi_indication_pdc_set_selected_config_output_get_indication_result (output, &error_code, &error)) { g_printerr ("error: couldn't set selected config: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } @@ -889,25 +855,21 @@ set_selected_config_ready_indication (QmiClientPdc *client, 10, ctx->cancellable, (GAsyncReadyCallback) activate_config_ready, NULL); - qmi_message_pdc_activate_config_input_unref (input); } static void set_selected_config_ready (QmiClientPdc *client, GAsyncResult *res) { - GError *error = NULL; - QmiMessagePdcSetSelectedConfigOutput *output; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcSetSelectedConfigOutput) output = NULL; output = qmi_client_pdc_set_selected_config_finish (client, res, &error); if (!output) { g_printerr ("error: operation failed: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } - - qmi_message_pdc_set_selected_config_output_unref (output); } static QmiMessagePdcSetSelectedConfigInput * @@ -934,7 +896,7 @@ set_selected_config_input_create (const gchar *str) static void run_activate_config (void) { - QmiMessagePdcSetSelectedConfigInput *input; + g_autoptr(QmiMessagePdcSetSelectedConfigInput) input = NULL; g_debug ("Activating config asynchronously..."); input = set_selected_config_input_create (activate_config_str); @@ -954,7 +916,6 @@ run_activate_config (void) ctx->cancellable, (GAsyncReadyCallback) set_selected_config_ready, NULL); - qmi_message_pdc_set_selected_config_input_unref (input); } #endif /* HAVE_QMI_ACTION_PDC_ACTIVATE_CONFIG */ @@ -965,22 +926,20 @@ run_activate_config (void) #if defined HAVE_QMI_ACTION_PDC_DEACTIVATE_CONFIG static void -deactivate_config_ready_indication (QmiClientPdc *client, +deactivate_config_ready_indication (QmiClientPdc *client, QmiIndicationPdcDeactivateConfigOutput *output) { - GError *error = NULL; - guint16 error_code = 0; + g_autoptr(GError) error = NULL; + guint16 error_code = 0; if (!qmi_indication_pdc_deactivate_config_output_get_indication_result (output, &error_code, &error)) { g_printerr ("error: couldn't deactivate config: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (error_code != 0) { - g_printerr ("error: couldn't deactivate config: %s\n", - qmi_protocol_error_get_string ((QmiProtocolError) error_code)); + g_printerr ("error: couldn't deactivate config: %s\n", qmi_protocol_error_get_string ((QmiProtocolError) error_code)); operation_shutdown (FALSE); return; } @@ -995,26 +954,21 @@ static void deactivate_config_ready (QmiClientPdc *client, GAsyncResult *res) { - GError *error = NULL; - QmiMessagePdcDeactivateConfigOutput *output; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcDeactivateConfigOutput) output = NULL; output = qmi_client_pdc_deactivate_config_finish (client, res, &error); if (!output) { g_printerr ("error: operation failed: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (!qmi_message_pdc_deactivate_config_output_get_result (output, &error)) { g_printerr ("error: couldn't deactivate config: %s\n", error->message); - g_error_free (error); - qmi_message_pdc_deactivate_config_output_unref (output); operation_shutdown (FALSE); return; } - - qmi_message_pdc_deactivate_config_output_unref (output); } static QmiMessagePdcDeactivateConfigInput * @@ -1042,7 +996,7 @@ deactivate_config_input_create (const gchar *str) static void run_deactivate_config (void) { - QmiMessagePdcDeactivateConfigInput *input; + g_autoptr(QmiMessagePdcDeactivateConfigInput) input = NULL; g_debug ("Deactivating config asynchronously..."); input = deactivate_config_input_create (deactivate_config_str); @@ -1064,7 +1018,6 @@ run_deactivate_config (void) 10, ctx->cancellable, (GAsyncReadyCallback) deactivate_config_ready, NULL); - qmi_message_pdc_deactivate_config_input_unref (input); } #endif /* HAVE_QMI_ACTION_PDC_DEACTIVATE_CONFIG */ @@ -1078,21 +1031,18 @@ static void delete_config_ready (QmiClientPdc *client, GAsyncResult *res) { - GError *error = NULL; - QmiMessagePdcDeleteConfigOutput *output; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcDeleteConfigOutput) output = NULL; output = qmi_client_pdc_delete_config_finish (client, res, &error); if (!output) { g_printerr ("error: operation failed: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (!qmi_message_pdc_delete_config_output_get_result (output, &error)) { g_printerr ("error: couldn't delete config: %s\n", error->message); - g_error_free (error); - qmi_message_pdc_delete_config_output_unref (output); operation_shutdown (FALSE); return; } @@ -1100,7 +1050,6 @@ delete_config_ready (QmiClientPdc *client, g_print ("[%s] Successfully deleted config\n", qmi_device_get_path_display (ctx->device)); - qmi_message_pdc_delete_config_output_unref (output); operation_shutdown (TRUE); } @@ -1129,7 +1078,7 @@ delete_config_input_create (const gchar *str) static void run_delete_config (void) { - QmiMessagePdcDeleteConfigInput *input; + g_autoptr(QmiMessagePdcDeleteConfigInput) input = NULL; g_debug ("Deleting config asynchronously..."); input = delete_config_input_create (delete_config_str); @@ -1143,7 +1092,6 @@ run_delete_config (void) 10, ctx->cancellable, (GAsyncReadyCallback) delete_config_ready, NULL); - qmi_message_pdc_delete_config_input_unref (input); } #endif /* HAVE_QMI_MESSAGE_PDC_DELETE_CONFIG */ @@ -1156,23 +1104,21 @@ run_delete_config (void) static LoadConfigFileData * load_config_file_from_string (const gchar *str) { - GError *error = NULL; - GMappedFile *mapped_file; - LoadConfigFileData *data; - guchar *file_contents; - GChecksum *checksum; - gsize file_size; - gsize hash_size; + g_autoptr(GError) error = NULL; + g_autoptr(GMappedFile) mapped_file = NULL; + LoadConfigFileData *data; + guchar *file_contents; + GChecksum *checksum; + gsize file_size; + gsize hash_size; if (!(mapped_file = g_mapped_file_new (str, FALSE, &error))) { g_printerr ("error: couldn't map config file: '%s'\n", error->message); - g_error_free (error); return NULL; } if (!(file_contents = (guchar *) g_mapped_file_get_contents (mapped_file))) { g_printerr ("error: couldn't get file content\n"); - g_mapped_file_unref (mapped_file); return NULL; } @@ -1183,11 +1129,12 @@ load_config_file_from_string (const gchar *str) g_checksum_update (checksum, file_contents, file_size); data = g_slice_new (LoadConfigFileData); - data->mapped_file = mapped_file; + data->mapped_file = g_mapped_file_ref (mapped_file); data->checksum = g_array_sized_new (FALSE, FALSE, sizeof (guint8), hash_size); g_array_set_size (data->checksum, hash_size); data->offset = 0; g_checksum_get_digest (checksum, &g_array_index (data->checksum, guint8, 0), &hash_size); + g_checksum_free (checksum); return data; } @@ -1195,12 +1142,12 @@ load_config_file_from_string (const gchar *str) static QmiMessagePdcLoadConfigInput * load_config_input_create_chunk (LoadConfigFileData *config_file) { - QmiMessagePdcLoadConfigInput *input; - GError *error = NULL; - GArray *chunk; - gsize full_size; - gsize chunk_size; - guint8 *file_content; + g_autoptr(QmiMessagePdcLoadConfigInput) input = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GArray) chunk = NULL; + gsize full_size; + gsize chunk_size; + guint8 *file_content; if (!config_file) return NULL; @@ -1208,8 +1155,6 @@ load_config_input_create_chunk (LoadConfigFileData *config_file) input = qmi_message_pdc_load_config_input_new (); if (!qmi_message_pdc_load_config_input_set_token (input, ctx->token++, &error)) { g_printerr ("error: couldn't set token: '%s'\n", error->message); - g_error_free (error); - qmi_message_pdc_load_config_input_unref (input); return NULL; } @@ -1230,41 +1175,35 @@ load_config_input_create_chunk (LoadConfigFileData *config_file) chunk, &error)) { g_printerr ("error: couldn't set chunk: '%s'\n", error->message); - g_error_free (error); - g_array_unref (chunk); - qmi_message_pdc_load_config_input_unref (input); return NULL; } config_file->offset += chunk_size; - g_array_unref (chunk); - return input; + return g_steal_pointer (&input); } static void load_config_ready (QmiClientPdc *client, GAsyncResult *res); static void -load_config_ready_indication (QmiClientPdc *client, +load_config_ready_indication (QmiClientPdc *client, QmiIndicationPdcLoadConfigOutput *output) { - GError *error = NULL; - QmiMessagePdcLoadConfigInput *input; - gboolean frame_reset; - guint32 remaining_size; - guint16 error_code = 0; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcLoadConfigInput) input = NULL; + gboolean frame_reset; + guint32 remaining_size; + guint16 error_code = 0; if (!qmi_indication_pdc_load_config_output_get_indication_result (output, &error_code, &error)) { g_printerr ("error: couldn't load config: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (error_code != 0) { - g_printerr ("error: couldn't load config: %s\n", - qmi_protocol_error_get_string ((QmiProtocolError) error_code)); + g_printerr ("error: couldn't load config: %s\n", qmi_protocol_error_get_string ((QmiProtocolError) error_code)); operation_shutdown (FALSE); return; } @@ -1277,7 +1216,6 @@ load_config_ready_indication (QmiClientPdc *client, if (!qmi_indication_pdc_load_config_output_get_remaining_size (output, &remaining_size, &error)) { g_printerr ("error: couldn't load config: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } @@ -1301,40 +1239,34 @@ load_config_ready_indication (QmiClientPdc *client, 10, ctx->cancellable, (GAsyncReadyCallback) load_config_ready, NULL); - qmi_message_pdc_load_config_input_unref (input); } static void load_config_ready (QmiClientPdc *client, GAsyncResult *res) { - GError *error = NULL; - QmiMessagePdcLoadConfigOutput *output; + g_autoptr(GError) error = NULL; + g_autoptr(QmiMessagePdcLoadConfigOutput) output = NULL; output = qmi_client_pdc_load_config_finish (client, res, &error); if (!output) { g_printerr ("error: operation failed: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (!qmi_message_pdc_load_config_output_get_result (output, &error)) { g_printerr ("error: couldn't load config: %s\n", error->message); - g_error_free (error); - qmi_message_pdc_load_config_output_unref (output); operation_shutdown (FALSE); return; } - - qmi_message_pdc_load_config_output_unref (output); } static QmiMessagePdcLoadConfigInput * load_config_input_create (const gchar *str) { - LoadConfigFileData *config_file; - QmiMessagePdcLoadConfigInput *input = NULL; + LoadConfigFileData *config_file; + QmiMessagePdcLoadConfigInput *input; config_file = load_config_file_from_string (str); if (!config_file) @@ -1351,7 +1283,7 @@ load_config_input_create (const gchar *str) static void run_load_config (void) { - QmiMessagePdcLoadConfigInput *input; + g_autoptr(QmiMessagePdcLoadConfigInput) input = NULL; g_debug ("Loading config asynchronously..."); input = load_config_input_create (load_config_str); @@ -1373,7 +1305,6 @@ run_load_config (void) ctx->cancellable, (GAsyncReadyCallback) load_config_ready, NULL); - qmi_message_pdc_load_config_input_unref (input); } #endif /* HAVE_QMI_ACTION_PDC_LOAD_CONFIG */ @@ -1392,37 +1323,29 @@ monitoring_cancelled (GCancellable *cancellable) } static void -refresh_received (QmiClientPdc *client, +refresh_received (QmiClientPdc *client, QmiIndicationPdcRefreshOutput *output) { - GError *error = NULL; + g_autoptr(GError) error = NULL; QmiPdcRefreshEventType type; - guint subscription_id; - guint slot_id; + guint subscription_id; + guint slot_id; g_print ("[%s] Received refresh indication:\n", qmi_device_get_path_display (ctx->device)); - if (!qmi_indication_pdc_refresh_output_get_refresh_event ( - output, &type, &error)) { + if (!qmi_indication_pdc_refresh_output_get_refresh_event (output, &type, &error)) { g_printerr ("error: refresh event has no type: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } g_print (" Received event type %s", VALIDATE_UNKNOWN (qmi_pdc_refresh_event_type_get_string (type))); - - if (qmi_indication_pdc_refresh_output_get_subscription_id ( - output, &subscription_id, NULL)) { + if (qmi_indication_pdc_refresh_output_get_subscription_id (output, &subscription_id, NULL)) g_print (", subscription ID: %u", subscription_id); - } - if (qmi_indication_pdc_refresh_output_get_slot_id ( - output, &slot_id, NULL)) { + if (qmi_indication_pdc_refresh_output_get_slot_id (output, &slot_id, NULL)) g_print (", slot ID: %u", slot_id); - } - g_print ("\n"); } @@ -1430,21 +1353,18 @@ static void register_refresh_ready (QmiClientPdc *client, GAsyncResult *res) { - QmiMessagePdcRegisterOutput *output; - GError *error = NULL; + g_autoptr(QmiMessagePdcRegisterOutput) output = NULL; + g_autoptr(GError) error = NULL; output = qmi_client_pdc_register_finish (client, res, &error); if (!output) { g_printerr ("error: operation failed: %s\n", error->message); - g_error_free (error); operation_shutdown (FALSE); return; } if (!qmi_message_pdc_register_output_get_result (output, &error)) { g_printerr ("error: could not register for refresh events: %s\n", error->message); - qmi_message_pdc_register_output_unref (output); - g_error_free (error); operation_shutdown (FALSE); return; } @@ -1466,7 +1386,7 @@ register_refresh_ready (QmiClientPdc *client, static void register_refresh_events (void) { - QmiMessagePdcRegisterInput *re_input; + g_autoptr(QmiMessagePdcRegisterInput) re_input = NULL; re_input = qmi_message_pdc_register_input_new (); qmi_message_pdc_register_input_set_enable_reporting (re_input, TRUE, NULL); @@ -1478,7 +1398,6 @@ register_refresh_events (void) ctx->cancellable, (GAsyncReadyCallback) register_refresh_ready, NULL); - qmi_message_pdc_register_input_unref (re_input); } #endif /* HAVE_QMI_ACTION_PDC_REFRESH */ |