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
This commit is contained in:
Angelos Oikonomopoulos 2018-06-07 14:26:47 +00:00
parent 56dd8dcea4
commit 1a95aad7a7
3 changed files with 4 additions and 4 deletions

View File

@ -345,7 +345,7 @@ PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args))
static static
PT_THREAD(cmd_help(struct pt *pt, shell_output_func output, char *args)) 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); PT_BEGIN(pt);
@ -734,7 +734,7 @@ shell_commands_init(void)
echo_reply_handler); echo_reply_handler);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
struct shell_command_t shell_commands[] = { const struct shell_command_t shell_commands[] = {
{ "help", cmd_help, "'> help': Shows this help" }, { "help", cmd_help, "'> help': Shows this help" },
{ "reboot", cmd_reboot, "'> reboot': Reboot the board by watchdog_reboot()" }, { "reboot", cmd_reboot, "'> reboot': Reboot the board by watchdog_reboot()" },
{ "ip-addr", cmd_ipaddr, "'> ip-addr': Shows all IPv6 addresses" }, { "ip-addr", cmd_ipaddr, "'> ip-addr': Shows all IPv6 addresses" },

View File

@ -54,7 +54,7 @@ struct shell_command_t {
}; };
/* The set of supported commands */ /* The set of supported commands */
extern struct shell_command_t shell_commands[]; extern const struct shell_command_t shell_commands[];
/** /**
* Initializes Shell-commands module * Initializes Shell-commands module

View File

@ -89,7 +89,7 @@ output_prompt(shell_output_func output)
PT_THREAD(shell_input(struct pt *pt, shell_output_func output, const char *cmd)) PT_THREAD(shell_input(struct pt *pt, shell_output_func output, const char *cmd))
{ {
static char *args; static char *args;
static struct shell_command_t *cmd_ptr; static const struct shell_command_t *cmd_ptr;
PT_BEGIN(pt); PT_BEGIN(pt);