From 0cf6670b7024a45d1aff3c21f3fb7fcc14d218bf Mon Sep 17 00:00:00 2001 From: Jakub Rzeszutko Date: Thu, 1 Oct 2020 09:23:03 +0200 Subject: [PATCH] shell: improve function shell_cmd_get The function can return existing root command even if dloc argument is a NULL pointer. Signed-off-by: Jakub Rzeszutko --- subsys/shell/shell_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subsys/shell/shell_utils.c b/subsys/shell/shell_utils.c index 0f4045b9bb2..844c0fc6db0 100644 --- a/subsys/shell/shell_utils.c +++ b/subsys/shell/shell_utils.c @@ -248,7 +248,6 @@ const struct shell_static_entry *shell_cmd_get( size_t idx, struct shell_static_entry *dloc) { - __ASSERT_NO_MSG(dloc != NULL); const struct shell_static_entry *res = NULL; if (parent == NULL) { @@ -256,6 +255,8 @@ const struct shell_static_entry *shell_cmd_get( shell_root_cmd_get(idx)->u.entry : NULL; } + __ASSERT_NO_MSG(dloc != NULL); + if (parent->subcmd) { if (parent->subcmd->is_dynamic) { parent->subcmd->u.dynamic_get(idx, dloc);