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 <jakub.rzeszutko@nordisemi.no>
This commit is contained in:
Jakub Rzeszutko 2020-10-01 09:23:03 +02:00 committed by Anas Nashif
commit 0cf6670b70

View file

@ -248,7 +248,6 @@ const struct shell_static_entry *shell_cmd_get(
size_t idx, size_t idx,
struct shell_static_entry *dloc) struct shell_static_entry *dloc)
{ {
__ASSERT_NO_MSG(dloc != NULL);
const struct shell_static_entry *res = NULL; const struct shell_static_entry *res = NULL;
if (parent == NULL) { if (parent == NULL) {
@ -256,6 +255,8 @@ const struct shell_static_entry *shell_cmd_get(
shell_root_cmd_get(idx)->u.entry : NULL; shell_root_cmd_get(idx)->u.entry : NULL;
} }
__ASSERT_NO_MSG(dloc != NULL);
if (parent->subcmd) { if (parent->subcmd) {
if (parent->subcmd->is_dynamic) { if (parent->subcmd->is_dynamic) {
parent->subcmd->u.dynamic_get(idx, dloc); parent->subcmd->u.dynamic_get(idx, dloc);