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 <gnu...@cyberdimension.org>
---
 tools/ipc-modem.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

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);
 }
-- 
2.33.0

_______________________________________________
Replicant mailing list
Replicant@osuosl.org
https://lists.osuosl.org/mailman/listinfo/replicant

Reply via email to