subsys/shell: check for shell context before accessing it

The ASSERT order is backwards, where the shell->ctx is being accessed
before it is being checked as valid.  Moving the check for the
shell->ctx to before the using it.

Signed-off-by: Dan Kalowsky <dkalowsky@amperecomputing.com>
This commit is contained in:
Dan Kalowsky 2021-02-18 17:02:51 -08:00 committed by Carles Cufí
commit 305ba26c6e

View file

@ -1408,9 +1408,9 @@ void shell_vfprintf(const struct shell *shell, enum shell_vt100_color color,
{
__ASSERT_NO_MSG(shell);
__ASSERT(!k_is_in_isr(), "Thread context required.");
__ASSERT_NO_MSG(shell->ctx);
__ASSERT_NO_MSG((shell->ctx->internal.flags.cmd_ctx == 1) ||
(k_current_get() != shell->ctx->tid));
__ASSERT_NO_MSG(shell->ctx);
__ASSERT_NO_MSG(shell->fprintf_ctx);
__ASSERT_NO_MSG(fmt);