From a64b0fe1e366028fa5371c2fe39d42109c3d6221 Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Wed, 13 Feb 2019 14:58:26 +0100 Subject: [PATCH] shell: Deprecate macros for subcommands creation Macros are replaced by C++ friendly versions: - SHELL_CREATE_STATIC_SUBCMD_SET by SHELL_STATIC_SUBCMD_SET_CREATE - SHELL_CREATE_DYNAMIC_CMD by SHELL_DYNAMIC_CMD_CREATE Signed-off-by: Krzysztof Chruscinski --- include/shell/shell.h | 10 ++++++---- samples/subsys/shell/shell_module/src/dynamic_cmd.c | 2 +- subsys/logging/log_cmds.c | 6 +++--- subsys/net/ip/net_shell.c | 4 ++-- tests/shell/src/main.c | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/shell/shell.h b/include/shell/shell.h index befc09de78d..54787179df2 100644 --- a/include/shell/shell.h +++ b/include/shell/shell.h @@ -177,12 +177,14 @@ struct shell_static_entry { } /** - * @brief Macro for creating a subcommand set. It must be used outside of any - * function body. + * @brief Deprecated macro for creating a subcommand set. + * + * It must be used outside of any function body. * * @param[in] name Name of the subcommand set. */ #define SHELL_CREATE_STATIC_SUBCMD_SET(name) \ + __DEPRECATED_MACRO \ static const struct shell_static_entry shell_##name[]; \ static const struct shell_cmd_entry name = { \ .is_dynamic = false, \ @@ -210,13 +212,13 @@ struct shell_static_entry { } /** - * @brief Macro for creating a dynamic entry. + * @brief Deprecated macro for creating a dynamic entry. * * @param[in] name Name of the dynamic entry. * @param[in] get Pointer to the function returning dynamic commands array */ #define SHELL_CREATE_DYNAMIC_CMD(name, get) \ - SHELL_DYNAMIC_CMD_CREATE(name, get) + __DEPRECATED_MACRO SHELL_DYNAMIC_CMD_CREATE(name, get) /** * @brief Initializes a shell command with arguments. diff --git a/samples/subsys/shell/shell_module/src/dynamic_cmd.c b/samples/subsys/shell/shell_module/src/dynamic_cmd.c index 0c655c0429f..f9ac0097edc 100644 --- a/samples/subsys/shell/shell_module/src/dynamic_cmd.c +++ b/samples/subsys/shell/shell_module/src/dynamic_cmd.c @@ -155,7 +155,7 @@ static void dynamic_cmd_get(size_t idx, struct shell_static_entry *entry) } } -SHELL_CREATE_DYNAMIC_CMD(m_sub_dynamic_set, dynamic_cmd_get); +SHELL_DYNAMIC_CMD_CREATE(m_sub_dynamic_set, dynamic_cmd_get); SHELL_STATIC_SUBCMD_SET_CREATE(m_sub_dynamic, SHELL_CMD_ARG(add, NULL, "Add a new dynamic command.\nExample usage: [ dynamic add test " diff --git a/subsys/logging/log_cmds.c b/subsys/logging/log_cmds.c index c7e328e918e..87148064743 100644 --- a/subsys/logging/log_cmds.c +++ b/subsys/logging/log_cmds.c @@ -266,7 +266,7 @@ static int cmd_log_backend_disable(const struct shell *shell, static void module_name_get(size_t idx, struct shell_static_entry *entry); -SHELL_CREATE_DYNAMIC_CMD(dsub_module_name, module_name_get); +SHELL_DYNAMIC_CMD_CREATE(dsub_module_name, module_name_get); static void module_name_get(size_t idx, struct shell_static_entry *entry) { @@ -286,7 +286,7 @@ static void severity_lvl_get(size_t idx, struct shell_static_entry *entry) severity_lvls_sorted[idx] : NULL; } -SHELL_CREATE_DYNAMIC_CMD(dsub_severity_lvl, severity_lvl_get); +SHELL_DYNAMIC_CMD_CREATE(dsub_severity_lvl, severity_lvl_get); static int log_halt(const struct shell *shell, const struct log_backend *backend, @@ -394,7 +394,7 @@ static void backend_name_get(size_t idx, struct shell_static_entry *entry) } } -SHELL_CREATE_DYNAMIC_CMD(dsub_backend_name_dynamic, backend_name_get); +SHELL_DYNAMIC_CMD_CREATE(dsub_backend_name_dynamic, backend_name_get); SHELL_STATIC_SUBCMD_SET_CREATE(sub_log_stat, diff --git a/subsys/net/ip/net_shell.c b/subsys/net/ip/net_shell.c index 15f85fa9643..1fc4d2cadfe 100644 --- a/subsys/net/ip/net_shell.c +++ b/subsys/net/ip/net_shell.c @@ -3637,7 +3637,7 @@ static char *set_iface_index_help(size_t idx) static void iface_index_get(size_t idx, struct shell_static_entry *entry); -SHELL_CREATE_DYNAMIC_CMD(iface_index, iface_index_get); +SHELL_DYNAMIC_CMD_CREATE(iface_index, iface_index_get); static void iface_index_get(size_t idx, struct shell_static_entry *entry) { @@ -3712,7 +3712,7 @@ static char *set_nbr_address(size_t idx) static void nbr_address_get(size_t idx, struct shell_static_entry *entry); -SHELL_CREATE_DYNAMIC_CMD(nbr_address, nbr_address_get); +SHELL_DYNAMIC_CMD_CREATE(nbr_address, nbr_address_get); #define NBR_ADDRESS_CMD &nbr_address diff --git a/tests/shell/src/main.c b/tests/shell/src/main.c index 7f08c5608e5..676a52cd1cc 100644 --- a/tests/shell/src/main.c +++ b/tests/shell/src/main.c @@ -268,7 +268,7 @@ static void dynamic_cmd_get(size_t idx, struct shell_static_entry *entry) } } -SHELL_CREATE_DYNAMIC_CMD(m_sub_test_dynamic, dynamic_cmd_get); +SHELL_DYNAMIC_CMD_CREATE(m_sub_test_dynamic, dynamic_cmd_get); SHELL_CMD_REGISTER(test_dynamic, &m_sub_test_dynamic, NULL, cmd_dynamic);