shell: Return proper errors if the command fails
If the command cannot be execute code should return a proper since this
may not be a user input.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c
index 73debb9..7d27f8b 100644
--- a/subsys/shell/shell.c
+++ b/subsys/shell/shell.c
@@ -205,7 +205,7 @@
}
printk("Unrecognized command: %s\n", argv[0]);
- return 0;
+ return -EINVAL;
}
static void print_module_commands(const int module)
@@ -235,7 +235,7 @@
module = get_destination_module(argv[1]);
if (module == -1) {
printk("Illegal module %s\n", argv[1]);
- return 0;
+ return -EINVAL;
}
} else {
module = default_module;
@@ -261,14 +261,14 @@
if (strlen(name) > MODULE_NAME_MAX_LEN) {
printk("Module name %s is too long, default is not changed\n",
name);
- return -1;
+ return -EINVAL;
}
module = get_destination_module(name);
if (module == -1) {
printk("Illegal module %s, default is not changed\n", name);
- return -1;
+ return -EINVAL;
}
default_module = module;
@@ -283,11 +283,10 @@
{
if (argc == 1) {
default_module = -1;
- } else {
- set_default_module(argv[1]);
+ return 0;
}
- return 0;
+ return set_default_module(argv[1]);
}
static int exit_module(int argc, char *argv[])