From 1a95aad7a72348e72f7301abe698757bba748ebd Mon Sep 17 00:00:00 2001 From: Angelos Oikonomopoulos Date: Thu, 7 Jun 2018 14:26:47 +0000 Subject: [PATCH] Mark shell_commands as const This enables the compiler to place the array in flash, saving us a bit of RAM. Suggested-by: g-oikonomou --- os/services/shell/shell-commands.c | 4 ++-- os/services/shell/shell-commands.h | 2 +- os/services/shell/shell.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index f2f036eda..67c81b6e1 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -345,7 +345,7 @@ PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args)) static PT_THREAD(cmd_help(struct pt *pt, shell_output_func output, char *args)) { - struct shell_command_t *cmd_ptr; + const struct shell_command_t *cmd_ptr; PT_BEGIN(pt); @@ -734,7 +734,7 @@ shell_commands_init(void) echo_reply_handler); } /*---------------------------------------------------------------------------*/ -struct shell_command_t shell_commands[] = { +const struct shell_command_t shell_commands[] = { { "help", cmd_help, "'> help': Shows this help" }, { "reboot", cmd_reboot, "'> reboot': Reboot the board by watchdog_reboot()" }, { "ip-addr", cmd_ipaddr, "'> ip-addr': Shows all IPv6 addresses" }, diff --git a/os/services/shell/shell-commands.h b/os/services/shell/shell-commands.h index f89703273..4d89d2e4b 100644 --- a/os/services/shell/shell-commands.h +++ b/os/services/shell/shell-commands.h @@ -54,7 +54,7 @@ struct shell_command_t { }; /* The set of supported commands */ -extern struct shell_command_t shell_commands[]; +extern const struct shell_command_t shell_commands[]; /** * Initializes Shell-commands module diff --git a/os/services/shell/shell.c b/os/services/shell/shell.c index fcf419880..e16a69b30 100644 --- a/os/services/shell/shell.c +++ b/os/services/shell/shell.c @@ -89,7 +89,7 @@ output_prompt(shell_output_func output) PT_THREAD(shell_input(struct pt *pt, shell_output_func output, const char *cmd)) { static char *args; - static struct shell_command_t *cmd_ptr; + static const struct shell_command_t *cmd_ptr; PT_BEGIN(pt);