summaryrefslogtreecommitdiffstats
path: root/common/command.c
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2017-05-17 14:24:21 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-05-19 07:12:46 +0200
commitf6652e7404ba4f10923227c75da4db4c86b1275e (patch)
treeef004d99024cebc4bf1ec8cd5946b93798d8fb22 /common/command.c
parent495111d91a35f63d8fa68749f0c4fe3b0ad31e54 (diff)
downloadbarebox-f6652e7404ba4f10923227c75da4db4c86b1275e.tar.gz
barebox-f6652e7404ba4f10923227c75da4db4c86b1275e.tar.xz
commands: allow <cmd>_aliases[] to be const
Commands with aliases define an array of alias strings such as: static const char *<cmd>_aliases[] = { "<alias1>", NULL}; Although the elements are of type `const char *`, the elements themselves are not `const`-qualified. If the array is declared as: static const char * const <cmd>_aliases[] = { "<alias1>", NULL}; then the compiler warns about const qualifiers being discarded. This is because the `aliases` member of `struct command` is declared as `const char *aliases;`. Change the declaration of the `aliases` member of `struct command` to `const char * const *aliases;` so that it can point to a `const` array of `const char *`. Also change the declaration of the `aliases` variable in `register_command()` to avoid unnecessary type casts. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/command.c')
-rw-r--r--common/command.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/common/command.c b/common/command.c
index 03c70834d1..d9cc4a6d48 100644
--- a/common/command.c
+++ b/common/command.c
@@ -104,7 +104,7 @@ int register_command(struct command *cmd)
list_add_sort(&cmd->list, &command_list, compare);
if (cmd->aliases) {
- char **aliases = (char**)cmd->aliases;
+ const char * const *aliases = cmd->aliases;
while(*aliases) {
struct command *c = xzalloc(sizeof(struct command));