aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-12-17 14:58:09 +0100
committerDan Williams <dcbw@redhat.com>2019-01-03 18:53:52 +0000
commitdcd49dee8899bfb4ccae7a0bbc200a0a62aeeb04 (patch)
treec43da1d822182d5442eff11390c08560a02099e1
parentf69098819b58a6f2f7012376e34035503daa876c (diff)
mmcli,firmware: avoid empty output if firmware status unsupported
-rw-r--r--cli/mmcli-modem-firmware.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/cli/mmcli-modem-firmware.c b/cli/mmcli-modem-firmware.c
index b5d474b6..ffcceb6a 100644
--- a/cli/mmcli-modem-firmware.c
+++ b/cli/mmcli-modem-firmware.c
@@ -151,7 +151,8 @@ print_firmware_status (void)
MMModemFirmwareUpdateMethod m;
m = mm_firmware_update_settings_get_method (update_settings);
- method = mm_modem_firmware_update_method_get_string (m);
+ if (m != MM_MODEM_FIRMWARE_UPDATE_METHOD_UNKNOWN)
+ method = mm_modem_firmware_update_method_get_string (m);
switch (m) {
case MM_MODEM_FIRMWARE_UPDATE_METHOD_FASTBOOT:
@@ -162,6 +163,18 @@ print_firmware_status (void)
}
}
+ /* There's not much to print in this status info, and if the modem
+ * does not support any firmware update method, we would just be returning
+ * an empty response to the --firmware-status action. So, instead, just
+ * return an error message explicitly when in human output type.
+ * We can remove this error message as soon as there is some parameter
+ * that will always be printed.
+ */
+ if (!method && !fastboot_at && mmcli_output_get () == MMC_OUTPUT_TYPE_HUMAN) {
+ g_printerr ("error: firmware status unsupported\n");
+ exit (EXIT_FAILURE);
+ }
+
mmcli_output_string (MMC_F_FIRMWARE_METHOD, method);
mmcli_output_string (MMC_F_FIRMWARE_FASTBOOT_AT, fastboot_at);
mmcli_output_dump ();