aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-08-31 15:29:38 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-09-01 15:41:58 +0200
commit322d4afd141f413e242e966202c6653426a3c2d5 (patch)
treee4d21dc4771cd084d282c8aed33de9bb355fc3fa
parentc111ccec80fdffa875ac4673a9d9cd22a165deaf (diff)
downloadhardware_replicant_libsamsung-ipc-322d4afd141f413e242e966202c6653426a3c2d5.tar.gz
hardware_replicant_libsamsung-ipc-322d4afd141f413e242e966202c6653426a3c2d5.tar.bz2
hardware_replicant_libsamsung-ipc-322d4afd141f413e242e966202c6653426a3c2d5.zip
tools: ipc-modem: Fail if there is no chosen command
Without that fix, if some arguments were set and no command was given, ipc-modem would proceed anyway: $ ./tools/ipc-modem --debug [I] Debug enabled [...] As it's expected to at least be used with a command to do something meaningful, without that fix, it could misslead users into thinking that everything is fine when it's not or vice versa. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--tools/ipc-modem.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/ipc-modem.c b/tools/ipc-modem.c
index 71031eb..de9910b 100644
--- a/tools/ipc-modem.c
+++ b/tools/ipc-modem.c
@@ -50,6 +50,7 @@ char call_number[14];
char sim_pin[8];
enum command {
+ CMD_NONE,
CMD_START,
CMD_BOOT,
CMD_POWER_ON,
@@ -553,7 +554,7 @@ modem_quit:
int main(int argc, char *argv[])
{
- enum command command;
+ enum command command = CMD_NONE;
int c = 0;
int opt_i = 0;
bool debug = false;
@@ -639,5 +640,14 @@ int main(int argc, char *argv[])
optind++;
}
+ if (command == CMD_NONE) {
+ printf("\n");
+ printf("Error: No command given. You need to use a command.\n");
+ printf(" See the help below for more details.\n");
+ printf("\n");
+ print_help();
+ return 1;
+ }
+
return handle_command(command, debug);
}