diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-03-16 10:54:13 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-03-16 11:17:17 +0100 |
commit | 61c89f17db2856b6a17a9a3b1a7537d95d29c027 (patch) | |
tree | 0dde0385895081be61cc1d21dd34008bf52994fc | |
parent | 7b3bd21e108236265da8c7fcb0ea312306392502 (diff) |
qmicli: port to g_autofree all mask string building
-rw-r--r-- | src/qmicli/qmicli-dms.c | 34 | ||||
-rw-r--r-- | src/qmicli/qmicli-loc.c | 8 | ||||
-rw-r--r-- | src/qmicli/qmicli-nas.c | 35 | ||||
-rw-r--r-- | src/qmicli/qmicli-pbm.c | 3 | ||||
-rw-r--r-- | src/qmicli/qmicli-uim.c | 37 | ||||
-rw-r--r-- | src/qmicli/qmicli-wds.c | 19 |
6 files changed, 58 insertions, 78 deletions
diff --git a/src/qmicli/qmicli-dms.c b/src/qmicli/qmicli-dms.c index 44fa5cb..0fb8d7b 100644 --- a/src/qmicli/qmicli-dms.c +++ b/src/qmicli/qmicli-dms.c @@ -875,7 +875,7 @@ static void get_power_state_ready (QmiClientDms *client, GAsyncResult *res) { - gchar *power_state_str; + g_autofree gchar *power_state_str = NULL; guint8 power_state_flags; guint8 battery_level; QmiMessageDmsGetPowerStateOutput *output; @@ -910,7 +910,6 @@ get_power_state_ready (QmiClientDms *client, power_state_str, (guint)battery_level); - g_free (power_state_str); qmi_message_dms_get_power_state_output_unref (output); operation_shutdown (TRUE); } @@ -1791,14 +1790,12 @@ get_operating_mode_ready (QmiClientDms *client, if (mode == QMI_DMS_OPERATING_MODE_OFFLINE || mode == QMI_DMS_OPERATING_MODE_LOW_POWER) { QmiDmsOfflineReason reason; - gchar *reason_str = NULL; + g_autofree gchar *reason_str = NULL; - if (qmi_message_dms_get_operating_mode_output_get_offline_reason (output, &reason, NULL)) { + if (qmi_message_dms_get_operating_mode_output_get_offline_reason (output, &reason, NULL)) reason_str = qmi_dms_offline_reason_build_string_from_mask (reason); - } g_print ("\tReason: '%s'\n", VALIDATE_UNKNOWN (reason_str)); - g_free (reason_str); } qmi_message_dms_get_operating_mode_output_get_hardware_restricted_mode (output, &hw_restricted, NULL); @@ -2666,7 +2663,6 @@ get_band_capabilities_ready (QmiClientDms *client, QmiDmsLteBandCapability lte_band_capability; GArray *extended_lte_band_capability; GError *error = NULL; - gchar *str; output = qmi_client_dms_get_band_capabilities_finish (client, res, &error); if (!output) { @@ -2684,25 +2680,27 @@ get_band_capabilities_ready (QmiClientDms *client, return; } - qmi_message_dms_get_band_capabilities_output_get_band_capability ( - output, - &band_capability, - NULL); + if (qmi_message_dms_get_band_capabilities_output_get_band_capability ( + output, + &band_capability, + NULL)) { + g_autofree gchar *str = NULL; - str = qmi_dms_band_capability_build_string_from_mask (band_capability); - g_print ("[%s] Device band capabilities retrieved:\n" - "\tBands: '%s'\n", - qmi_device_get_path_display (ctx->device), - str); - g_free (str); + str = qmi_dms_band_capability_build_string_from_mask (band_capability); + g_print ("[%s] Device band capabilities retrieved:\n" + "\tBands: '%s'\n", + qmi_device_get_path_display (ctx->device), + str); + } if (qmi_message_dms_get_band_capabilities_output_get_lte_band_capability ( output, <e_band_capability, NULL)) { + g_autofree gchar *str = NULL; + str = qmi_dms_lte_band_capability_build_string_from_mask (lte_band_capability); g_print ("\tLTE bands: '%s'\n", str); - g_free (str); } if (qmi_message_dms_get_band_capabilities_output_get_extended_lte_band_capability ( diff --git a/src/qmicli/qmicli-loc.c b/src/qmicli/qmicli-loc.c index f8fb2a1..7bf29d9 100644 --- a/src/qmicli/qmicli-loc.c +++ b/src/qmicli/qmicli-loc.c @@ -470,7 +470,6 @@ position_report_received (QmiClientLoc *client, QmiLocSensorDataUsage sensor_data_usage; QmiIndicationLocPositionReportOutputDilutionOfPrecision dop; QmiIndicationLocPositionReportOutputGpsTime gps_time; - gchar *auxs; gboolean auxb; GArray *array; @@ -570,9 +569,10 @@ position_report_received (QmiClientLoc *client, g_print (" magnetic deviation: n/a\n"); if (qmi_indication_loc_position_report_output_get_technology_used (output, &technology, NULL)) { - auxs = qmi_loc_technology_used_build_string_from_mask (technology); - g_print (" technology: %s\n", auxs); - g_free (auxs); + g_autofree gchar *technology_str = NULL; + + technology_str = qmi_loc_technology_used_build_string_from_mask (technology); + g_print (" technology: %s\n", technology_str); } else g_print (" technology: n/a\n"); diff --git a/src/qmicli/qmicli-nas.c b/src/qmicli/qmicli-nas.c index 014b89a..882b65e 100644 --- a/src/qmicli/qmicli-nas.c +++ b/src/qmicli/qmicli-nas.c @@ -1052,13 +1052,13 @@ get_preferred_networks_ready (QmiClientNas *client, if (qmi_message_nas_get_preferred_networks_output_get_preferred_networks (output, &preferred_networks_array, NULL)) { guint i; - gchar *access_tech_string; g_print ("Preferred PLMN list:\n"); if (preferred_networks_array->len == 0) g_print ("\t<empty>\n"); for (i = 0; i < preferred_networks_array->len; i++) { QmiMessageNasGetPreferredNetworksOutputPreferredNetworksElement *element; + g_autofree gchar *access_tech_string = NULL; element = &g_array_index (preferred_networks_array, QmiMessageNasGetPreferredNetworksOutputPreferredNetworksElement, i); access_tech_string = qmi_nas_plmn_access_technology_identifier_build_string_from_mask (element->radio_access_technology); @@ -1070,7 +1070,6 @@ get_preferred_networks_ready (QmiClientNas *client, element->mcc, element->mnc, access_tech_string); - g_free (access_tech_string); } } @@ -2402,7 +2401,8 @@ get_technology_preference_ready (QmiClientNas *client, GError *error = NULL; QmiNasRadioTechnologyPreference preference; QmiNasPreferenceDuration duration; - gchar *preference_string; + g_autofree gchar *preference_string = NULL; + g_autofree gchar *persistent_preference_string = NULL; output = qmi_client_nas_get_technology_preference_finish (client, res, &error); if (!output) { @@ -2432,16 +2432,13 @@ get_technology_preference_ready (QmiClientNas *client, qmi_device_get_path_display (ctx->device), preference_string, qmi_nas_preference_duration_get_string (duration)); - g_free (preference_string); if (qmi_message_nas_get_technology_preference_output_get_persistent ( output, &preference, NULL)) { - preference_string = qmi_nas_radio_technology_preference_build_string_from_mask (preference); - g_print ("\tPersistent: '%s'\n", - preference_string); - g_free (preference_string); + persistent_preference_string = qmi_nas_radio_technology_preference_build_string_from_mask (preference); + g_print ("\tPersistent: '%s'\n", persistent_preference_string); } qmi_message_nas_get_technology_preference_output_unref (output); @@ -2509,22 +2506,20 @@ get_system_selection_preference_ready (QmiClientNas *client, output, &mode_preference, NULL)) { - gchar *str; + g_autofree gchar *str = NULL; str = qmi_nas_rat_mode_preference_build_string_from_mask (mode_preference); g_print ("\tMode preference: '%s'\n", str); - g_free (str); } if (qmi_message_nas_get_system_selection_preference_output_get_disabled_modes ( output, &disabled_modes, NULL)) { - gchar *str; + g_autofree gchar *str = NULL; str = qmi_nas_rat_mode_preference_build_string_from_mask (disabled_modes); g_print ("\tDisabled modes: '%s'\n", str); - g_free (str); } @@ -2532,22 +2527,20 @@ get_system_selection_preference_ready (QmiClientNas *client, output, &band_preference, NULL)) { - gchar *str; + g_autofree gchar *str = NULL; str = qmi_nas_band_preference_build_string_from_mask (band_preference); g_print ("\tBand preference: '%s'\n", str); - g_free (str); } if (qmi_message_nas_get_system_selection_preference_output_get_lte_band_preference ( output, <e_band_preference, NULL)) { - gchar *str; + g_autofree gchar *str = NULL; str = qmi_nas_lte_band_preference_build_string_from_mask (lte_band_preference); g_print ("\tLTE band preference: '%s'\n", str); - g_free (str); } if (qmi_message_nas_get_system_selection_preference_output_get_extended_lte_band_preference ( @@ -2584,11 +2577,10 @@ get_system_selection_preference_ready (QmiClientNas *client, output, &td_scdma_band_preference, NULL)) { - gchar *str; + g_autofree gchar *str = NULL; str = qmi_nas_td_scdma_band_preference_build_string_from_mask (td_scdma_band_preference); g_print ("\tTD-SCDMA band preference: '%s'\n", str); - g_free (str); } if (qmi_message_nas_get_system_selection_preference_output_get_cdma_prl_preference ( @@ -2848,7 +2840,7 @@ network_scan_ready (QmiClientNas *client, for (i = 0; i < array->len; i++) { QmiMessageNasNetworkScanOutputNetworkInformationElement *element; - gchar *status_str; + g_autofree gchar *status_str = NULL; element = &g_array_index (array, QmiMessageNasNetworkScanOutputNetworkInformationElement, i); status_str = qmi_nas_network_status_build_string_from_mask (element->network_status); @@ -2862,7 +2854,6 @@ network_scan_ready (QmiClientNas *client, element->mnc, status_str, element->description); - g_free (status_str); } } @@ -3549,14 +3540,14 @@ get_operator_name_ready (QmiClientNas *client, &spn_display_condition, &spn, NULL)) { - gchar *dc_string = qmi_nas_network_name_display_condition_build_string_from_mask (spn_display_condition); + g_autofree gchar *dc_string = NULL; + dc_string = qmi_nas_network_name_display_condition_build_string_from_mask (spn_display_condition); g_print ("Service Provider Name\n"); g_print ("\tDisplay Condition: '%s'\n" "\tName : '%s'\n", dc_string, spn); - g_free (dc_string); } if (qmi_message_nas_get_operator_name_output_get_operator_string_name ( diff --git a/src/qmicli/qmicli-pbm.c b/src/qmicli/qmicli-pbm.c index ece89c6..3d1a095 100644 --- a/src/qmicli/qmicli-pbm.c +++ b/src/qmicli/qmicli-pbm.c @@ -183,7 +183,7 @@ get_all_capabilities_ready (QmiClientPbm *client, g_print ("\t[%s]:\n", qmi_pbm_session_type_get_string (session->session_type)); for (j = 0; j < session->phonebooks->len; j++) { QmiMessagePbmGetAllCapabilitiesOutputCapabilityBasicInformationElementPhonebooksElement *phonebook; - gchar *phonebook_type_str; + g_autofree gchar *phonebook_type_str = NULL; phonebook = &g_array_index (session->phonebooks, QmiMessagePbmGetAllCapabilitiesOutputCapabilityBasicInformationElementPhonebooksElement, @@ -194,7 +194,6 @@ get_all_capabilities_ready (QmiClientPbm *client, g_print ("\t\t\tMaximum records: %" G_GUINT16_FORMAT "\n", phonebook->maximum_records); g_print ("\t\t\tMaximum number length: %u\n", phonebook->maximum_number_length); g_print ("\t\t\tMaximum name length: %u\n", phonebook->maximum_name_length); - g_free (phonebook_type_str); } } } diff --git a/src/qmicli/qmicli-uim.c b/src/qmicli/qmicli-uim.c index 4c2fef3..ae200ee 100644 --- a/src/qmicli/qmicli-uim.c +++ b/src/qmicli/qmicli-uim.c @@ -2033,7 +2033,12 @@ get_file_attributes_ready (QmiClientUim *client, &activate_security_attributes, &raw, NULL)) { - gchar *str; + g_autofree gchar *read_security_attributes_str = NULL; + g_autofree gchar *write_security_attributes_str = NULL; + g_autofree gchar *increase_security_attributes_str = NULL; + g_autofree gchar *deactivate_security_attributes_str = NULL; + g_autofree gchar *activate_security_attributes_str = NULL; + g_autofree gchar *raw_str = NULL; g_print ("File attributes:\n"); g_print ("\tFile size: %u\n", (guint)file_size); @@ -2042,39 +2047,33 @@ get_file_attributes_ready (QmiClientUim *client, g_print ("\tRecord size: %u\n", (guint)record_size); g_print ("\tRecord count: %u\n", (guint)record_count); - str = qmi_uim_security_attribute_build_string_from_mask (read_security_attributes); + read_security_attributes_str = qmi_uim_security_attribute_build_string_from_mask (read_security_attributes); g_print ("\tRead security attributes: (%s) %s\n", qmi_uim_security_attribute_logic_get_string (read_security_attributes_logic), - str); - g_free (str); + read_security_attributes_str); - str = qmi_uim_security_attribute_build_string_from_mask (write_security_attributes); + write_security_attributes_str = qmi_uim_security_attribute_build_string_from_mask (write_security_attributes); g_print ("\tWrite security attributes: (%s) %s\n", qmi_uim_security_attribute_logic_get_string (write_security_attributes_logic), - str); - g_free (str); + write_security_attributes_str); - str = qmi_uim_security_attribute_build_string_from_mask (increase_security_attributes); + increase_security_attributes_str = qmi_uim_security_attribute_build_string_from_mask (increase_security_attributes); g_print ("\tIncrease security attributes: (%s) %s\n", qmi_uim_security_attribute_logic_get_string (increase_security_attributes_logic), - str); - g_free (str); + increase_security_attributes_str); - str = qmi_uim_security_attribute_build_string_from_mask (deactivate_security_attributes); + deactivate_security_attributes_str = qmi_uim_security_attribute_build_string_from_mask (deactivate_security_attributes); g_print ("\tDeactivate security attributes: (%s) %s\n", qmi_uim_security_attribute_logic_get_string (deactivate_security_attributes_logic), - str); - g_free (str); + deactivate_security_attributes_str); - str = qmi_uim_security_attribute_build_string_from_mask (activate_security_attributes); + activate_security_attributes_str = qmi_uim_security_attribute_build_string_from_mask (activate_security_attributes); g_print ("\tActivate security attributes: (%s) %s\n", qmi_uim_security_attribute_logic_get_string (activate_security_attributes_logic), - str); - g_free (str); + activate_security_attributes_str); - str = qmicli_get_raw_data_printable (raw, 80, "\t"); - g_print ("\tRaw: %s\n", str); - g_free (str); + raw_str = qmicli_get_raw_data_printable (raw, 80, "\t"); + g_print ("\tRaw: %s\n", raw_str); } qmi_message_uim_get_file_attributes_output_unref (output); diff --git a/src/qmicli/qmicli-wds.c b/src/qmicli/qmicli-wds.c index a047161..0f36f78 100644 --- a/src/qmicli/qmicli-wds.c +++ b/src/qmicli/qmicli-wds.c @@ -641,7 +641,7 @@ start_network_input_create (const gchar *str, QmiMessageWdsStartNetworkInput **input, GError **error) { - gchar *aux_auth_str = NULL; + g_autofree gchar *aux_auth_str = NULL; const gchar *ip_type_str = NULL; gchar **split = NULL; StartNetworkProperties props = { @@ -757,7 +757,6 @@ out: g_free (props.apn); g_free (props.username); g_free (props.password); - g_free (aux_auth_str); return success; } @@ -1166,8 +1165,8 @@ print_current_data_bearer_technology_results (const gchar *which, guint32 rat_mask, guint32 so_mask) { - gchar *rat_string = NULL; - gchar *so_string = NULL; + g_autofree gchar *rat_string = NULL; + g_autofree gchar *so_string = NULL; if (network_type == QMI_WDS_NETWORK_TYPE_3GPP2) { rat_string = qmi_wds_rat_3gpp2_build_string_from_mask (rat_mask); @@ -1190,9 +1189,6 @@ print_current_data_bearer_technology_results (const gchar *which, if (network_type == QMI_WDS_NETWORK_TYPE_3GPP2) g_print (" Service Option: '%s'\n", VALIDATE_UNKNOWN (so_string)); - - g_free (rat_string); - g_free (so_string); } static void @@ -2052,11 +2048,10 @@ get_profile_settings_ready (QmiClientWds *client, if (qmi_message_wds_get_profile_settings_output_get_apn_name (output, &str, NULL)) g_print ("\t\tAPN: '%s'\n", str); if (qmi_message_wds_get_profile_settings_output_get_apn_type_mask (output, &apn_type, NULL)) { - gchar *aux; + g_autofree gchar *aux = NULL; aux = qmi_wds_apn_type_mask_build_string_from_mask (apn_type); g_print ("\t\tAPN type: '%s'\n", aux); - g_free (aux); } if (qmi_message_wds_get_profile_settings_output_get_pdp_type (output, &pdp_type, NULL)) g_print ("\t\tPDP type: '%s'\n", qmi_wds_pdp_type_get_string (pdp_type)); @@ -2067,11 +2062,10 @@ get_profile_settings_ready (QmiClientWds *client, if (qmi_message_wds_get_profile_settings_output_get_password (output, &str, NULL)) g_print ("\t\tPassword: '%s'\n", str); if (qmi_message_wds_get_profile_settings_output_get_authentication (output, &auth, NULL)) { - gchar *aux; + g_autofree gchar *aux = NULL; aux = qmi_wds_authentication_build_string_from_mask (auth); g_print ("\t\tAuth: '%s'\n", aux); - g_free (aux); } if (qmi_message_wds_get_profile_settings_output_get_roaming_disallowed_flag (output, &flag, NULL)) g_print ("\t\tNo roaming: '%s'\n", flag ? "yes" : "no"); @@ -2234,11 +2228,10 @@ get_default_settings_ready (QmiClientWds *client, if (qmi_message_wds_get_default_settings_output_get_password (output, &str, NULL)) g_print ("\tPassword: '%s'\n", str); if (qmi_message_wds_get_default_settings_output_get_authentication (output, &auth, NULL)) { - gchar *aux; + g_autofree gchar *aux = NULL; aux = qmi_wds_authentication_build_string_from_mask (auth); g_print ("\tAuth: '%s'\n", aux); - g_free (aux); } qmi_message_wds_get_default_settings_output_unref (output); |