shell: Refactor shell argument count validation

Shell arguments structure was stored as a pointer in shell structure
and NULL pointer indicated that argument count checking is skipped.
It has been reworked to hold the structure (2 bytes) in the shell
structure with mandatory=0 skipping the check. This approach is cpp
friendly, contrary to the legacy one.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2019-02-12 14:09:19 +01:00 committed by Anas Nashif
commit 349dd964e0
2 changed files with 8 additions and 19 deletions

View file

@ -110,7 +110,7 @@ struct shell_static_entry {
const char *help; /*!< Command help string. */
const struct shell_cmd_entry *subcmd; /*!< Pointer to subcommand. */
shell_cmd_handler handler; /*!< Command handler. */
const struct shell_static_args *args; /*!< Command arguments. */
struct shell_static_args args; /*!< Command arguments. */
};
/**
@ -213,8 +213,7 @@ struct shell_static_entry {
.subcmd = _subcmd, \
.help = (const char *)_help, \
.handler = _handler, \
.args = _mandatory ? \
(&(struct shell_static_args) SHELL_ARG(_mandatory, _optional)) : NULL \
.args = SHELL_ARG(_mandatory, _optional) \
}
/**