mirror of
https://github.com/apache/nuttx.git
synced 2026-05-13 02:18:38 +08:00
sched/assert: Call abort() instead of exit() in assert
POSIX dictates that assert() terminates via abort(), even though in NuttX abort() just calls exit(EXIT_FAILURE) it is better to use the correct API here, if at some point a proper implementation for abort() is made. Also, as the kernel must not use abort() which is a userspace API, direct the exit to PANIC() if for some reason _assert() returns (it should not but trap it here just in case).
This commit is contained in:
@@ -27,6 +27,16 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* If assert() is called from kernel, must not call user API abort */
|
||||
|
||||
#ifdef __KERNEL__
|
||||
# define abort PANIC
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -34,5 +44,5 @@
|
||||
void __assert(FAR const char *filename, int linenum, FAR const char *msg)
|
||||
{
|
||||
_assert(filename, linenum, msg);
|
||||
exit(EXIT_FAILURE);
|
||||
abort();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user