aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-03-16 11:19:44 +0100
committerAleksander Morgado <aleksander@aleksander.es>2021-03-16 11:19:44 +0100
commit933b8a9974ba0680698ff4e7f5fd29837d061f5c (patch)
tree740da974f30666020131a6f19b586a5650e5cc44
parent61c89f17db2856b6a17a9a3b1a7537d95d29c027 (diff)
qmicli: print 'none' if a mask has no known values
Instead of trying to print the NULL string, which ends up as '(null)'
-rw-r--r--src/qmicli/qmicli-dms.c18
-rw-r--r--src/qmicli/qmicli-loc.c9
-rw-r--r--src/qmicli/qmicli-nas.c23
-rw-r--r--src/qmicli/qmicli-pbm.c5
-rw-r--r--src/qmicli/qmicli-uim.c13
-rw-r--r--src/qmicli/qmicli-voice.c5
-rw-r--r--src/qmicli/qmicli-wds.c13
7 files changed, 54 insertions, 32 deletions
diff --git a/src/qmicli/qmicli-dms.c b/src/qmicli/qmicli-dms.c
index 0fb8d7b..8492da4 100644
--- a/src/qmicli/qmicli-dms.c
+++ b/src/qmicli/qmicli-dms.c
@@ -38,6 +38,9 @@
#undef VALIDATE_UNKNOWN
#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
+#undef VALIDATE_MASK_NONE
+#define VALIDATE_MASK_NONE(str) (str ? str : "none")
+
/* Context */
typedef struct {
QmiDevice *device;
@@ -907,7 +910,7 @@ get_power_state_ready (QmiClientDms *client,
"\tPower state: '%s'\n"
"\tBattery level: '%u %%'\n",
qmi_device_get_path_display (ctx->device),
- power_state_str,
+ VALIDATE_MASK_NONE (power_state_str),
(guint)battery_level);
qmi_message_dms_get_power_state_output_unref (output);
@@ -1790,12 +1793,13 @@ get_operating_mode_ready (QmiClientDms *client,
if (mode == QMI_DMS_OPERATING_MODE_OFFLINE || mode == QMI_DMS_OPERATING_MODE_LOW_POWER) {
QmiDmsOfflineReason reason;
- g_autofree gchar *reason_str = 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);
+ if (qmi_message_dms_get_operating_mode_output_get_offline_reason (output, &reason, NULL)) {
+ g_autofree gchar *reason_str = NULL;
- g_print ("\tReason: '%s'\n", VALIDATE_UNKNOWN (reason_str));
+ reason_str = qmi_dms_offline_reason_build_string_from_mask (reason);
+ g_print ("\tReason: '%s'\n", VALIDATE_MASK_NONE (reason_str));
+ }
}
qmi_message_dms_get_operating_mode_output_get_hardware_restricted_mode (output, &hw_restricted, NULL);
@@ -2690,7 +2694,7 @@ get_band_capabilities_ready (QmiClientDms *client,
g_print ("[%s] Device band capabilities retrieved:\n"
"\tBands: '%s'\n",
qmi_device_get_path_display (ctx->device),
- str);
+ VALIDATE_MASK_NONE (str));
}
if (qmi_message_dms_get_band_capabilities_output_get_lte_band_capability (
@@ -2700,7 +2704,7 @@ get_band_capabilities_ready (QmiClientDms *client,
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_print ("\tLTE bands: '%s'\n", VALIDATE_MASK_NONE (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 7bf29d9..752c96e 100644
--- a/src/qmicli/qmicli-loc.c
+++ b/src/qmicli/qmicli-loc.c
@@ -36,6 +36,9 @@
#if defined HAVE_QMI_SERVICE_LOC
+#undef VALIDATE_MASK_NONE
+#define VALIDATE_MASK_NONE(str) (str ? str : "none")
+
/* Context */
typedef enum {
@@ -572,7 +575,7 @@ position_report_received (QmiClientLoc *client,
g_autofree gchar *technology_str = NULL;
technology_str = qmi_loc_technology_used_build_string_from_mask (technology);
- g_print (" technology: %s\n", technology_str);
+ g_print (" technology: %s\n", VALIDATE_MASK_NONE (technology_str));
} else
g_print (" technology: n/a\n");
@@ -615,7 +618,7 @@ position_report_received (QmiClientLoc *client,
g_autofree gchar *sensor_data_usage_str = NULL;
sensor_data_usage_str = qmi_loc_sensor_data_usage_build_string_from_mask (sensor_data_usage);
- g_print (" sensor data usage: %s\n", sensor_data_usage_str);
+ g_print (" sensor data usage: %s\n", VALIDATE_MASK_NONE (sensor_data_usage_str));
} else
g_print (" sensor data usage: n/a\n");
@@ -914,7 +917,7 @@ get_nmea_types_received (QmiClientLoc *client,
}
nmea_types_str = qmi_loc_nmea_type_build_string_from_mask (nmea_types_mask);
- g_print ("Successfully retrieved NMEA types: %s\n", nmea_types_str ? nmea_types_str : "none");
+ g_print ("Successfully retrieved NMEA types: %s\n", VALIDATE_MASK_NONE (nmea_types_str));
operation_shutdown (TRUE);
}
diff --git a/src/qmicli/qmicli-nas.c b/src/qmicli/qmicli-nas.c
index 882b65e..a058913 100644
--- a/src/qmicli/qmicli-nas.c
+++ b/src/qmicli/qmicli-nas.c
@@ -35,6 +35,9 @@
#if defined HAVE_QMI_SERVICE_NAS
+#undef VALIDATE_MASK_NONE
+#define VALIDATE_MASK_NONE(str) (str ? str : "none")
+
/* Context */
typedef struct {
QmiDevice *device;
@@ -1069,7 +1072,7 @@ get_preferred_networks_ready (QmiClientNas *client,
i,
element->mcc,
element->mnc,
- access_tech_string);
+ VALIDATE_MASK_NONE (access_tech_string));
}
}
@@ -2430,7 +2433,7 @@ get_technology_preference_ready (QmiClientNas *client,
g_print ("[%s] Successfully got technology preference\n"
"\tActive: '%s', duration: '%s'\n",
qmi_device_get_path_display (ctx->device),
- preference_string,
+ VALIDATE_MASK_NONE (preference_string),
qmi_nas_preference_duration_get_string (duration));
if (qmi_message_nas_get_technology_preference_output_get_persistent (
@@ -2438,7 +2441,7 @@ get_technology_preference_ready (QmiClientNas *client,
&preference,
NULL)) {
persistent_preference_string = qmi_nas_radio_technology_preference_build_string_from_mask (preference);
- g_print ("\tPersistent: '%s'\n", persistent_preference_string);
+ g_print ("\tPersistent: '%s'\n", VALIDATE_MASK_NONE (persistent_preference_string));
}
qmi_message_nas_get_technology_preference_output_unref (output);
@@ -2509,7 +2512,7 @@ get_system_selection_preference_ready (QmiClientNas *client,
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_print ("\tMode preference: '%s'\n", VALIDATE_MASK_NONE (str));
}
if (qmi_message_nas_get_system_selection_preference_output_get_disabled_modes (
@@ -2519,7 +2522,7 @@ get_system_selection_preference_ready (QmiClientNas *client,
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_print ("\tDisabled modes: '%s'\n", VALIDATE_MASK_NONE (str));
}
@@ -2530,7 +2533,7 @@ get_system_selection_preference_ready (QmiClientNas *client,
g_autofree gchar *str = NULL;
str = qmi_nas_band_preference_build_string_from_mask (band_preference);
- g_print ("\tBand preference: '%s'\n", str);
+ g_print ("\tBand preference: '%s'\n", VALIDATE_MASK_NONE (str));
}
if (qmi_message_nas_get_system_selection_preference_output_get_lte_band_preference (
@@ -2540,7 +2543,7 @@ get_system_selection_preference_ready (QmiClientNas *client,
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_print ("\tLTE band preference: '%s'\n", VALIDATE_MASK_NONE (str));
}
if (qmi_message_nas_get_system_selection_preference_output_get_extended_lte_band_preference (
@@ -2580,7 +2583,7 @@ get_system_selection_preference_ready (QmiClientNas *client,
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_print ("\tTD-SCDMA band preference: '%s'\n", VALIDATE_MASK_NONE (str));
}
if (qmi_message_nas_get_system_selection_preference_output_get_cdma_prl_preference (
@@ -2852,7 +2855,7 @@ network_scan_ready (QmiClientNas *client,
i,
element->mcc,
element->mnc,
- status_str,
+ VALIDATE_MASK_NONE (status_str),
element->description);
}
}
@@ -3546,7 +3549,7 @@ get_operator_name_ready (QmiClientNas *client,
g_print ("Service Provider Name\n");
g_print ("\tDisplay Condition: '%s'\n"
"\tName : '%s'\n",
- dc_string,
+ VALIDATE_MASK_NONE (dc_string),
spn);
}
diff --git a/src/qmicli/qmicli-pbm.c b/src/qmicli/qmicli-pbm.c
index 3d1a095..c1e8770 100644
--- a/src/qmicli/qmicli-pbm.c
+++ b/src/qmicli/qmicli-pbm.c
@@ -34,6 +34,9 @@
#if defined HAVE_QMI_SERVICE_PBM
+#undef VALIDATE_MASK_NONE
+#define VALIDATE_MASK_NONE(str) (str ? str : "none")
+
/* Context */
typedef struct {
QmiDevice *device;
@@ -189,7 +192,7 @@ get_all_capabilities_ready (QmiClientPbm *client,
QmiMessagePbmGetAllCapabilitiesOutputCapabilityBasicInformationElementPhonebooksElement,
j);
phonebook_type_str = qmi_pbm_phonebook_type_build_string_from_mask (phonebook->phonebook_type);
- g_print ("\t\t[%s]:\n", phonebook_type_str);
+ g_print ("\t\t[%s]:\n", VALIDATE_MASK_NONE (phonebook_type_str));
g_print ("\t\t\tUsed records: %" G_GUINT16_FORMAT "\n", phonebook->used_records);
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);
diff --git a/src/qmicli/qmicli-uim.c b/src/qmicli/qmicli-uim.c
index ae200ee..ff5b9fd 100644
--- a/src/qmicli/qmicli-uim.c
+++ b/src/qmicli/qmicli-uim.c
@@ -35,6 +35,9 @@
#if defined HAVE_QMI_SERVICE_UIM
+#undef VALIDATE_MASK_NONE
+#define VALIDATE_MASK_NONE(str) (str ? str : "none")
+
/* Context */
typedef struct {
QmiDevice *device;
@@ -2050,27 +2053,27 @@ get_file_attributes_ready (QmiClientUim *client,
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),
- read_security_attributes_str);
+ VALIDATE_MASK_NONE (read_security_attributes_str));
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),
- write_security_attributes_str);
+ VALIDATE_MASK_NONE (write_security_attributes_str));
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),
- increase_security_attributes_str);
+ VALIDATE_MASK_NONE (increase_security_attributes_str));
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),
- deactivate_security_attributes_str);
+ VALIDATE_MASK_NONE (deactivate_security_attributes_str));
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),
- activate_security_attributes_str);
+ VALIDATE_MASK_NONE (activate_security_attributes_str));
raw_str = qmicli_get_raw_data_printable (raw, 80, "\t");
g_print ("\tRaw: %s\n", raw_str);
diff --git a/src/qmicli/qmicli-voice.c b/src/qmicli/qmicli-voice.c
index 0b51a02..27f5561 100644
--- a/src/qmicli/qmicli-voice.c
+++ b/src/qmicli/qmicli-voice.c
@@ -35,6 +35,9 @@
#if defined HAVE_QMI_SERVICE_VOICE
+#undef VALIDATE_MASK_NONE
+#define VALIDATE_MASK_NONE(str) (str ? str : "none")
+
/* Context */
typedef struct {
QmiDevice *device;
@@ -237,7 +240,7 @@ get_config_ready (QmiClientVoice *client,
"\tGSM: '%s'\n"
"\tWCDMA: '%s' (0x%04X)\n",
current_amr_status_gsm ? "enabled" : "disabled",
- current_amr_status_wcdma_str ? current_amr_status_wcdma_str : "unknown",
+ VALIDATE_MASK_NONE (current_amr_status_wcdma_str),
current_amr_status_wcdma);
g_free (current_amr_status_wcdma_str);
}
diff --git a/src/qmicli/qmicli-wds.c b/src/qmicli/qmicli-wds.c
index 0f36f78..6e8f75d 100644
--- a/src/qmicli/qmicli-wds.c
+++ b/src/qmicli/qmicli-wds.c
@@ -37,6 +37,9 @@
#if defined HAVE_QMI_SERVICE_WDS
+#undef VALIDATE_MASK_NONE
+#define VALIDATE_MASK_NONE(str) (str ? str : "none")
+
#define QMI_WDS_MUX_ID_UNDEFINED 0xFF
#define QMI_WDS_ENDPOINT_INTERFACE_NUMBER_UNDEFINED -1
@@ -1184,11 +1187,11 @@ print_current_data_bearer_technology_results (const gchar *which,
qmi_device_get_path_display (ctx->device),
which,
qmi_wds_network_type_get_string (network_type),
- VALIDATE_UNKNOWN (rat_string));
+ VALIDATE_MASK_NONE (rat_string));
if (network_type == QMI_WDS_NETWORK_TYPE_3GPP2)
g_print (" Service Option: '%s'\n",
- VALIDATE_UNKNOWN (so_string));
+ VALIDATE_MASK_NONE (so_string));
}
static void
@@ -2051,7 +2054,7 @@ get_profile_settings_ready (QmiClientWds *client,
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_print ("\t\tAPN type: '%s'\n", VALIDATE_MASK_NONE (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));
@@ -2065,7 +2068,7 @@ get_profile_settings_ready (QmiClientWds *client,
g_autofree gchar *aux = NULL;
aux = qmi_wds_authentication_build_string_from_mask (auth);
- g_print ("\t\tAuth: '%s'\n", aux);
+ g_print ("\t\tAuth: '%s'\n", VALIDATE_MASK_NONE (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");
@@ -2231,7 +2234,7 @@ get_default_settings_ready (QmiClientWds *client,
g_autofree gchar *aux = NULL;
aux = qmi_wds_authentication_build_string_from_mask (auth);
- g_print ("\tAuth: '%s'\n", aux);
+ g_print ("\tAuth: '%s'\n", VALIDATE_MASK_NONE (aux));
}
qmi_message_wds_get_default_settings_output_unref (output);