diff --git a/include/nuttx/init.h b/include/nuttx/init.h index 19cbf784e78..697c509112e 100644 --- a/include/nuttx/init.h +++ b/include/nuttx/init.h @@ -45,6 +45,7 @@ #define OSINIT_HW_READY() (g_nx_initstate >= OSINIT_HARDWARE) #define OSINIT_OS_READY() (g_nx_initstate >= OSINIT_OSREADY) #define OSINIT_IDLELOOP() (g_nx_initstate >= OSINIT_IDLELOOP) +#define OSINIT_IS_PANIC() (g_nx_initstate >= OSINIT_PANIC) #define OSINIT_OS_INITIALIZING() (g_nx_initstate < OSINIT_OSREADY) /**************************************************************************** diff --git a/sched/misc/assert.c b/sched/misc/assert.c index c9cb58ac4cc..0c89d62a7df 100644 --- a/sched/misc/assert.c +++ b/sched/misc/assert.c @@ -833,7 +833,7 @@ void _assert(FAR const char *filename, int linenum, struct panic_notifier_s notifier_data; irqstate_t flags; - if (g_nx_initstate == OSINIT_PANIC) + if (OSINIT_IS_PANIC()) { /* Already in fatal state, reset board directly. */ @@ -885,7 +885,7 @@ void _assert(FAR const char *filename, int linenum, notifier_data.filename = filename; notifier_data.linenum = linenum; notifier_data.msg = msg; - panic_notifier_call_chain(g_nx_initstate == OSINIT_PANIC + panic_notifier_call_chain(OSINIT_IS_PANIC() ? PANIC_KERNEL : PANIC_TASK, ¬ifier_data); #ifdef CONFIG_ARCH_LEDS @@ -902,7 +902,7 @@ void _assert(FAR const char *filename, int linenum, dump_assert_info(rtcb, filename, linenum, msg, regs); #endif - if (g_nx_initstate == OSINIT_PANIC) + if (OSINIT_IS_PANIC()) { /* Dump fatal info of assertion. */ diff --git a/sched/sched/sched_backtrace.c b/sched/sched/sched_backtrace.c index 3d677308a3c..bdf95d2974f 100644 --- a/sched/sched/sched_backtrace.c +++ b/sched/sched/sched_backtrace.c @@ -111,8 +111,8 @@ int sched_backtrace(pid_t tid, FAR void **buffer, int size, int skip) if (tcb != NULL) { #ifdef CONFIG_SMP - if (tcb->task_state == TSTATE_TASK_RUNNING && - g_nx_initstate != OSINIT_PANIC) + if (!OSINIT_IS_PANIC() && + tcb->task_state == TSTATE_TASK_RUNNING) { struct backtrace_arg_s arg;